Memory data access device, memory data storage and reading method
By including two consecutive data storage areas and an address storage area in each storage unit in the memory, the problem of slow data copying and reading speed during capacity expansion in the existing technology is solved, and efficient memory data storage and reading are achieved. .
Patent Information
- Application Number
- CN202011353512.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-27
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2040-11-27
AI Technical Summary
Existing memory storage methods need to copy data when expanding, resulting in high system overhead, and linked list storage methods need to traverse the linked list when reading data, resulting in a problem of reduced reading speed.
Using storage units, each storage unit includes two consecutive data storage areas and an address storage area. The address storage area records the first address of the next storage unit, achieving continuous data storage and fast reading, and avoiding data copying and linked list traversal.
Improves data storage and reading speed, reduces system overhead, and saves memory space.
Smart Images

Figure CN113821160B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a memory data access device, and a memory data storage and reading method. Background Art
[0002] Currently, memory storage is mainly divided into two types: continuous memory address storage and discontinuous chain storage. The corresponding technologies are array storage and linked list storage.
[0003] Among them, Figure 1 As shown in the figure, the array storage method is to apply for a continuous memory address in the memory and store the data in the memory. When there is insufficient space, another continuous memory address will be re-applied, which is 1.5 times the original size and the original data will be copied in. For example, Figure 1 In the figure, the original space has 4 groups of data, namely data 1, data 2, data 3 and data 4. When the new data 5 is inserted, the original space is insufficient, so another larger continuous memory space address is newly applied in the memory. The size of the newly applied memory space is, for example, 1.5 times the size of the original space. Then, all the data in the original space is copied to the newly applied memory space, and then data 5 is inserted into the memory space address after data 4.
[0004] It is not difficult to see from the above array storage method that when there is not enough continuous memory space in the memory, the expansion will fail. In addition, the data in the original array needs to be copied to the new array during expansion, resulting in high system overhead. When the original space is large, the storage speed will be reduced due to the copy of the original array. At the same time, this array storage method cannot be used for discontinuous memory space, and frequent use of this array storage method will also cause fragmentation of the memory space.
[0005] like Figure 2 As shown in the figure, the linked list storage method means that the data is physically discontinuous in the memory, and the logical continuity of the data is achieved by recording the position of the next data element (memory space address) in each data element. When inserting a new data element, you only need to apply for a new memory space address in the memory for storing the new data, and record the first address of the memory space of the new data in the data element at the end of the linked list to insert the new data element.
[0006] It can be seen from the above linked list storage method that: in each data element, the storage location of the next data element needs to be recorded, and recording the storage location will occupy memory space. The memory space occupied by the recording storage location is generally equal to the space size of the recording data element. This results in the actual memory space occupied by each data element being twice the memory space required by the data element itself. At the same time, the linked list storage method does not support random reading. When it is necessary to read the nth data element, it is necessary to traverse the previous n-1 elements first, resulting in a higher system overhead. And when the linked list is long, it will also bring about the problem of reduced reading speed.
[0007] Based on the above description, how to improve the memory data access speed and reduce system overhead has become an urgent problem to be solved. Summary of the invention
[0008] In view of this, the present invention provides a memory data access device, a memory data storage and reading method, so as to ensure the access speed of memory data while reducing the system overhead caused by memory data access, so that the data storage speed is higher than the array storage method, and the data reading speed is higher than the linked list storage method, thereby reducing the system overhead while the overall memory access speed is higher than the group storage method and the linked list storage method.
[0009] The technical solution of the present invention is achieved in this way:
[0010] A memory data access device, comprising:
[0011] A storage unit, the number of which is at least one, wherein each of the storage units includes at least two data storage areas that are continuously occupied in the storage space of the memory;
[0012] address storage areas, the number of which is equal to the number of the storage units, and each of the address storage areas is located at the rear end of each of the data storage areas and corresponds to each of the data storage areas, and when the number of the storage units is at least two, between two adjacent storage units in the data storage sequence, the address storage area corresponding to the previous storage unit stores the first address of the next storage unit in the memory, and at least two of the storage units form a storage unit chain through the information stored in the address storage area;
[0013] A data memory, the data memory being used to continuously store the data in each storage area of the storage unit, and, after all the data storage areas of the current storage unit are full, to establish a new storage unit in the memory and record the first address of the new storage unit in the memory in the address storage area corresponding to the current storage unit, and to continue to continuously store the data in each storage area of the new storage unit;
[0014] A data reader, the data reader is used to obtain the data storage area where the data element to be read is located in at least one of the storage units according to the specified position of the data element to be read in the data, the number of data storage areas of each of the storage units, and the information stored in each of the address storage areas, and read the data element from the data storage area where the data element is located.
[0015] Further, the space occupied by each of the address storage areas in the memory is equal to the space occupied by each of the data storage areas in the memory;
[0016] Each of the address storage areas is respectively connected to an end of the storage space occupied by each of the storage units;
[0017] When the number of the storage units is at least two, the lengths of all the storage units are equal and the sizes of the data storage areas of all the storage units and the address storage areas are equal.
[0018] Furthermore, the number of the data storage areas in each of the storage units is 2 to 100.
[0019] A memory data storage method, using the memory data access device as described in any one of the above items, comprising:
[0020] Receive data;
[0021] Establishing a storage unit in the memory, and continuously storing the data in each storage area of the storage unit;
[0022] When all data storage areas of the current storage unit are full and the data has not been completely stored, a new storage unit is established in the memory and the first address of the new storage unit in the memory is recorded in the address storage area corresponding to the current storage unit;
[0023] The parts of the data that have not been stored continue to be stored continuously in each storage area of the new storage unit.
[0024] A method for reading memory data, using the memory data access device as described in any one of the above items, comprising:
[0025] receiving a read instruction including a designated position of a data element to be read in the data;
[0026] Obtaining a first address of a first storage unit in the memory for storing the data;
[0027] According to the first address of the first storage unit, obtaining the location of the first data storage area of the first storage unit in the memory;
[0028] In the storage unit chain for storing the data, according to the designated position, the number of data storage areas in each of the storage units, and the information recorded in the address storage area, the first address of the target storage unit where the data element is located in the memory is obtained;
[0029] In the target storage unit, according to the specified position, the number of storage units from the first storage unit to the target storage unit, and the number of the data storage areas in each of the storage units, a target data storage area of the data element in the target storage unit is obtained;
[0030] Data is read from the target data storage area to obtain the data element.
[0031] A non-volatile computer-readable storage medium stores instructions, wherein the instructions, when executed by a processor, cause the processor to execute the steps in the memory data storage method described above.
[0032] An electronic device, comprising:
[0033] at least one processor; and,
[0034] a memory communicatively connected to the at least one processor; wherein,
[0035] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the steps in the memory data storage method as described above.
[0036] A non-volatile computer-readable storage medium stores instructions, wherein the instructions, when executed by a processor, cause the processor to execute the steps in the memory data reading method as described above.
[0037] An electronic device, comprising:
[0038] at least one processor; and,
[0039] a memory communicatively connected to the at least one processor; wherein,
[0040] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the steps in the memory data reading method as described above.
[0041] It can be seen from the above scheme that the memory data access device, memory data storage and reading method of the present invention, compared with the array storage method, does not need to copy the data in the existing storage unit after applying for a new continuous memory address as a new storage unit, thereby improving the data storage speed and reducing the system overhead; compared with the linked list storage method, each storage unit includes at least two data storage areas that are continuously occupied in the storage space of the memory, so that the number of data storage areas in each storage unit is higher than the number of address storage areas corresponding to it, so that when reading the data elements in any of the data storage areas, the number of traversed storage units is reduced due to the increase in the number of data storage areas in each storage unit, and the number of times the address storage area is read and the first address of the subsequent storage unit of the storage unit chain is determined is significantly less than the number of times the storage position of the next data element is determined in the linked list storage method, thereby improving the data reading speed and reducing the system overhead, and overall, since each storage unit includes at least two data storage areas that are continuously occupied in the storage space of the memory, compared with the linked list storage method, in the present invention, the structure of the storage unit and the address storage area saves more memory space. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 It is a schematic diagram of an array storage method in an existing memory storage method;
[0043] Figure 2 It is a schematic diagram of a linked list storage method in an existing memory storage method;
[0044] Figure 3 A schematic diagram of a memory data access device according to an embodiment of the present invention;
[0045] Figure 4 A schematic diagram of a method for storing data in a memory according to an embodiment of the present invention;
[0046] Figure 5 A schematic diagram of a specific example flow chart of a method for storing data in a memory according to an embodiment of the present invention;
[0047] Figure 6 A schematic diagram of a method for reading memory data according to an embodiment of the present invention;
[0048] Figure 7A schematic diagram of a specific example flow chart of a method for reading memory data according to an embodiment of the present invention;
[0049] Figure 8 is a schematic diagram of a storage unit in Example 1 in an embodiment of the present invention;
[0050] Fig. 9 is a schematic diagram of a storage unit in Example 2 in an embodiment of the present invention;
[0051] Fig.10 Schematic diagram of the structure of an electronic device in an embodiment of the present invention.
[0052] In the accompanying drawings, the names of the components represented by the reference numerals are as follows:
[0053] 10. Storage Unit
[0054] 101. Data Storage Area
[0055] 20. Address storage area
[0056] 30. Data storage
[0057] 40. Data Reader
[0058] 50. Memory DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and embodiments.
[0060] like Figure 3 As shown, the memory data access device of the embodiment of the present invention mainly includes a storage unit 10, an address storage area 20, a data storage device 30 and a data reader 40. Among them, the number of storage units 10 is at least one, each storage unit 10 occupies a continuous storage space of the memory 50, and each storage unit includes at least two data storage areas 101 continuously occupied in the storage space of the memory 50. The number of address storage areas 20 is equal to the number of storage units 10, and each address storage area 20 is respectively located at the back end of each data storage area 10 and corresponds to each data storage area 10. When the number of storage units 10 is at least two, between two adjacent storage units 10 in the data storage order, the corresponding address storage area 20 connected to the end of the previous storage unit 10 stores the first address of the next storage unit 10 in the memory 50, and at least two storage units 10 form a storage unit chain through the information stored in the address storage area 20.
[0061] The data storage device 30 is used to continuously store data in each storage area 101 of the storage unit 10, and after all the data storage areas 101 of the current storage unit 10 are full, a new storage unit 10 is established in the memory 50 and the first address of the new storage unit 10 in the memory 50 is recorded in the corresponding address storage area 20 connected to the end of the current storage unit 10, and the data continues to be continuously stored in each storage area 101 of the new storage unit 10.
[0062] The data reader 40 is used to obtain the data storage area 101 where the data element to be read is located in at least one storage unit 10 according to the specified position of the data element to be read in the data, the number of data storage areas of each storage unit 10, and the information stored in each address storage area 20, and read the data element from the data storage area 101 where the data element is located.
[0063] Compared with the prior art, the memory data access device of the embodiment of the present invention, relative to the array storage method, does not need to copy the data in the existing storage unit 10 after applying for a new continuous memory address as a new storage unit 10, thereby improving the data storage speed and reducing the system overhead; relative to the linked list storage method, each storage unit 10 contains at least two data storage areas 101 continuously occupied in the storage space of the memory 50, so that the number of data storage areas 101 in each storage unit 10 is higher than the number of address storage areas 20 corresponding thereto, so that when reading the data elements in any of the data storage areas 101 Since the number of data storage areas 101 in each storage unit 10 increases, the number of storage units 10 traversed is reduced, and the number of times the address storage area 20 is read and the first address of the subsequent storage unit 10 in the storage unit chain is determined is significantly less than the number of times the storage position of the next data element is determined in the linked list storage method, thereby improving the data reading speed and reducing the system overhead. In general, since each storage unit 10 includes at least two data storage areas 101 continuously occupied in the storage space of the memory 50, compared with the linked list storage method, in the embodiment of the present invention, the structure of the storage unit 10 and the address storage area 20 saves more memory space.
[0064] In an optional embodiment, the space occupied by each address storage area 20 in the memory 50 is equal to the space occupied by each data storage area 101 in the memory 50, which is conducive to the unification of the data storage length in the address storage area 20 and the data storage area 101, and is convenient for determining the actual physical address of the data in the memory 50. Each address storage area 20 is respectively connected to the end of the storage space occupied by each storage unit 10, and then each address storage area 20 is continuously distributed on the physical address of the memory 50 with its corresponding storage unit 10, which is conducive to the improvement of the speed of obtaining information in the address storage area 20 during the traversal process of the storage unit 10 when reading data elements. Further, in a preferred embodiment, when the number of storage units 10 is at least two, the lengths of all storage units 10 are equal and the sizes of the data storage areas 101 of all storage units 10 and all address storage areas 20 are equal.
[0065] In an optional embodiment, the number of data storage areas 101 in each storage unit 10 is 2 to 100. Specifically, the number of data storage areas 101 can be optimized according to the actual memory 50 used and the system status.
[0066] In the embodiment of the present invention, a data element refers to a section of content in the stored data.
[0067] For example, the number of data storage areas 101 in each storage unit 10 is k.
[0068] When the data storage device 30 continuously stores data in each data storage area 101 of the storage unit 10, it first stores the data in sequence in the first storage unit 10 established in the memory 50, stores the first data element in the data in the first data storage area 101 of the first storage unit 10, and stores the second data element in the data in the second data storage area 101 of the first storage unit 10. When the kth data element in the data is stored in the kth data storage area 101 of the first storage unit 10 and the data has not been stored completely, a second storage unit 10 is established in the memory 50, and the first address of the second storage unit 10 is stored in the address storage area 20 corresponding to the first storage unit 10 (located after the kth data storage area 101 of the first storage unit 10). Then, the k+1th data element is stored in the first data storage area 101 of the second storage unit 10, and the k+2th data element is stored in the second data storage area 101 of the second storage unit 10, and so on, until all data are stored.
[0069] When reading a specified data element, for example, when the specified position of the data element to be read in the data is the nth data element, the data reader 40 obtains the data storage area 101 where the data element to be read (the nth data element) is located in at least one storage unit 10 according to the specified position of the data element to be read in the data (i.e., the nth data element), the number (k) of data storage areas of each storage unit 10, and the information stored in each address storage area 20, including:
[0070] The first address of the first storage unit 10 storing data in the memory 50 is obtained, and the first address is assigned to the variable a, where a is a pointer type.
[0071] Find the number of storage cells 10 storing data from the 1st data element to the nth data element:
[0072] t=u=[n / (k+1)]
[0073] Wherein, the square brackets indicate that the value therein is rounded down, where k+1 represents the total number of all data storage areas 101 plus the address storage area 20 in the storage unit 10 and the corresponding address storage area 20, and the actual physical space lengths of all data storage areas 101 and all address storage areas 20 are set to be equal for the convenience of address pointer control in the memory 50. Each time the pointer address is adjusted, it is only necessary to increase or decrease the integer multiple of the actual physical space lengths of the set data storage area 101 and the address storage area 20. Wherein, t is the number of storage units 10 storing data from the 1st data element to the nth data element, u is a variable used to determine whether the address pointer in the memory 50 reaches the storage unit 10 where the data element to be read (the nth data element) is located, and the initial value of u is the same as t. In the embodiment of the present invention, the number of storage units 10 starts from 0. When t=0, it means that there is only one storage unit 10, and when t=1, it means that there are two storage units 10, and so on.
[0074] After obtaining the value of u through t=u=[n / (k+1)], it is determined whether u is 0. If u is not 0, it means that the current address pointer has not reached the storage unit 10 where the data element to be read (the nth data element) is located, and the first address of the next storage unit 10 is read from the address storage area 20 corresponding to the current storage unit 10 after the current storage unit 10, wherein the address pointer jumps to the address storage area 20 corresponding to the current storage unit 10 through the following formula to read the corresponding information therein:
[0075] a=*(a+k)
[0076] At the same time, u is assigned a value of u-1, that is, u=u-1. It should be noted that a is an address pointer, and k needs to be converted according to the actual physical address length of each data storage area during calculation.
[0077] Then, continue to judge whether u is 0. If u is still not 0, continue to execute the above-mentioned a=*(a+k) and u=u-1 process.
[0078] If u is 0, it means that the current address pointer has reached the storage unit 10 where the data element to be read (the nth data element) is located. At this time, the data storage area 101 where the data element to be read (the nth data element) is located is obtained by the following formula:
[0079] R=a+(nt*k)-1
[0080] Wherein, R is the address of the data storage area where the data element to be read (the nth data element) is located. It should be noted that a is an address pointer, and the (nt*k) part needs to be converted according to the actual physical address length of each data storage area during calculation.
[0081] At this point, the data reader 40 has completed the determination of the data storage area 101 where the specified data element is located when reading the specified data element.
[0082] Based on the above-mentioned memory data access device, the embodiment of the present invention also provides a memory data storage method, such as Figure 4 As shown, including:
[0083] Receive data;
[0084] Establish a storage unit in the memory and store the data continuously in each storage area of the storage unit;
[0085] When all data storage areas of the current storage unit are full and the data has not been fully stored, a new storage unit is created in the memory and the first address of the new storage unit in the memory is recorded in the address storage area corresponding to the current storage unit;
[0086] The parts of the data that have not yet been stored continue to be stored continuously in each storage area of the new storage unit.
[0087] The following is a specific example to illustrate the memory data storage method of the embodiment of the present invention.
[0088] In this example, there are k data storage areas in each storage unit, and the length of the data to be stored is the length of N1 data storage areas, such as Figure 5 As shown, the specific embodiment includes the following steps:
[0089] Step a1, establish a storage unit in the memory, and record the first address of the storage unit, take the established storage unit as the current storage unit, and then execute step a2;
[0090] Step a2, storing the data in the current storage unit from the first data storage area to the kth data storage area in sequence, and then executing step a3;
[0091] Step a3, determine whether the data storage is complete, if yes, complete the data storage, otherwise, execute step a4;
[0092] Step a4, creating a new storage unit in the memory, and storing the first address of the new storage unit in the address storage area corresponding to the current storage unit, and then executing step a5;
[0093] Step a5, enter a new storage unit according to the information in the address storage area corresponding to the current storage unit, and use the new storage unit as the current storage unit, and then execute step a2.
[0094] The following example illustrates the process from step a1 to step a5.
[0095] Assume that there are 7 data storage areas in each storage unit and the length of the data to be stored is the length of 17 data storage areas. The process includes:
[0096] Establish a first storage unit in the memory, record the first address of the first storage unit, and use the first storage unit as the current storage unit;
[0097] The data is stored in the current storage unit (the first storage unit) from the first data storage area to the seventh data storage area in sequence;
[0098] Determine whether the data has been stored. Since the length of the data to be stored is the length of 17 data storage areas and the data storage areas in each storage unit are 7, the data has not been stored completely in the current storage unit (the first storage unit) (at this time, the data of the length of 7 data storage areas has been stored in the first storage unit). Then, a second storage unit is established in the memory, and the first address of the second storage unit is stored in the address storage area corresponding to the current storage unit (the first storage unit);
[0099] Enter the second storage unit according to the information in the address storage area corresponding to the current storage unit (the first storage unit), and use the second storage unit as the current storage unit;
[0100] The data is stored in the current storage unit (the second storage unit) from the first data storage area to the seventh data storage area in sequence;
[0101] Determine whether the data has been stored. Since the length of the data to be stored is 17 data storage areas and the data storage areas in each storage unit are 7, the data has not been stored completely in the current storage unit (the second storage unit) (at this time, the first storage unit and the second storage unit have stored data of 14 data storage areas), then a third storage unit is established in the memory, and the first address of the third storage unit is stored in the address storage area corresponding to the current storage unit (the second storage unit);
[0102] Enter the third storage unit according to the information in the address storage area corresponding to the current storage unit (the second storage unit), and use the third storage unit as the current storage unit;
[0103] Enter the third storage unit according to the information in the address storage area corresponding to the current storage unit (the third storage unit), and use the third storage unit as the current storage unit;
[0104] The data is stored in the current storage unit (the third storage unit) from the first data storage area to the seventh data storage area in sequence;
[0105] Determine whether the data has been stored. Since the length of the data to be stored is 17 data storage areas and there are 7 data storage areas in each storage unit, when the data is stored in the third data storage area in the current storage unit (the third storage unit), the data has been stored (at this time, data with a length of 14 data storage areas has been stored in the first storage unit and the second storage unit, and data with a length of 3 data storage areas has been stored in the current storage unit, totaling 17 data storage areas). At this point, data storage is completed.
[0106] Based on the above memory data access device, the embodiment of the present invention also provides a memory data reading method, such as Figure 6 As shown, including:
[0107] Receiving a read instruction including a specified position of a data element to be read in the data;
[0108] Get the first address of the first storage unit in the memory used to store data;
[0109] According to the first address of the first storage unit, the location of the first data storage area of the first storage unit in the memory is obtained;
[0110] In a chain of storage units for storing data, according to a specified position, the number of data storage areas in each storage unit, and information recorded in the address storage area, a first address of a target storage unit where a data element is located in a memory is obtained;
[0111] In the target storage unit, a target data storage area of the data element in the target storage unit is obtained according to the specified position, the number of storage units from the first storage unit to the target storage unit, and the number of data storage areas in each storage unit;
[0112] Read data from the target data storage area to obtain the data element to be read.
[0113] Among them, the acquisition of the first address of the first storage unit used to store data in the memory can be implemented by using existing technology. The first address is obtained when storing data. The method of obtaining the first address when storing data can be implemented by using existing technology and will not be repeated here.
[0114] The memory data reading method according to the embodiment of the present invention is described below with reference to a specific embodiment.
[0115] In this example, the number of data storage areas in each storage unit is k, and the data element to be read is the nth data element in the data, such as Figure 7 As shown, the specific embodiment includes the following steps:
[0116] Step b1, obtain the first address of the first storage unit storing data in the memory, and assign the first address to variable a, where a is a pointer type, and then proceed to step b2;
[0117] Step b2, calculate the number of storage units storing data from the first data element to the nth data element by using the formula t=u=[n / (k+1)], and then proceed to step b3;
[0118] Step b3, determine whether u is 0, if it is 0, go to step b5, otherwise go to step b4;
[0119] Step b4, assign a value to a by the formula a=*(a+k), and assign u by the formula u=u-1, and then go to step b3;
[0120] Step b5, obtain the address of the data storage area where the nth data element is located by the formula R=a+(nt*k)-1, and then proceed to step b6;
[0121] Step b6: Read the content in the data storage area where the nth data element is located.
[0122] The following example illustrates the process from step b1 to step b6.
[0123] Example 1
[0124] See also Figure 8As shown, there are 7 data storage areas in each storage unit, and the data element to be read is the 5th data element in the data, wherein the sequence numbers in each data storage area represent the addresses and order of each data storage area, and the process includes:
[0125] Get the first address a of the first storage unit storing data in the memory. Assume that a=1. In this example, it means that the first data storage area in the first storage unit storing data is 1.
[0126] The number of storage units storing data from the first data element to the fifth data element is obtained by the formula t=u=[n / (k+1)]=0;
[0127] If u is 0, we can get R=1+(5-0*7)-1=5 by the formula R=a+(nt*k)-1.
[0128] Read the contents of the data storage area at address 5 (located in the first storage unit) to obtain the fifth data element.
[0129] Example 2
[0130] See also Fig. 9 As shown, there are 7 data storage areas in each storage unit, and the data element to be read is the 10th data element in the data, wherein the sequence numbers in each data storage area represent the addresses and order of each data storage area, and the process includes:
[0131] Get the first address a of the first storage unit storing data in the memory. Assume that a=1. In this example, it means that the first data storage area in the first storage unit storing data is 1.
[0132] The number of storage units storing data from the first data element to the fifth data element is obtained by using the formula t=u=[n / (k+1)]=1;
[0133] Determine that u is 1, and use the formula a=*(a+k) to get a=*(1+7)=8. Use the formula u=u-1 to get u=1-1=0. Since a=8, the address pointer points to the first data storage area of the second storage unit ( Fig. 9 The bid number is 8);
[0134] If u is 0, we can get R=8+(10-1*7)-1=10 by the formula R=a+(nt*k)-1;
[0135] Read the contents of the data storage area at address 10 (located in the second storage unit) to obtain the 10th data element.
[0136] The embodiment of the present invention also provides a non-volatile computer-readable storage medium, which stores instructions. When the instructions are executed by a processor, the processor executes the various steps in the memory data storage method as described above.
[0137] The embodiment of the present invention also provides an electronic device for executing the memory data storage method. Fig.10 As shown, the electronic device includes: at least one processor 1 and a memory 2. The memory 2 is communicatively connected to the at least one processor 1, for example, the memory 2 and the at least one processor 1 are connected via a bus. The memory 2 stores instructions that can be executed by the at least one processor 1, and the instructions are executed by the at least one processor 1 so that the at least one processor 1 performs the various steps in the memory data storage method as described above.
[0138] The embodiment of the present invention also provides a non-volatile computer-readable storage medium, which stores instructions. When the instructions are executed by a processor, the processor executes the various steps in the memory data reading method as described above.
[0139] The embodiment of the present invention also provides an electronic device for executing the memory data reading method, such as Fig.10 As shown, the electronic device includes: at least one processor 1 and a memory 2. The memory 2 is communicatively connected to the at least one processor 1, for example, the memory 2 and the at least one processor 1 are connected via a bus. The memory 2 stores instructions that can be executed by the at least one processor 1, and the instructions are executed by the at least one processor 1 so that the at least one processor 1 executes the various steps in the memory data reading method as described above.
[0140] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A memory data access device, characterized in that: include: A storage unit, the number of which is at least one, wherein each of the storage units includes at least two data storage areas that are continuously occupied in the storage space of the memory; address storage areas, the number of which is equal to the number of the storage units, and each of the address storage areas is located at the rear end of each of the data storage areas and corresponds to each of the data storage areas, and when the number of the storage units is at least two, between two adjacent storage units in the data storage sequence, the address storage area corresponding to the previous storage unit stores the first address of the next storage unit in the memory, and at least two of the storage units form a storage unit chain through the information stored in the address storage area; A data memory, the data memory being used to continuously store the data in each storage area of the storage unit, and, after all the data storage areas of the current storage unit are full, to establish a new storage unit in the memory and record the first address of the new storage unit in the memory in the address storage area corresponding to the current storage unit, and to continue to continuously store the data in each storage area of the new storage unit; A data reader, the data reader is used to obtain the data storage area where the data element to be read is located in at least one of the storage units according to the specified position of the data element to be read in the data, the number of data storage areas of each of the storage units, and the information stored in each of the address storage areas, and read the data element from the data storage area where the data element is located, comprising: Get the first address of the first storage unit storing data, and assign the first address to variable a, where a is the address pointer; Find the number of storage cells that store data from the 1st data element to the nth data element in the data: t=u=[n / (k+1)] Wherein, the square brackets indicate that the value therein is rounded down, wherein k+1 represents the total number of all data storage areas in the storage unit and the address storage area corresponding to the storage unit plus the address storage area, t is the number of storage units storing data from the 1st data element to the nth data element, u is a variable used to determine whether the address pointer in the memory reaches the storage unit where the nth data element is located, and the initial assignment of u is the same as t, wherein the nth data element is the specified position of the data element to be read in the data; After obtaining the value of u through t=u=[n / (k+1)], it is determined whether u is 0. If u is not 0, the first address of the next storage unit (10) is read from the address storage area corresponding to the current storage unit after the current storage unit, wherein the address pointer jumps to the address storage area corresponding to the current storage unit to read the corresponding information therein through the following formula: a=*(a+k) At the same time, assign u to u-1; Then, continue to judge whether u is 0. If u is still not 0, continue to execute the process of a=*(a+k) and u=u-1; If u is 0, the data storage area where the nth data element is located is obtained by the following formula: R=a+(nt*k)-1 Wherein, R is the address of the data storage area where the nth data element is located.
2. The memory data access device according to claim 1, characterized in that: The space occupied by each of the address storage areas in the memory is equal to the space occupied by each of the data storage areas in the memory; Each of the address storage areas is respectively connected to an end of the storage space occupied by each of the storage units; When the number of the storage units is at least two, the lengths of all the storage units are equal and the sizes of the data storage areas of all the storage units and the address storage areas are equal.
3. The memory data access device according to claim 1, characterized in that: The number of the data storage areas in each of the storage units is 2 to 100.
4. A method for storing memory data, using the memory data access device according to any one of claims 1 to 3, comprising: Receive data; Establishing a storage unit in the memory, and continuously storing the data in each storage area of the storage unit; When all data storage areas of the current storage unit are full and the data has not been completely stored, a new storage unit is created in the memory and the first address of the new storage unit in the memory is recorded in the address storage area corresponding to the current storage unit; The parts of the data that have not been stored continue to be stored continuously in each storage area of the new storage unit.
5. A method for reading memory data, using the memory data access device according to any one of claims 1 to 3, comprising: receiving a read instruction including a designated position of a data element to be read in the data; Obtaining a first address of a first storage unit in the memory for storing the data; According to the first address of the first storage unit, obtaining the location of the first data storage area of the first storage unit in the memory; In the storage unit chain for storing the data, according to the designated position, the number of data storage areas in each of the storage units, and the information recorded in the address storage area, the first address of the target storage unit where the data element is located in the memory is obtained; In the target storage unit, according to the specified position, the number of storage units from the first storage unit to the target storage unit, and the number of the data storage areas in each of the storage units, a target data storage area of the data element in the target storage unit is obtained; Data is read from the target data storage area to obtain the data element.
6. A non-volatile computer-readable storage medium storing instructions, characterized in that: When the instructions are executed by a processor, the processor is caused to perform the steps in the memory data storage method according to claim 4.
7. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the steps in the memory data storage method according to claim 4.
8. A non-volatile computer-readable storage medium storing instructions, characterized in that: When the instruction is executed by a processor, the processor executes the steps in the memory data reading method as claimed in claim 5.
9. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the steps in the memory data reading method as claimed in claim 5.
Citation Information
Patent Citations
High speed cache system and method for implementing file access
CN101187901A
Method and device for achieving high-efficient storage of data with non-fixed lengths
CN103164490A
Data storage method and device and data access method and device
CN107622020A
OTP memory, data writing reading methods thereof and security chip
CN107908359A
Data storage system, data storage method and device, data reading method and device and electronic device
CN109783021A
