Data storage method, device, storage medium and electronic device

By clustering storage devices and generating index information, the problem of low data access efficiency in deep learning model training is solved, the data storage location is quickly located, metadata access overhead is eliminated, and model training efficiency is improved.

CN118394282BActive Publication Date: 2024-08-30ZHEJIANG LAB
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202410849941.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-27
Publication Date
2024-08-30
Estimated Expiration
2044-06-27

AI Technical Summary

Technical Problem

During the training process of deep learning models, since the training data set consists of a large number of small files, metadata management and access efficiency is low, which affects the training efficiency of the model.

Method used

By clustering the storage space of the storage device according to the data size, each data is stored in a block that matches its size, and index information is generated to locate the data storage address, reducing metadata access overhead.

Benefits of technology

It improves data access efficiency, reduces the time overhead of metadata parsing and processing during model training, and improves overall business execution efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118394282B
    Figure CN118394282B
Patent Text Reader

Abstract

The specification discloses a data storage method, device, storage medium and electronic device. The data storage method includes: obtaining each data to be stored; sorting each data according to the storage space occupied by each data, and determining the data number corresponding to each data based on the sorting result, and dividing the storage space of the storage device into several clusters; for each data, storing the data in a block matching the storage space occupied by the data; for each cluster, according to the data number corresponding to the data stored in the first block in the cluster, the data number corresponding to the data stored in the last block in the cluster, the storage address corresponding to the first block and the size of the blocks in the cluster, generate and store the index information of the cluster. The data storage method provided by this solution can greatly improve the access efficiency when reading data, and further improve the business efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a data storage method, device, storage medium and electronic device. Background Art

[0002] With the rapid development of artificial intelligence, deep learning models have begun to be widely used in many fields such as driving, aerospace, industry, and medicine. In the training process of deep learning models, it is usually necessary to train the model for several rounds to achieve convergence goals. Each round of training will access the entire data set samples in a random sequence.

[0003] Currently, it is usually necessary to access data in the file system based on metadata. However, since the training data set in the model training process is usually composed of a large number of small files, this requires the management and maintenance of a large amount of metadata. In the process of data access, the process of parsing, reading and processing metadata will undoubtedly bring additional time overhead, reduce data access efficiency, and further affect the efficiency of model training.

[0004] Therefore, how to improve data access efficiency is an urgent problem to be solved. Summary of the invention

[0005] This specification provides a data storage method, device, storage medium and electronic device to partially solve the above problems existing in the prior art.

[0006] This manual adopts the following technical solutions:

[0007] This specification provides a data storage method, including:

[0008] Receiving a data storage request, and acquiring each data to be stored according to the data storage request;

[0009] Sort the data according to the storage space occupied by each data, and determine the data number corresponding to each data based on the sorting result, and

[0010] Based on the sizes of different blocks, the storage space of the storage device is divided into a plurality of clusters, wherein for each cluster, the cluster contains a plurality of blocks of the same size, and the sizes of the blocks in different clusters are different;

[0011] For each data, the data is stored in a block matching the storage space occupied by the data;

[0012] For each cluster, each block contained in the cluster is sorted according to the storage space occupied by the data stored in each block contained in the cluster. According to the data number corresponding to the data stored in the first block in the cluster, the data number corresponding to the data stored in the last block in the cluster, the storage address corresponding to the first block and the size of the blocks in the cluster, the index information of the cluster is generated and stored. The index information is used to determine the storage address of the data to be read during the data reading process.

[0013] Optionally, the method further comprises:

[0014] receiving a data read request for target data;

[0015] Determine, according to the data read request, a data number corresponding to the target data as a target number;

[0016] The storage address corresponding to the target data is determined according to the target number and the index information corresponding to each cluster in the storage device, and the target data is read according to the storage address corresponding to the target data.

[0017] Optionally, determining the storage address corresponding to the target data according to the target number and the index information corresponding to each cluster in the storage device specifically includes:

