Data storage method, device, storage medium and electronic device
By optimizing the number combination and mapping relationship of the memory space, the problem of low computer operation efficiency caused by memory bottlenecks is solved, and more efficient data storage and reading are achieved.
Patent Information
- Application Number
- CN202410937903.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-12
AI Technical Summary
When the computer is running a program, the processor speed caused by memory bottleneck exceeds the memory reading speed, resulting in limited program running efficiency, and the memory reading efficiency based on the memory controller is limited, which cannot effectively improve the storage and reading efficiency of memory data. .
By determining the target memory space of the data to be stored, and numbering and combining the unit storage bits, using a non-sequential storage method, the data is evenly distributed to the memory spaces controlled by multiple memory controllers, and the actual logical address of the data is established. The mapping relationship of the original logical address optimizes the storage and reading process.
It improves data storage and reading efficiency, avoids uneven problems caused by sequential storage, reduces storage and reading time, and improves computer operating performance.
Smart Images

Figure CN118466863B_ABST
Abstract
Description
Technical Field
[0001] The present specification relates to the field of computer science, and in particular to a data storage method, device, storage medium and electronic device. Background Art
[0002] With the continuous development of computer science, computers can now help users complete different tasks through installed applications.
[0003] In recent years, the processing speed of computer processors has increased much faster than the reading speed of memory. For computers, the speed of processors often exceeds the reading speed of memory, which also leads to limited program running efficiency due to memory bottlenecks when computers run programs.
[0004] At present, multiple memory controllers are usually used to access multiple memory areas in the memory at the same time, so as to improve the memory reading speed through parallel access, thereby alleviating the problem caused by memory bottleneck. However, the data stored in the memory is often continuous, and the data is not evenly distributed in the memory areas accessed by each memory controller, which also leads to the limited memory reading efficiency based on the memory controller, thereby affecting the operation efficiency of the computer.
[0005] Therefore, how to effectively improve the storage and reading efficiency of memory data is an urgent problem to be solved. Summary of the invention
[0006] This specification provides a data storage method to partially solve the above problems existing in the prior art.
[0007] This manual adopts the following technical solutions:
[0008] This specification provides a data storage method, including:
[0009] Determining data to be stored, and according to the data to be stored, determining a number of target memory spaces for storing the data to be stored from a preset storage device;
[0010] Determine the number of storage bits of each unit contained in the plurality of target memory spaces;
[0011] According to the quantity, numbering each unit storage bit included in the plurality of target memory spaces to obtain a number corresponding to each unit storage bit included in the plurality of target memory spaces;
[0012] According to the amount of data included in the data to be stored, the numbers corresponding to the unit storage bits included in the plurality of target memory spaces are combined to obtain various number combinations, wherein the numbers included in at least some of the number combinations correspond to the unit storage bits in different target memory spaces, and all the number combinations contain the numbers corresponding to all the unit storage bits included in the plurality of target memory spaces;
[0013] For each data included in the data to be stored, determine the number combination corresponding to the data and the number corresponding to the data in the number combination as the target number corresponding to the data, so as to store the data according to the unit storage bit corresponding to the target number.
[0014] Optionally, according to the data to be stored, determining a number of target memory spaces for storing the data to be stored from a preset storage device specifically includes:
[0015] Determining each preset memory space contained in the storage device;
[0016] According to the amount of data contained in the data to be stored, a number of target memory spaces are selected from the preset memory spaces, and the number of memory spaces of the target memory spaces is greater than the number of memory spaces used when the data to be stored is stored in a manner of filling one memory space and then storing it in the next memory space.
[0017] Optionally, according to the amount of data included in the data to be stored, the numbers corresponding to the unit storage bits included in the plurality of target memory spaces are combined to obtain the number combinations, specifically including:
[0018] Determine a maximum number N corresponding to each unit storage bit contained in the plurality of target memory spaces, where N is a positive integer;
[0019] With the constraint that the sum of the numbers in the obtained number combinations is an integer multiple of N+1, the numbers corresponding to the unit storage bits contained in the plurality of target memory spaces are combined to obtain various number combinations.
[0020] Optionally, with the constraint that the sum of the numbers in the obtained number combinations is an integer multiple of N+1, the numbers corresponding to the unit storage bits contained in the plurality of target memory spaces are combined to obtain the number combinations, specifically including:
[0021] The numbers corresponding to the unit storage bits contained in the plurality of target memory spaces are sorted in ascending order to obtain a first numbering order, and the numbers corresponding to the unit storage bits contained in the plurality of target memory spaces are sorted in descending order to obtain a second numbering order;
[0022] The numbers in the same sorting position of the first numbering sorting and the second numbering sorting are combined to obtain various numbering combinations.
[0023] Optionally, the method further comprises:
[0024] For each data included in the data to be stored, determining an original logical address corresponding to the data, the original logical address corresponding to the data being used to correspond to the physical address of the unit storage bit corresponding to the data when the data to be stored is stored in sequence in a manner of filling up a memory space and then being stored in the next memory space;
[0025] Determine the actual logical address corresponding to the data when the data is stored according to the number in the number combination corresponding to the data, as the actual logical address corresponding to the data;
[0026] A mapping relationship between the actual logical address corresponding to the data and the original logical address corresponding to the data is established and saved.
[0027] Optionally, the method further comprises:
[0028] Receive data query requests;
[0029] According to the data query request, determine data that needs to be read from the storage device as target data;
[0030] Based on a pre-established mapping relationship between an actual logical address corresponding to each data and an original logical address corresponding to each data, determining an actual logical address corresponding to the target data according to the original logical address corresponding to the target data;
[0031] The target data is queried according to the actual logical address corresponding to the target data.
[0032] This specification provides a data storage device, including:
[0033] A first determining module, used to determine data to be stored, and according to the data to be stored, determine a number of target memory spaces for storing the data to be stored from a preset storage device;
[0034] A second determination module is used to determine the number of storage bits of each unit contained in the plurality of target memory spaces;
[0035] A numbering module, used for numbering each unit storage bit included in the plurality of target memory spaces according to the quantity, to obtain a number corresponding to each unit storage bit included in the plurality of target memory spaces;
[0036] A combination module, used for combining numbers corresponding to the unit storage bits contained in the plurality of target memory spaces according to the amount of data contained in the data to be stored, to obtain various number combinations, wherein the numbers contained in at least some of the number combinations correspond to the unit storage bits in different target memory spaces, and all number combinations contain numbers corresponding to all the unit storage bits contained in the plurality of target memory spaces;
[0037] The third determination module is used to determine, for each data included in the data to be stored, a number combination corresponding to the data and a number corresponding to the data in the number combination as a target number corresponding to the data, so as to store the data according to a unit storage bit corresponding to the target number.
[0038] Optionally, the first determining module is specifically configured to:
[0039] Determine each preset memory space included in the storage device; select a number of target memory spaces from the preset memory spaces according to the amount of data included in the data to be stored, the number of memory spaces of the number of target memory spaces being greater than the number of memory spaces used when storing the data to be stored in a manner of filling one memory space and then storing it in the next memory space.
[0040] Optionally, the combination module is specifically used to:
[0041] Determine the maximum number N corresponding to each unit storage bit contained in the several target memory spaces, where N is a positive integer; and take the sum of the numbers in the obtained numbering combinations as a constraint condition that the sum of the numbers is an integer multiple of N+1, combine the numbers corresponding to the unit storage bits contained in the several target memory spaces to obtain each numbering combination.
[0042] Optionally, the combination module is specifically used to:
[0043] The numbers corresponding to the unit storage bits contained in the several target memory spaces are sorted in order from small to large to obtain a first numbering sorting, and the numbers corresponding to the unit storage bits contained in the several target memory spaces are sorted in order from large to small to obtain a second numbering sorting; the numbers in the same sorting position of the first numbering sorting and the second numbering sorting are combined to obtain various numbering combinations.
[0044] Optionally, the device further comprises:
[0045] The fourth determination module is used to determine, for each data contained in the data to be stored, the original logical address corresponding to the data, the original logical address corresponding to the data is used to correspond to the physical address of the unit storage bit corresponding to the data when the data to be stored is stored in sequence in a manner of filling up a memory space and then storing it in the next memory space; determine the actual logical address corresponding to the data when the data is stored according to the number in the number combination corresponding to the data, as the actual logical address corresponding to the data; establish and save the mapping relationship between the actual logical address corresponding to the data and the original logical address corresponding to the data.
[0046] Optionally, the device further comprises:
[0047] A query module is used to receive a data query request; determine the data that needs to be read from the storage device as the target data based on the data query request; determine the actual logical address corresponding to the target data based on the original logical address corresponding to the target data based on the pre-established mapping relationship between the actual logical address corresponding to each data and the original logical address corresponding to each data; and query the target data based on the actual logical address corresponding to the target data.
[0048] 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.
[0049] This specification provides an electronic device, including a processor and a computer program stored in a memory and executable on the processor, wherein the processor implements the above-mentioned data storage method when executing the program.
[0050] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:
[0051] In the data storage method provided in the present specification, after determining the data to be stored and determining a number of target memory spaces for storing the devices to be stored from a preset storage device according to the data to be stored, the number of each unit storage bit contained in the several target memory spaces is determined, and then each unit storage bit is numbered according to the determined number to obtain the number corresponding to each unit storage bit, so that according to the amount of data to be stored, the numbers corresponding to each unit storage bit are combined to obtain each number combination, so as to determine, for each data in the data to be stored, the number combination corresponding to the data and the number corresponding to the data in the number combination as the target number, and store the data according to the unit storage bit corresponding to the target number.
[0052] It can be seen from the above method that by numbering the unit storage bits contained in several target memory spaces, combining the numbers, and storing them according to the determined number combinations, the problem of uneven storage caused by sequential storage is avoided, and the data is stored more evenly in each target memory space, thereby improving the storage and reading efficiency of the data. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] 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:
[0054] Figure 1 A flowchart of a data storage method provided in this specification;
[0055] Figure 2 A schematic diagram of the connection between various number combinations and unit storage bits provided in this specification;
[0056] Figure 3 A schematic diagram of the structure of a data storage device provided in this specification;
[0057] Figure 4 A method provided in this specification corresponding to Figure 1 Schematic diagram of the structure of an electronic device. DETAILED DESCRIPTION
[0058] 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.
[0059] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.
[0060] Figure 1 A flowchart of a data storage method provided in this specification includes:
[0061] S101: Determine data to be stored, and according to the data to be stored, determine a number of target memory spaces for storing the data to be stored from a preset storage device.
[0062] The execution subject of a data storage method provided in this specification can be a terminal device such as a laptop computer, a desktop computer, or a client installed in the terminal device, or a server or a database device. For the sake of ease of description, the following only takes the execution subject as an example to illustrate a data storage method provided in this specification.
[0063] At present, before computers operate on data, they often need to read the data pre-stored in the memory. In order to improve the efficiency of data reading, computers can use multiple memory controllers to extract data from the memory at the same time. For example, if the memory contains 1024 unit storage bits, 4 memory controllers can be set to control the four memory spaces 1~256, 257~512, 513~768, and 769~1024 respectively. In this way, when the data to be read just fills the memory, the computer only needs to control each memory controller to read 256 times to read the data to be read in a size of 256*4.
[0064] However, when data is stored in the memory, it usually does not fill up the space, and the default storage method of the memory is sequential storage, that is, storage from 1 to 1024. For ease of understanding, the following takes each memory controller controlling a memory space as an example to explain sequential storage. When data is stored in the memory sequentially, it is necessary to fill the first memory space first, and then fill the second memory space, and so on, until the storage is completed. This storage method brings a problem. Continuing with the above example, when the amount of data is less than 768 unit storage bits, the fourth memory controller cannot take effect when reading. By analogy, the smaller the amount of data stored sequentially, the fewer memory controllers are used when reading data, and the existence of idle memory controllers when reading data will slow down the efficiency of data reading.
[0065] Based on the impact of sequential storage on data reading efficiency, this specification provides a method for storing data more evenly in the memory space controlled by each memory controller, which improves the efficiency of storing the data to be stored and reading the data after storage compared to sequential storage.
[0066] Specifically, after determining the preset storage device, that is, the memory, the server needs to determine each preset memory space contained in the memory. Then, according to the number of data contained in the data to be stored, select a number of target memory spaces from each preset memory space. When determining the number of target memory spaces corresponding to the data to be stored, if you want to improve the reading efficiency as much as possible, you can directly set the number of target memory spaces to the number of total memory spaces. Of course, if too many target memory spaces are selected, it may result in too little data stored in each target space, resulting in a problem of computer performance waste. Therefore, a minimum data amount can be set in advance, and then according to the number of data contained in the data to be stored, determine how many target memory spaces are required at least, so that after the data to be stored is stored in the memory, the data contained in each target memory space does not exceed the preset minimum data amount, and then the determined minimum number is used as the number of target memory spaces. The minimum data amount can be preset according to the size of the memory space. For example, if each memory space is 256, the minimum data amount can be preset to 128. Of course, there are other methods for determining the number of required target memory spaces, which are not specifically limited in this specification.
[0067] Next, we will continue with the above example, assuming that the memory contains 4 memory spaces, the data to be stored is the size of 512 units, and the target memory space is also 4, and then explain how to evenly store the 512 units of data to be stored into the 4 target memory spaces.
[0068] S102: Determine the number of storage bits of each unit contained in the plurality of target memory spaces.
[0069] S103: numbering each unit storage bit included in the target memory spaces according to the quantity, and obtaining a number corresponding to each unit storage bit included in the target memory spaces.
[0070] After the server determines the data of the target memory space, it can number the unit storage bits contained in the target memory spaces according to the number of each unit storage bit contained in the target memory spaces, and obtain the number corresponding to each unit storage bit in the memory spaces. Among them, the numbering can be performed according to the storage order of each unit storage bit during default storage. Of course, this manual does not make specific restrictions on the numbering method. For four target memory spaces containing 1024 unit storage bits, the number of each unit storage bit is 1~1024.
[0071] In the data storage method provided in this specification, by processing the numbers corresponding to the storage bits of each unit, data can be stored using the processed numbers, thereby changing the original sequential storage method so that the data is no longer stored in the memory according to the original sequential storage method.
[0072] S104: According to the amount of data included in the data to be stored, the numbers corresponding to the unit storage bits included in the plurality of target memory spaces are combined to obtain number combinations.
[0073] After the server determines the number corresponding to each unit storage bit in the target memory space, it can combine the numbers corresponding to the determined unit storage bits to obtain various number combinations. It should be noted that the combination involves all numbers, and all numbers in all number combinations obtained are all numbers before the combination, and the total number of numbers is the same.
[0074] Continuing with the above example, after combining the numbers corresponding to all the unit storage bits of the target memory space, 4 number combinations will be obtained, and for each number combination, the numbers contained in the number combination can come from unit storage bits in different target memory spaces. For example, a number combination can include numbers corresponding to some unit storage bits in 1 to 256, and can also include numbers corresponding to some unit storage bits in 257 to 512, 513 to 768, or even 769 to 1024.
[0075] After obtaining each number combination, data can be stored according to the obtained number combination. For example, if the data contained in a to-be-stored data originally needs to be stored in the unit storage bit corresponding to the number 129 in the memory, it is necessary to determine the number of the number combination in which the number 129 is located. If the number 129 is in the first position of the second number combination, the data is stored in the first unit storage bit controlled by the second memory controller, that is, the 257th position.
[0076] In order to store the data to be stored in the memory more evenly, this specification provides a number combination method. The server can use the number of unit storage bits controlled by each memory controller as the number of numbers in each number combination. Then, for each number combination, the sum of the numbers of the numbers in each number is a positive integer multiple of the sum of N+1 as a constraint condition, and the numbers corresponding to the unit storage bits contained in several target memory spaces are combined to obtain each number combination. Among them, N is the total number of unit storage bits in each target memory space, that is, the maximum number corresponding to the unit storage bits contained in several target memory spaces. In each number combination obtained by this method, there are several number pairs, and each number pair contains a number corresponding to a unit storage bit at the front of the storage order, and a number corresponding to a unit storage bit at the back of the storage order.
[0077] Of course, this specification also provides a number combination method. Continuing with the above example, the 1024 numbers corresponding to the unit storage bits contained in the target memory spaces can be sorted in order from small to large to obtain a first number sorting, and the numbers corresponding to the unit storage bits contained in the target memory spaces can be sorted in order from large to small to obtain a second number sorting. Further, the server combines the numbers of the same sorting position in the first number sorting and the second number sorting to obtain each number combination. Specifically, the Mth number in the first number sorting and the Mth number in the second number sorting can be used as a number pair, and then, if four number combinations are required, the 128 number pairs corresponding to the first 128 numbers in the first number sorting can be used as the first number combination, the 128 number pairs corresponding to the 129th to 256th numbers in the number sorting can be used as the second number combination, the 128 number pairs corresponding to the 257th to 384th numbers in the first number sorting can be used as the third number combination, and the 128 number pairs corresponding to the 384th to 512th numbers in the first number sorting can be used as the first number combination. Thereby, the total number of numbers in the four numbering combinations obtained is 1024. M is a positive integer. It should be noted that sometimes there may be an odd number of numbered data in the numbering combination. In this case, all numbers except the last position in this numbering combination can be determined according to the method for determining the numbering combination of even numbers, and then the last numbering can be determined. Specifically, if the last number is the 257th in the numbering combination, any one of the numbering pairs corresponding to the 129th numbering in the first numbering combination can be used as the last in the numbering combination according to the method provided in this specification. In this process, it is necessary to avoid containing the same number in different numbering combinations. Of course, each numbering combination can also be determined by other methods, and this specification does not make specific restrictions.
[0078] After determining each number combination, all the data in the data to be stored can be evenly stored in the target memory space controlled by each memory controller based on each number combination.
[0079] S105: For each data included in the data to be stored, determine the number combination corresponding to the data and the number corresponding to the data in the number combination as the target number corresponding to the data, so as to store the data according to the unit storage bit corresponding to the target number.
[0080] After the server determines the data to be stored, each data contained in the data to be stored corresponds to a unit storage bit, and the unit storage bit is the unit storage bit where the data is stored if the data to be stored is stored sequentially. The server can first determine the number of the unit storage bit corresponding to the data, and then determine the number combination in which the number of the unit storage bit corresponding to the data is, and the position of the number of the unit storage bit corresponding to the data in the number combination as the number corresponding to the data, that is, the target number corresponding to the data. Then the data is stored according to the unit storage bit corresponding to the target number corresponding to the data.
[0081] Continuing with the above example, if the unit storage bit number of a data is 768, and the number 768 is at the 128th bit of the second number combination, the data will be stored in the 128th unit storage bit of the target memory space controlled by the second memory controller. If stored in a sequential manner, the data will be stored in the 256th bit of the target memory space controlled by the third memory controller.
[0082] After the server stores 768 units of data to be stored in four target memory spaces according to the method provided in this manual, the amount of data stored in each target memory space is approximately 192 units. If stored sequentially, the first three target memory spaces will be full, and there will be no data stored in the fourth target memory space. This manual only needs to control the four memory controllers to store 192 times to complete the storage, which can be regarded as 192 time nodes. If stored sequentially, the three memory controllers need to be controlled to store 256 times to complete the storage, which requires 256 time nodes. In this example, the storage method provided in this manual reduces the required time nodes by one third compared to sequential storage.
[0083] For ease of understanding, the following will illustrate how to evenly store the data to be stored into each target memory area based on each number combination with an image.
[0084] Figure 2 A schematic diagram of the connection between various number combinations and unit storage bits provided in this specification.
[0085] There are four number combinations, memory controllers corresponding to each number combination, target memory areas controlled by each memory device, and unit storage bits in each target memory area that are the same as the number in each number combination. For the convenience of explanation, this example only involves sixteen unit storage bits from unit storage bit 1 to unit storage bit 16 from left to right, four memory controllers, and the data to be stored is 12 units in size. If sequential storage is selected, the target memory area 1, target memory area 2, and target memory area 3 will be full, and only three memory controllers will work during the storage of the data to be stored, and only three memory controllers will work when reading this data later.
[0086] However, if the data is stored according to the number combination, for example, the data originally needed to be stored in unit storage bit 2, the number corresponding to unit storage bit 2 is the second in the first number combination, then the data originally needed to be stored in unit storage bit 2 will be stored in the third unit storage bit of target memory area 1, that is, unit storage bit 3. By analogy, the data to be stored of 12 units will be stored in unit storage bit 1, unit storage bit 3, unit storage bit 5, unit storage bit 7, unit storage bit 9, unit storage bit 11, unit storage bit 13, unit storage bit 15, unit storage bit 16, unit storage bit 14, unit storage bit 12, and unit storage bit 10. 2, 2, 3, and 3 are stored in each target memory area, respectively, to achieve uniform storage.
[0087] In addition, it should be noted that when storing data, the server needs to determine the logical address corresponding to each data in the data to be stored, and this logical address can be converted into a physical address, and each physical address corresponds to a unit storage bit. If stored sequentially, the data will be stored in the unit storage bit corresponding to the physical address.
[0088] When storing data using the storage method provided in this specification, the unit storage bit where a piece of data is stored is not the same as the unit storage bit corresponding to the physical address corresponding to the data. Based on this, the logical address corresponding to the data can be used as the original logical address of the data, and then the logical address corresponding to the unit storage bit where the data is actually stored can be used as the actual logical address corresponding to the data. Thus, for each piece of data, a mapping relationship between the original logical address of the data and the actual logical address of the data is established and saved.
[0089] After establishing the mapping relationship corresponding to each data, the server can read the data according to the logical address contained in the request after receiving subsequent requests such as data query and data reading. Taking the data query request as an example, the server determines the data to be read as the target data according to the data query request, and then determines the original logical address corresponding to the target data, and then determines the actual logical address corresponding to the target data according to the mapping relationship obtained in advance, and then queries the target data according to the actual logical address corresponding to the target data. In this process, the unit storage bit corresponding to the actual logical address corresponding to the data is read by the memory controller. Therefore, if 192 time nodes are required to store the data, then only 192 time nodes are required to read the data, and the time nodes required for sequential reading are also the same as the time nodes required for sequential storage. It can be seen that the data storage method provided in this specification not only improves the data storage efficiency, but also improves the data reading efficiency.
[0090] The server determines the number combination corresponding to each memory controller, and then stores data according to each number combination, so that the data is evenly stored in the target memory space controlled by each memory controller, reducing the time required to store data and improving data storage efficiency. After establishing the mapping relationship between the original logical address of the data and the actual logical address, the data can be quickly read through this mapping relationship, improving the efficiency of data storage and reading.
[0091] The above one or more data storage methods of this specification are based on the same idea. This specification also provides corresponding devices, storage media and electronic devices.
[0092] Figure 3 This is a schematic diagram of a data storage device provided in an embodiment of the present specification, the device comprising:
[0093] A first determining module 301 is used to determine data to be stored, and according to the data to be stored, determine a number of target memory spaces for storing the data to be stored from a preset storage device;
[0094] A second determination module 302 is used to determine the number of storage bits of each unit contained in the plurality of target memory spaces;
[0095] A numbering module 303 is used to number each unit storage bit included in the plurality of target memory spaces according to the quantity, and obtain a number corresponding to each unit storage bit included in the plurality of target memory spaces;
[0096] A combining module 304 is used to combine the numbers corresponding to the unit storage bits contained in the plurality of target memory spaces according to the amount of data contained in the data to be stored, to obtain various number combinations, wherein the numbers contained in at least some of the number combinations correspond to the unit storage bits in different target memory spaces, and all the number combinations contain the numbers corresponding to all the unit storage bits contained in the plurality of target memory spaces;
[0097] The third determination module 305 is used to determine, for each data included in the data to be stored, the number combination corresponding to the data and the number corresponding to the data in the number combination as the target number corresponding to the data, so as to store the data according to the unit storage bit corresponding to the target number.
[0098] Optionally, the first determining module 301 is specifically configured to:
[0099] Determine each preset memory space included in the storage device; select a number of target memory spaces from the preset memory spaces according to the amount of data included in the data to be stored, the number of memory spaces of the number of target memory spaces being greater than the number of memory spaces used when storing the data to be stored in a manner of filling one memory space and then storing it in the next memory space.
[0100] Optionally, the combining module 304 is specifically used for:
[0101] Determine the maximum number N corresponding to each unit storage bit contained in the several target memory spaces, where N is a positive integer; and take the sum of the numbers in the obtained numbering combinations as a constraint condition that the sum of the numbers is an integer multiple of N+1, combine the numbers corresponding to the unit storage bits contained in the several target memory spaces to obtain each numbering combination.
[0102] Optionally, the combining module 304 is specifically used for:
[0103] The numbers corresponding to the unit storage bits contained in the several target memory spaces are sorted in order from small to large to obtain a first numbering sorting, and the numbers corresponding to the unit storage bits contained in the several target memory spaces are sorted in order from large to small to obtain a second numbering sorting; the numbers in the same sorting position of the first numbering sorting and the second numbering sorting are combined to obtain various numbering combinations.
[0104] Optionally, the device further comprises:
[0105] The fourth determination module 306 is used to determine, for each data contained in the data to be stored, the original logical address corresponding to the data, the original logical address corresponding to the data is used to correspond to the physical address of the unit storage bit corresponding to the data when the data to be stored is stored in sequence in a manner of filling up a memory space and then storing it in the next memory space; determine the actual logical address corresponding to the data when the data is stored according to the number in the number combination corresponding to the data, as the actual logical address corresponding to the data; establish and save the mapping relationship between the actual logical address corresponding to the data and the original logical address corresponding to the data.
[0106] Optionally, the device further comprises:
[0107] The query module 307 is used to receive a data query request; determine the data that needs to be read from the storage device as the target data based on the data query request; determine the actual logical address corresponding to the target data based on the original logical address corresponding to the target data based on the pre-established mapping relationship between the actual logical address corresponding to each data and the original logical address corresponding to each data; and query the target data based on the actual logical address corresponding to the target data.
[0108] This specification also provides a computer-readable storage medium, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, it can be used to perform the above Figure 1 Provides data storage methods.
[0109] based on Figure 1 A data storage method shown in the embodiment of the present specification also provides Figure 4 The structural diagram of the electronic device shown in FIG. Figure 4 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 A data storage method.
[0110] Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the executor of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0111] In the 1990s, it was very clear whether the improvement of a technology was hardware improvement (for example, improvement of the circuit structure of diodes, transistors, switches, etc.) or 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 hardware entity modules. 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 it 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.
[0112] 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.
[0113] 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.
[0114] 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.
[0115] 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.
[0116] 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.
[0117] 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.
[0118] 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.
[0119] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0120] 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.
[0121] 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 magnetic 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.
[0122] 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.
[0123] 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.
[0124] 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.
[0125] 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.
[0126] 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: Determining data to be stored, and according to the data to be stored, determining a number of target memory spaces for storing the data to be stored from a preset storage device; Determine the number of storage bits of each unit contained in the plurality of target memory spaces; According to the quantity, numbering each unit storage bit included in the plurality of target memory spaces to obtain a number corresponding to each unit storage bit included in the plurality of target memory spaces; According to the amount of data included in the data to be stored, the numbers corresponding to the unit storage bits included in the several target memory spaces are combined to obtain various number combinations, wherein the maximum number N corresponding to the unit storage bits included in the several target memory spaces is determined, where N is a positive integer, and the numbers corresponding to the unit storage bits included in the several target memory spaces are sorted in ascending order to obtain a first number sorting, and the numbers corresponding to the unit storage bits included in the several target memory spaces are sorted in descending order to obtain a second number sorting; the numbers at the same sorting position in the first number sorting and the second number sorting are combined to obtain various number combinations, wherein at least some of the number combinations contain numbers corresponding to unit storage bits in different target memory spaces, and all number combinations contain numbers corresponding to all unit storage bits included in the several target memory spaces; For each data included in the data to be stored, determine the number combination corresponding to the data and the number corresponding to the data in the number combination as the target number corresponding to the data, so as to store the data according to the unit storage bit corresponding to the target number.
2. The method according to claim 1, characterized in that According to the data to be stored, determining a plurality of target memory spaces for storing the data to be stored from a preset storage device specifically includes: Determining each preset memory space contained in the storage device; According to the amount of data contained in the data to be stored, a number of target memory spaces are selected from the preset memory spaces, and the number of memory spaces of the target memory spaces is greater than the number of memory spaces used when the data to be stored is stored in a manner of filling one memory space and then storing it in the next memory space.
3. The method according to claim 1, characterized in that The method further comprises: For each data included in the data to be stored, determining an original logical address corresponding to the data, the original logical address corresponding to the data being used to correspond to the physical address of the unit storage bit corresponding to the data when the data to be stored is stored in sequence in a manner of filling up a memory space and then being stored in the next memory space; Determine the actual logical address corresponding to the data when the data is stored according to the number in the number combination corresponding to the data, as the actual logical address corresponding to the data; A mapping relationship between the actual logical address corresponding to the data and the original logical address corresponding to the data is established and saved.
4. The method according to claim 3, characterized in that The method further comprises: Receive data query requests; According to the data query request, determine data that needs to be read from the storage device as target data; Based on a pre-established mapping relationship between an actual logical address corresponding to each data and an original logical address corresponding to each data, determining an actual logical address corresponding to the target data according to the original logical address corresponding to the target data; The target data is queried according to the actual logical address corresponding to the target data.
5. A data storage device, characterized in that: include: A first determining module, used to determine data to be stored, and according to the data to be stored, determine a number of target memory spaces for storing the data to be stored from a preset storage device; A second determination module is used to determine the number of storage bits of each unit contained in the plurality of target memory spaces; A numbering module, used for numbering each unit storage bit included in the plurality of target memory spaces according to the quantity, to obtain a number corresponding to each unit storage bit included in the plurality of target memory spaces; A combination module, used for combining the numbers corresponding to the unit storage bits contained in the several target memory spaces according to the amount of data contained in the data to be stored, to obtain various number combinations, wherein the maximum number N corresponding to the unit storage bits contained in the several target memory spaces is determined, N is a positive integer, the numbers corresponding to the unit storage bits contained in the several target memory spaces are sorted in ascending order, to obtain a first number sorting, and the numbers corresponding to the unit storage bits contained in the several target memory spaces are sorted in descending order, to obtain a second number sorting; the numbers at the same sorting position in the first number sorting and the second number sorting are combined to obtain various number combinations, wherein at least some of the number combinations contain numbers corresponding to unit storage bits in different target memory spaces, and all number combinations contain numbers corresponding to all unit storage bits contained in the several target memory spaces; The third determination module is used to determine, for each data included in the data to be stored, a number combination corresponding to the data and a number corresponding to the data in the number combination as a target number corresponding to the data, so as to store the data according to a unit storage bit corresponding to the target number.
6. The device according to claim 5, characterized in that The first determination module is specifically configured to: Determine each preset memory space included in the storage device; select a number of target memory spaces from the preset memory spaces according to the amount of data included in the data to be stored, the number of memory spaces of the number of target memory spaces being greater than the number of memory spaces used when storing the data to be stored in a manner of filling one memory space and then storing it in the next memory space.
7. 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 4 is implemented.
8. An electronic device comprising a processor and a computer program stored in a 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 4 is implemented.