[0018] For each cluster, according to the index information of the cluster, determine the data number range of the data stored in the cluster as the number range corresponding to the cluster;

[0019] According to the number range corresponding to each cluster, determine the cluster where the target data is located as the target cluster;

[0020] The storage address corresponding to the target data is determined according to the index information corresponding to the target cluster and the target number.

[0021] Optionally, for each cluster, determining a data serial number range of data stored in the cluster according to the index information of the cluster specifically includes:

[0022] The number range is determined according to the data number corresponding to the data stored in the first block and the data number corresponding to the data stored in the last block included in the index information of the cluster.

[0023] Optionally, determining the storage address corresponding to the target data according to the index information corresponding to the target cluster and the target number specifically includes:

[0024] The storage address corresponding to the target data is determined according to the target number, the data number corresponding to the data stored in the first block contained in the index information corresponding to the target cluster, the storage address corresponding to the first block and the size of the block in the target cluster.

[0025] Optionally, determining a storage address corresponding to the target data according to the target number and index information corresponding to each cluster in the storage device, and reading the target data according to the storage address corresponding to the target data specifically includes:

[0026] Determine the target block where the target data is located according to the target number and the index information corresponding to each cluster in the storage device, and determine the storage address corresponding to the target block and the header information of the target block, wherein the header information includes the data size of the target data;

[0027] The target data is read from the target block according to the storage address and the header information.

[0028] Optionally, the header information also includes: verification information and permission information corresponding to the target data;

[0029] Reading the target data from the target block according to the storage address and the header information specifically includes:

[0030] Obtaining the identity carried in the data reading request, and verifying the identity based on the permission information;

[0031] If the verification is successful, the target data is read according to the storage address and the data size of the target data, and a consistency check is performed on the read target data based on the check information.

[0032] This specification provides a data storage device, including:

[0033] A receiving module, used to receive a data storage request, and obtain each data to be stored according to the data storage request;

[0034] A sorting module is used to sort each data according to the storage space occupied by each data, and determine the data number corresponding to each data based on the sorting result, and

[0035] Based on the sizes of different blocks, the storage space of the storage device is divided into a plurality of clusters, wherein for each cluster, the cluster contains a plurality of blocks of the same size, and the sizes of the blocks in different clusters are different;

[0036] A storage module, used for storing each data in a block matching the storage space occupied by the data;

[0037] An index module is used to sort each block contained in each cluster according to the storage space occupied by the data stored in each block contained in the cluster, and generate and store index information of the cluster according to the data number corresponding to the data stored in the first block in the cluster, the data number corresponding to the data stored in the last block in the cluster, the storage address corresponding to the first block and the size of the blocks in the cluster. The index information is used to determine the storage address of the data to be read during the data reading process.

[0038] This specification provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned data storage method is implemented.

[0039] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned data storage method when executing the program.

[0040] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:

[0041] In the data storage method provided in the present specification, each data to be stored is obtained; each data is sorted according to the storage space occupied by each data, and the data number corresponding to each data is determined based on the sorting result, and the storage space of the storage device is divided into a plurality of clusters; for each data, the data is stored in a block matching the storage space occupied by the data; for each cluster, the index information of the cluster is generated and stored according to the data number corresponding to the data stored in the first block in the cluster, the data number corresponding to the data stored in the last block in the cluster, the storage address corresponding to the first block and the size of the blocks in the cluster.

[0042] From the above method, it can be seen that in the process of storing data, this solution will first sort the data based on the size and store it in blocks. Each cluster to which the data block belongs has corresponding index information. In this way, in the subsequent data reading process, the block address where the data is located can be directly located based on the index information, and there is no need to access it based on metadata. Compared with the current method of parsing and processing the metadata of each data before reading it, this solution only needs to locate the data based on the index information containing a small amount of data, eliminating the overhead brought by accessing metadata, improving data access efficiency, and further ensuring the overall execution efficiency of the business. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The illustrative embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation on this specification. In the drawings:

[0044] Figure 1 A schematic diagram of a data storage method provided in this specification;

[0045] Figure 2 A schematic diagram of a data storage architecture provided in this specification;

[0046] Figure 3 Provides a schematic diagram of index information for the instruction manual;

[0047] Figure 4 A schematic diagram of a data storage device provided in this specification;

[0048] Figure 5 A method corresponding to the Figure 1 Schematic diagram of electronic equipment. DETAILED DESCRIPTION

[0049] In order to make the purpose, technical solutions and advantages of this specification more clear, the technical solutions of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.

[0050] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.

[0051] Figure 1 This is a flow chart of a data storage method provided in this specification, comprising the following steps:

[0052] S101: receiving a data storage request, and acquiring data to be stored according to the data storage request.

[0053] During the training process of a deep learning model, a large number of access operations are usually required to the training samples stored in the storage device, and the access efficiency to the training samples affects the overall efficiency of the model training.

[0054] In practical applications, the size distribution of training samples in the same training data set is usually within a certain range, such as between tens of KB and hundreds of KB. Based on this, this specification provides a data storage method, which numbers the data in ascending order, and then divides it into several clusters according to the size distribution. For the files in each cluster, a fixed-size block is used for storage in the storage medium.

[0055] During the model training process, the training program generates a random sequence with the file number in each round and uses this sequence for training, and locates the sample data storage address by the file number. The fixed-length storage method provided by this solution enables the training program to quickly locate the data storage location and eliminate the metadata overhead when accessing the training data.

[0056] In this specification, the execution subject for implementing a data storage method may be a designated device such as a server. For ease of description, the following will only take the server as an execution subject as an example to illustrate a data storage method provided in this specification.

[0057] In the process of storing data, the server may receive a data storage request, and obtain the data to be stored uploaded by the user according to the data storage request.

[0058] In actual applications, the above-mentioned data storage request may refer to a storage request for sample data during the model training process, and the stored data is the sample data used in the model training. Of course, the above-mentioned data storage request may also be business data involved in the process of executing other businesses such as data statistics, data management, data detection, etc. This specification does not make specific limitations on this.

[0059] S102: Sort each data according to the storage space occupied by each data, determine the data number corresponding to each data based on the sorting result, and divide the storage space of the storage device into a plurality of clusters based on the sizes of different blocks, wherein for each cluster, the cluster contains a plurality of blocks of the same size, and the sizes of blocks in different clusters are different.

[0060] After obtaining the data to be stored, the server may sort the data according to the storage space occupied by each data, and number the data based on the sorting result.

[0061] For example, the server may sort the data in ascending order, that is, the data number of the smallest data is 0.

[0062] At the same time, the server can divide the storage space of the storage device into a plurality of clusters based on the sizes of different blocks, wherein a cluster contains a plurality of blocks of the same size, while the sizes of blocks in different clusters are different.

[0063] The block size is an integer multiple of the size of the basic storage unit in the storage device. When allocating space to blocks, continuous address space can be allocated to blocks of the same cluster.

[0064] In the process of dividing the storage space of the storage device, the server may divide the disk of the storage device into multiple partitions, each partition corresponding to a cluster.

[0065] As for the distributed storage device, which includes multiple storage nodes, the server can be clustered according to the storage nodes, that is, each storage node corresponds to a cluster.

[0066] Furthermore, before clustering the storage space, the server may determine whether the storage space occupied by each data is uniform, that is, whether the deviation between the data sizes of each data is within a preset range. If so, the server may not cluster the storage space, but directly divide the storage space into several blocks of the same size, thereby mapping the data number corresponding to the data stored in each block to the block address.

[0067] If the storage space occupied by each data is uneven, the storage space can be further clustered.

[0068] In addition, when the storage space is sufficient, the server may not judge whether the storage space occupied by each data is uniform, but directly divide the storage space into several blocks of the same size, and the size of the block can accommodate the data that occupies the largest space, thereby improving access performance by trading space for time.

[0069] It should be noted that the storage space of the above storage device may refer to the storage space of the memory, and of course, may also refer to the storage space of the cache.

[0070] In addition, in actual applications, it is very likely that the storage space is occupied by other business data. Therefore, in this specification, the storage addresses between different clusters may not be continuous.

[0071] S103: For each data, store the data in a block that matches the storage space occupied by the data.

[0072] S104: For each cluster, sort each block contained in the cluster according to the storage space occupied by the data stored in each block contained in the cluster, and generate and store index information of the cluster according to the data number corresponding to the data stored in the first block in the cluster, the data number corresponding to the data stored in the last block in the cluster, the storage address corresponding to the first block, and the size of the blocks in the cluster. The index information is used to determine the storage address of the data to be read during the data reading process.

[0073] For each data, the server may store the data in a block that matches the storage space occupied by the data.

[0074] In this specification, there may be multiple ways to determine the blocks that match the storage space occupied by data. For example, for data a and block b, if after data a is stored in block b, the remaining storage space in b is lower than a preset threshold, it means that the storage space occupied by data a matches block b, thereby avoiding a waste of storage space. The above-mentioned preset threshold can be set according to actual conditions, and this specification does not make any specific restrictions on this.

[0075] For example, if after data a is stored in block b, the remaining storage space in block b is insufficient to store the remaining unstored data, it means that the storage space occupied by data a matches block b.

[0076] It should be noted that, since the same cluster contains multiple blocks of the same size, one piece of data may correspond to multiple matching blocks. In this case, the server may store the matching data in sequence based on the position of each block in the same cluster.

[0077] The server may use the data number corresponding to the data stored in each block as the block number corresponding to each block, so that the data number corresponds to the block number one by one.

[0078] Of course, the server can also sort the blocks in different clusters according to the sizes of different blocks, wherein, for the blocks in the same cluster, the corresponding block numbers can be determined in sequence based on the positions of these blocks. Then, the server can store each data in a block that matches the storage space it occupies based on the block numbers corresponding to different blocks and the data numbers corresponding to different data. Since the order of blocks is the same as the order of data size, the data numbers and block numbers correspond one to one at this time.

[0079] For example, the data block number range in cluster 0 is 0-3, and the data block number range in cluster 1 is 4-7. For the data numbered 0-7, the server can store them in blocks with the same number according to the data numbers corresponding to these data.

[0080] For each block, the header information of the block may store the data size of the data stored in the block, the data verification information and the permission information, wherein the data verification information may be the hash value of the data, which is used to perform consistency verification on the read data during the data reading process, and the permission information is used to limit the users who are allowed to access the data.

[0081] Furthermore, for each cluster, the server can sort each block contained in the cluster according to the storage space occupied by the data stored in each block contained in the cluster, and generate and store the index information of the cluster according to the data number corresponding to the data stored in the first block in the cluster, the data number corresponding to the data stored in the last block in the cluster, the storage address corresponding to the first block, and the size of the blocks in the cluster. The index information is used to determine the storage address of the data to be read during the data reading process. For ease of understanding, this specification provides a schematic diagram of a data storage architecture, such as Figure 2 shown.

[0082] Figure 2 A schematic diagram of a data storage architecture provided in this manual.

[0083] Among them, the server can divide the 4 data numbers 0 to 3 into the data blocks in the first cluster (cluster number 0) for storage, and divide the data numbers 4 to 7 into the data blocks in the second cluster (cluster number 1) for storage. The size of the block in cluster 0 is determined by the largest file in the cluster, that is, file number 3; the block in cluster 0 should be able to fully accommodate the data content of file number 3 and the corresponding block header data. In addition, the block size is aligned according to the media access unit size, and for each block, the header information is stored in the block header of the block.

[0084] The server can then generate an index list based on the index information corresponding to each cluster.

[0085] In model training, it is usually necessary to read sample data from a storage device. During this process, the server can receive a data read request for the target data to be read. Then, according to the data read request, the data number corresponding to the target data is determined as the target number.

[0086] The server may determine the storage address corresponding to the target data according to the target number and the above index list, and read the target data according to the storage address corresponding to the target data.

[0087] Specifically, for each cluster, the server can determine the data number range of the data stored in the cluster according to the index information of the cluster, as the number range corresponding to the cluster, and determine the cluster where the target data is located according to the number range corresponding to each cluster, as the target cluster, and then determine the storage address corresponding to the target data according to the index information corresponding to the target cluster and the target number.

[0088] Among them, for each cluster, the server can determine the number range corresponding to the cluster based on the data number corresponding to the data stored in the first block and the data number corresponding to the data stored in the last block contained in the index information of the cluster (that is, the number corresponding to the starting data block and the number corresponding to the last data block).

[0089] After determining the target cluster, the server can determine the storage address corresponding to the target data according to the target number, the data number corresponding to the data stored in the first block contained in the index information corresponding to the target cluster, the storage address corresponding to the first block, and the size of the block in the target cluster. For ease of understanding, this specification provides a schematic diagram of index information, such as Figure 3 shown.

[0090] Figure 3 A schematic diagram of index information is provided for the instruction manual.

[0091] The server can determine the cluster where the requested sample is located based on the starting block number and the ending block number, and then calculate the address of the block where the sample is located based on the sample number, the cluster starting block number, the block size, and the cluster starting address. The calculation formula for the block address where the sample is located is: (sample number - cluster starting block number) × block size + cluster address. Figure 3 Take the index information shown in the figure as an example. When accessing the sample numbered 153, the cluster index list is searched first. The data of channel 153 is in cluster 1. The block address is calculated according to the above formula, that is, (153 - 100) × 12288 + 40960 = 692224. That is to say, the block address of the sample is 692224. The server can read the 4 bytes of the block header from this address to get the sample data size, and then read the subsequent target data.

[0092] In the process of reading the data stored in the block, the server may read the target data from the target block according to the determined storage address (block address) and the header information of the block.

[0093] The server may read the entire block at one time according to the block address, and obtain the target data according to the sample data size in the header information.

[0094] In addition, during the data reading process, the server can obtain the identity carried in the data reading request, and verify the identity based on the permission information contained in the block information. If the verification passes, the target data is read according to the storage address and the data size of the target data, and the consistency of the read target data is checked based on the verification information (such as calculating the hash value of the read data, and determining whether the read hash value is consistent with the target hash value corresponding to the verification information).

[0095] If the identity authentication fails or the consistency check fails, the target data cannot be read and a failure message is fed back to the user.

[0096] After obtaining the target data, the server can perform services based on the target data. When the target data is sample data, the server can perform model training tasks based on the sample data read, and when the target data is service data corresponding to other services, the server can perform other services based on the read data.

[0097] It can be seen from the above method that this scheme can number the data according to the size of the data and store it sequentially according to the number; reduce the data index overhead through fixed-length block storage; and reduce the space waste in fixed-length storage for data sets with large size distribution variance through clustering.

[0098] The above are one or more data storage methods implemented in this specification. Based on the same idea, this specification also provides corresponding data storage devices, such as Figure 4 shown.

[0099] Figure 4 A schematic diagram of a data storage device provided in this specification includes:

[0100] The receiving module 401 is used to receive a data storage request and obtain the data to be stored according to the data storage request;

[0101] A sorting module 402 is used to sort each data according to the storage space occupied by each data, and determine the data number corresponding to each data based on the sorting result, and

[0102] Based on the sizes of different blocks, the storage space of the storage device is divided into a plurality of clusters, wherein for each cluster, the cluster contains a plurality of blocks of the same size, and the sizes of the blocks in different clusters are different;

[0103] The storage module 403 is used to store each data in a block matching the storage space occupied by the data;

[0104] The index module 404 is used to sort each block contained in each cluster according to the storage space occupied by the data stored in each block contained in the cluster, and generate and store the index information of the cluster according to the data number corresponding to the data stored in the first block in the cluster, the data number corresponding to the data stored in the last block in the cluster, the storage address corresponding to the first block and the size of the blocks in the cluster. The index information is used to determine the storage address of the data to be read during the data reading process.

[0105] Optionally, the device further comprises:

[0106] The reading module 405 is used to receive a data reading request for target data; determine the data number corresponding to the target data as the target number according to the data reading request; determine the storage address corresponding to the target data according to the target number and the index information corresponding to each cluster in the storage device, and read the target data according to the storage address corresponding to the target data.

[0107] Optionally, the reading module 405 is specifically used to, for each cluster, determine, based on the index information of the cluster, a data number range of the data stored in the cluster as the number range corresponding to the cluster; determine, based on the number range corresponding to each cluster, the cluster where the target data is located as the target cluster; and determine, based on the index information corresponding to the target cluster and the target number, the storage address corresponding to the target data.

[0108] Optionally, the reading module 405 is specifically configured to determine the numbering range according to a data number corresponding to data stored in a first block and a data number corresponding to data stored in a last block included in the index information of the cluster.

[0109] Optionally, the reading module 405 is specifically used to determine the storage address corresponding to the target data based on the target number, the data number corresponding to the data stored in the first block contained in the index information corresponding to the target cluster, the storage address corresponding to the first block, and the size of the block in the target cluster.

[0110] Optionally, the reading module 405 is specifically used to determine the target block where the target data is located, and determine the storage address corresponding to the target block and the header information of the target block according to the target number and the index information corresponding to each cluster in the storage device, wherein the header information includes the data size of the target data;

[0111] The target data is read from the target block according to the storage address and the header information.

[0112] Optionally, the header information also includes: verification information and permission information corresponding to the target data;

[0113] The reading module 405 is specifically used to obtain the identity carried in the data reading request, and verify the identity based on the permission information;

[0114] If the verification is successful, the target data is read according to the storage address and the data size of the target data, and a consistency check is performed on the read target data based on the check information.

[0115] This specification also provides a computer-readable storage medium, which stores a computer program, which can be used to execute the above Figure 1 A data storage method is provided.

[0116] This manual also provides Figure 5 The one shown corresponds to Figure 1 A schematic diagram of the electronic device. Figure 5 As mentioned above, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include other hardware required for the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 Of course, in addition to the software implementation, this specification does not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0117] For the improvement of a technology, it can be clearly distinguished whether it is a hardware improvement (for example, improvement of the circuit structure of diodes, transistors, switches, etc.) or a software improvement (improvement of the method flow). However, with the development of technology, many improvements of the method flow today can be regarded as direct improvements of the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be implemented with a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming themselves, without having to ask chip manufacturers to design and make dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0118] The controller may be implemented in any suitable manner, for example, the controller may take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (e.g., software or firmware) executable by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, and the memory controller may also be implemented as part of the control logic of the memory. It is also known to those skilled in the art that, in addition to implementing the controller in a purely computer-readable program code manner, the controller may be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, such a controller may be considered as a hardware component, and the devices for implementing various functions included therein may also be considered as structures within the hardware component. Or even, the devices for implementing various functions may be considered as both software modules for implementing the method and structures within the hardware component.

[0119] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0120] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0121] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0122] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0123] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0124] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0125] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0126] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0127] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0128] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0129] It should be understood by those skilled in the art that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0130] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0131] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0132] The above description is only an embodiment of the present specification and is not intended to limit the present specification. For those skilled in the art, the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of the claims of the present specification.

Claims

1. A data storage method, characterized in that: include: Receiving a data storage request, and acquiring each data to be stored according to the data storage request; Sort the data according to the storage space occupied by each data, and determine the data number corresponding to each data based on the sorting result, and Based on the sizes of different blocks, the storage space of the storage device is divided into a plurality of clusters, wherein for each cluster, the cluster contains a plurality of blocks of the same size, and the sizes of the blocks in different clusters are different; For each data, the data is stored in a block that matches the storage space occupied by the data, wherein for each block, if the remaining storage space in the block is lower than a preset threshold after the data is stored in the block, the storage space occupied by the data matches the block; For each cluster, each block contained in the cluster is sorted according to the storage space occupied by the data stored in each block contained in the cluster. According to the data number corresponding to the data stored in the first block in the cluster, the data number corresponding to the data stored in the last block in the cluster, the storage address corresponding to the first block and the size of the blocks in the cluster, the index information of the cluster is generated and stored. The index information is used to determine the storage address of the data to be read during the data reading process.

2. The method according to claim 1, characterized in that The method further comprises: receiving a data read request for target data; Determine, according to the data read request, a data number corresponding to the target data as a target number; The storage address corresponding to the target data is determined according to the target number and the index information corresponding to each cluster in the storage device, and the target data is read according to the storage address corresponding to the target data.

3. The method according to claim 2, characterized in that Determining a storage address corresponding to the target data according to the target number and index information corresponding to each cluster in the storage device specifically includes: For each cluster, according to the index information of the cluster, determine the data number range of the data stored in the cluster as the number range corresponding to the cluster; According to the number range corresponding to each cluster, determine the cluster where the target data is located as the target cluster; The storage address corresponding to the target data is determined according to the index information corresponding to the target cluster and the target number.

4. The method according to claim 3, characterized in that For each cluster, the data number range of the data stored in the cluster is determined according to the index information of the cluster, specifically including: The number range is determined according to the data number corresponding to the data stored in the first block and the data number corresponding to the data stored in the last block included in the index information of the cluster.

5. The method according to claim 3, characterized in that Determining a storage address corresponding to the target data according to the index information corresponding to the target cluster and the target number specifically includes: The storage address corresponding to the target data is determined according to the target number, the data number corresponding to the data stored in the first block contained in the index information corresponding to the target cluster, the storage address corresponding to the first block and the size of the block in the target cluster.

6. The method according to claim 2, characterized in that Determining a storage address corresponding to the target data according to the target number and index information corresponding to each cluster in the storage device, and reading the target data according to the storage address corresponding to the target data, specifically includes: Determine the target block where the target data is located according to the target number and the index information corresponding to each cluster in the storage device, and determine the storage address corresponding to the target block and the header information of the target block, wherein the header information includes the data size of the target data; The target data is read from the target block according to the storage address and the header information.

7. The method according to claim 6, characterized in that The header information also includes: verification information and permission information corresponding to the target data; Reading the target data from the target block according to the storage address and the header information specifically includes: Obtaining the identity carried in the data reading request, and verifying the identity based on the permission information; If the verification is successful, the target data is read according to the storage address and the data size of the target data, and a consistency check is performed on the read target data based on the check information.

8. A data storage device, characterized in that: include: A receiving module, used to receive a data storage request, and obtain each data to be stored according to the data storage request; A sorting module is used to sort each data according to the storage space occupied by each data, and determine the data number corresponding to each data based on the sorting result, and Based on the sizes of different blocks, the storage space of the storage device is divided into a plurality of clusters, wherein for each cluster, the cluster contains a plurality of blocks of the same size, and the sizes of the blocks in different clusters are different; A storage module, used for storing, for each data, the data in a block that matches the storage space occupied by the data, wherein, for each block, if after the data is stored in the block, the remaining storage space in the block is lower than a preset threshold, then the storage space occupied by the data matches the block; An index module is used to sort each block contained in each cluster according to the storage space occupied by the data stored in each block contained in the cluster, and generate and store index information of the cluster according to the data number corresponding to the data stored in the first block in the cluster, the data number corresponding to the data stored in the last block in the cluster, the storage address corresponding to the first block and the size of the blocks in the cluster. The index information is used to determine the storage address of the data to be read during the data reading process.

9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method described in any one of claims 1 to 7 is implemented.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Data storage and query method and device

    CN103914462A

  • Data storage method and device

    CN104298681A

  • File storage method, device and system

    CN107644056A

  • Data storage method and device

    CN110096477A

  • Distributed file storage system and file storage method

    CN110188084A