Detailed Description
The technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only a part of the embodiments of the present disclosure, and not all of the embodiments. All other embodiments obtained by a person skilled in the art based on the embodiments in the present specification without any inventive step should fall within the scope of protection of the present specification.
Please refer to fig. 1. A Stack memory (Stack), which is a storage area generally allocated in the memory for the application program, and can be used for storing some basic types of variables and reference variables of objects, etc.; heap memory (Heap), a memory area typically allocated in memory for application programs, may be used to store dynamically created objects and arrays, etc.
Data structures generally refer to the way in which a computer stores and organizes data. The data structure may specifically include an array, a stack, a queue, a linked list, a tree, a graph, and the like.
The application may open up storage space in the heap memory. The storage space may include one or more storage units. Each memory cell may be used to store data. For a storage unit in the heap memory, when the storage time of data in the storage unit reaches a preset time length, an application program may generally consider that the data in the storage unit is invalid, so as to be able to store new data in the storage unit, thereby being beneficial to saving the storage space of the heap memory. The preset time length can be flexibly set according to actual needs, and can be 5 seconds, 1 minute, 10 minutes and the like.
Please refer to fig. 2. The embodiment of the specification provides a data processing method. The data processing method can be applied to electronic equipment. The electronic devices may include a pc (personal computer), a server, an industrial personal computer (industrial control computer), a mobile smart phone, a tablet electronic device, a portable computer (e.g., a laptop computer, etc.), a Personal Digital Assistant (PDA), a desktop computer, a smart wearable device, and the like.
In this embodiment, the electronic device may be provided with a first storage space, a second storage space, a third storage space, and a count storage unit. The first storage space, the second storage space, and the third storage space may be located in a heap memory of the electronic device. The count storage unit may be located in a heap memory of the electronic device, or may be located in a stack memory of the electronic device.
In this embodiment, the first storage space may include N storage units with consecutive addresses. The N may be a natural number greater than zero, and may be, for example, 10, 50, 500, or the like. The storage unit in the first storage space may be used to store data. The data in the storage unit in the first storage space may be valid or invalid. Here, when data is referred to by one or more variables, the data may be considered valid data; when data is not referenced by any variable, the data may be considered invalid data.
It should be noted that the data in each storage unit in the first storage space may form a data set. The data structure of the data set may be an array, and thus, the data in each of the first storage units may be an array element of the array. Of course, the data set may also be other forms of data structures including, but not limited to, stacks, queues, linked lists, trees, graphs, and the like.
In this embodiment, the second storage space may include N storage units with consecutive addresses. The storage location in the second storage space may be for storing a location index of data. The position index of the data may be used to index the data, and may be a natural number. For example, as described above, the data in each storage unit in the first storage space may form a data set, the data structure of the data set may be an array, the data in each storage unit in the first storage space may be an array element of the array, and the position index in each storage unit in the second storage space may be a subscript of the array element.
It should be noted that each storage unit in the second storage space may be a valid storage unit or an invalid storage unit. Here, the effective memory cell can be understood as: the data in the storage unit pointed by the position index in the storage unit in the first storage space is valid data; invalid memory cells can be understood as: and the data in the storage unit pointed to by the position index in the storage unit in the first storage space is invalid data. The number of valid storage units in the second storage space is generally the same as the number of storage units in the first storage space in which the data stored in the first storage space is valid data.
It should be further noted that, in the second storage space, each storage unit may have a storage address. In the following process, for convenience of description, the memory cell with the smaller memory address can be considered to be in front of the memory cell with the larger memory address. Thus, for example, the memory location with the smallest memory address in the second memory space may be considered as the first memory location of the second memory space; the memory location having the largest memory address in the second memory space may be considered as the last memory location of the second memory space. In the second storage space, the valid storage units are usually located in front of the invalid storage units.
In this embodiment, the third storage space may include N storage units with consecutive addresses. The storage unit in the third storage space may be used to store a location index of the storage unit in the second storage space.
In this embodiment, the count storage unit may be configured to store the number of storage units in which the data stored in the first storage space is valid data, that is, may be configured to store the number of valid storage units in the second storage space. The count storage unit typically stores a number less than or equal to N.
In this embodiment, the sizes of the storage unit in the first storage space, the storage unit in the second storage space, and the storage unit in the third storage space may be the same or different.
In this embodiment, the electronic device may create a count storage unit in a stack memory or a heap memory. For example, through the code int c, the electronic device may open up a count storage unit in the stack memory; the count storage unit may be for storing a value of a variable c; the value of the variable c may be the number of storage units in the first storage space where the data stored in the first storage space is valid data. As another example, the electronic device may create a count storage unit in the heap memory by using the code int _ c _ new int; the counting storage unit can be used for storing the number of storage units of which the data stored in the first storage space are valid data; the value of the variable c may be the memory address of the count memory location.
In this embodiment, the electronic device may obtain a numerical value N input by a user in advance; the first storage space, the second storage space, and the third storage space may be opened up in the heap memory based on the value N. Of course, it should be understood by those skilled in the art that the numerical value N may also be obtained in other manners, which is not specifically limited in this embodiment. For example, through a code load (T) malloc (sizeof (T) N), the electronic device may open up a first memory space in the heap memory; the first memory space may include N memory cells of size sizeof (t); the value of the variable load may be the first address of the first memory space. As another example, the electronic device may open up a second storage space in the heap by using a code ref (unused) malloc (sized of (unused)) size; the second storage space may include N size of sized (unsigned) storage units; the value of the variable ref may be the first address of the second memory space. As another example, the electronic device may open up a third storage space in the heap according to the code rref (unused) malloc (sized of size); the third storage space may include N size of sized (unsigned) storage units; the value of the variable rref may be the first address of the third memory space.
Please refer to fig. 3. For example, the first memory space may include 10 memory locations with consecutive addresses, specifically Z [0] -Z [9 ]. Wherein, the position index of the storage unit Z [0] can be 0; similarly, the location index for storage location Z [1] may be 1, … …, and the location index for storage location Z [9] may be 9. The second memory space may comprise 10 memory locations with consecutive addresses, in particular X0-X9. Wherein, the position index of the storage unit X [0] can be 0; similarly, the location index for storage location X [1] may be 1, … …, and the location index for storage location X [9] may be 9. The third memory space may comprise 10 memory locations with consecutive addresses, in particular Y0-Y9. Wherein, the position index of the storage unit Y [0] can be 0; similarly, the location index of storage unit Y [1] may be 1, … …, and the location index of storage unit Y [9] may be 9. The data stored in the storage unit in the first storage space, the second storage space and the second storage space may be R, where R represents random data. The number of the count storage unit may be C, and the value of C may be 0.
In this embodiment, after a count storage unit, a first storage space, a second storage space and a third storage space are created, the data stored in the count storage unit, each storage unit in the first storage space, each storage unit in the second storage space and each storage unit in the third storage space is generally random data. In this way, the electronic device may initialize the count storage unit, and may store 0 to the count storage unit, for example. The electronic device does not need to initialize the storage unit in the first storage space, the storage unit in the second storage space and the storage unit in the third storage space. In this way, the electronic device may increase the speed of initialization.
The present embodiment may include the following steps.
Step S102: and acquiring data to be stored and a position index of the data to be stored.
In this embodiment, the data to be stored may be data of goods or services, and the position index of the data to be stored may be used to indicate a storage position of the data to be stored. For example, the data to be stored may be a, and the position index of the data to be stored may be 5. It should be noted that the data to be stored may be data to be cached, and the electronic device may temporarily store the data to be stored for reading.
In this embodiment, the data to be stored and the position index of the data to be stored may be input by a user in advance. In this way, the electronic device can acquire the data to be stored and the position index of the data to be stored, which are input by the user in advance. Of course, it should be understood by those skilled in the art that the electronic device may also use other manners to obtain the data to be stored and the position index of the data to be stored, which is not specifically limited in this embodiment.
Step S104: and storing the data to be stored to a storage unit pointed by the first position index in the first storage space by taking the position index of the data to be stored as the first position index.
In this embodiment, the electronic device may use the location index in the first storage space as the storage unit of the first location index as the storage unit pointed to by the first location index in the first storage space. Specifically, the electronic device may obtain a location index from the first storage space as a storage unit of the first location index, and then may store the data to be stored in the obtained storage unit.
In this embodiment, through step S104, the electronic device may store the data to be stored in the storage unit in the first storage space.
Step S106: taking the number in the counting storage unit as a second position index, and storing the first position index to a storage unit pointed by the second position index in the second storage space; and storing the second position index to a storage unit pointed by the first position index in the third storage space.
In this embodiment, the storage unit pointed to by the second location index in the second storage space and the storage unit pointed to by the first location index in the third storage space may be understood with reference to the foregoing step S104.
In this embodiment, after step S106, the storage unit pointed to by the second location index in the second storage space and the storage unit pointed to by the first location index in the third storage space may form a bidirectional reference relationship. Here, two storage units having a bidirectional reference relationship can be understood as: one storage unit stores a position index of the other storage unit; the other storage unit stores a position index of the storage unit.
Step S108: and performing self-addition operation on the number in the counting storage unit.
In this embodiment, the electronic device may read the number from the count storage unit; the number of reads may be self-incremented (++); the result of the self-addition operation may be stored to the count storage unit.
Please refer to fig. 3 and fig. 4. For example, the first storage space, the second storage space, the third storage space, and the count storage unit may be as shown in fig. 3. The data to be stored may be a, and the position index of the data to be stored may be 5. The electronic equipment can take the position index 5 of the data to be stored as a first position index; the number 0 in the count storage unit may be used as the first position index.
The electronic device may store the data to be stored to a storage unit pointed to by the first location index in the first storage space. That is, the electronic device may store the data to be stored a to the storage unit Z [5 ].
The electronic device may store the first location index to a storage unit pointed to by the second location index in the second storage space; the second location index may be stored to a storage location pointed to by the first location index in the third storage space. That is, the electronic device may store the first position index 5 to a storage unit X [0 ]; the second position index 0 may be stored to the storage unit Y [5 ]. Thus, memory location X [0] and memory location Y [5] can form a two-way reference relationship.
The electronic device may perform a self-addition operation on the number in the count storage unit. That is, the electronic device may perform C + + operations.
In one embodiment of this embodiment, it may be necessary to perform an update process on the data in the storage unit in the first storage space. As such, the electronic device may obtain data for updating and the location index for the updating data; the data for updating may be stored in a storage unit pointed to by the location index for updating data in the first storage space, so as to update the data in the storage unit. The process of the electronic device acquiring the data for updating and the position index for updating the data can be seen in the aforementioned step S102,
in one embodiment of this embodiment, it may be necessary to perform a deletion process on data in the storage unit in the first storage space. Thus, the electronic device can obtain the position index of the data to be deleted; the position index of the data to be deleted in the storage unit pointed by the third storage space can be used as a third position index; the position index in the storage unit pointed to by the second storage space may be a fourth position index in a difference value between the number in the counting storage unit and 1; a difference between the number in the count storage unit and the third position index may be calculated.
Under the condition that the difference between the number in the count storage unit and the third position index is greater than 1, the electronic device may consider that the valid storage unit in the second storage space, in which the position index of the data to be deleted is stored, is not the last valid storage unit. In this way, the electronic device may store the fourth position index to a storage unit pointed by the third position index in the second storage space; the third position index can be stored to a storage unit pointed by the fourth position index in the third storage space; a self-subtraction (- -) operation may be performed on the number in the count storage unit. In this way, the electronic device may store the position index in the last valid storage unit in the second storage space to the valid storage unit in the second storage space, where the position index of the data to be deleted is stored. And the storage unit pointed by the third position index in the second storage space and the storage unit pointed by the fourth position index in the third storage space can form a bidirectional reference relationship.
Under the condition that the difference between the number in the count storage unit and the third position index is equal to 1, the electronic device may regard the valid storage unit in the second storage space, in which the position index of the data to be deleted is stored, as the last valid storage unit. In this way, the electronic device can perform a self-subtraction operation on the number in the count storage unit.
Please refer to fig. 5 and fig. 6. For example, the first storage space, the second storage space, the third storage space, and the count storage unit may be as shown in fig. 5. The data to be deleted may be B, and the position index of the data to be deleted may be 7. The electronic equipment can take the position index 1 of the position index of the data to be deleted in the storage unit pointed by the third storage space as a third position index; the position index 3 in the memory location pointed to by the second memory space may be the fourth position index in the difference between the number in the count memory location and 1.
The difference between the number 3 in the count storage unit and the third position index 1 is greater than 1. Then, the electronic device may store the fourth location index to a storage location pointed to by the third location index in the second storage space; the third position index can be stored to a storage unit pointed by the fourth position index in the third storage space; a self-subtraction operation may be performed on the number in the count storage unit. That is, the electronic device may store the fourth position index 3 to a storage unit X [0 ]; the third location, the 1, may be stored to memory location Y [3 ]; c- -operations may be performed.
Please refer to fig. 5 and fig. 7. As another example, the first storage space, the second storage space, the third storage space, and the count storage unit may be as shown in fig. 5. The data to be deleted may be C, and the position index of the data to be deleted may be 3. The electronic device may use the position index 2 of the position index of the data to be deleted in the storage unit pointed by the third storage space as the third position index.
The difference between the number 3 in the count storage unit and the third position index 2 is greater than 1. Then the electronic device may perform a C-operation.
In one embodiment of this embodiment, it may be necessary to identify whether the data in the storage unit in the first storage space is valid data. In this way, the electronic device can obtain the position index of the storage unit to be identified; the position index of the storage unit to be identified can be used as a fifth position index; the location index of the fifth location index in the storage unit pointed to by the third storage space may be a sixth location index.
Under the condition that the sixth position index is greater than or equal to the number of the counting storage units, or under the condition that the position index of the sixth position index in the storage unit pointed by the second storage space is different from the fifth position index, the electronic device may identify the data in the storage unit to be identified as invalid data.
Under the condition that the sixth position index is smaller than the number in the counting storage unit and the position index of the sixth position index in the storage unit pointed by the second storage space is the same as the fifth position index, the electronic device can identify the data in the storage unit to be identified as valid data.
Please refer to fig. 5. For example, the memory location to be identified may be Z [7], and the index of the location of the memory location to be identified may be 7. The electronic equipment can take the position index 7 of the storage unit to be identified as a fifth position index; the location index 1 of the fifth location index 7 in the storage unit pointed to by the third storage space may be used as the sixth location index.
The sixth location index 1 is smaller than the number 3 in the count storage unit, and the location index of the sixth location index 1 in the storage unit pointed to by the second storage space is 7 (the same as the fifth location index 7). Thus, the electronic device can identify the data in the memory cell to be identified Z [7] as valid data.
Please refer to fig. 8. For example, the memory location to be identified may be Z [7], and the index of the location of the memory location to be identified may be 7. The electronic equipment can take the position index 7 of the storage unit to be identified as a fifth position index; the location index 1 of the fifth location index 7 in the storage unit pointed to by the third storage space may be used as the sixth location index.
The location index of the sixth location index 1 in the storage unit pointed to by the second storage space is 3 (the same as the fifth location index 7). Thus, the electronic device can identify the data in the memory cell to be identified Z [7] as invalid data.
In this embodiment, the electronic device may provide a first storage space, a second storage space, a third storage space, and a count storage unit; wherein the first storage space, the second storage space and the third storage space may include N storage units, respectively; n is a natural number greater than zero; the storage unit in the first storage space can be used for storing data; the storage unit in the second storage space can be used for storing a position index of data; the storage unit in the third storage space may be used to store a location index of the storage unit in the second storage space; the count storage unit may be configured to store the number of storage units in which the stored data is valid data. The electronic device may store data through the first storage space, the second storage space, the third storage space, and the count storage unit. The count storage unit may be initialized after being booted up. The first storage space, the second storage space, and the third storage space may not need to be initialized after being opened up. Thus, the number of memory cells to be initialized can be reduced, and the initialization speed can be increased.
Please refer to fig. 9. The embodiment of the specification also provides another data processing method. The data processing method can be applied to electronic equipment. The electronic device may be provided with a first storage space, a second storage space, a third storage space, a first count storage unit, and a second count storage unit. For detailed descriptions of the first storage space, the second storage space, and the third storage space, reference may be made to the foregoing embodiments, and details are not repeated here.
It should be noted that the valid data in the storage unit in the first storage space may be current-generation valid data or previous-generation valid data. Here, when the storage time of one valid data reaches a specified time length, the valid data may be regarded as the previous generation valid data; when the storage time of one data is less than the specified time length, the valid data can be considered as the current generation valid data. The specified time length can be flexibly set according to actual needs, and can be 10 seconds, 5 minutes, 10 minutes and the like.
It should be noted that the valid storage unit in the second storage space may be a current-generation valid storage unit or a previous-generation valid storage unit. Here, the current generation valid memory unit can be understood as: the position index in the effective storage unit is used for indicating the data in the storage unit pointed by the first storage space as the current effective data; the prior generation valid memory cell can be understood as: the data in the storage unit pointed to by the first storage space of the position index in the effective storage unit is the previous generation effective data. In the second storage space, the valid storage unit is generally positioned in front of the invalid storage unit; the current generation valid storage unit is typically located in front of the previous generation valid storage unit.
In this embodiment, the first count storage unit may be configured to store the number of storage units in which the data stored in the first storage space is valid data, that is, may be configured to store the number of valid storage units in the second storage space.
The second count storage unit may be configured to store the number of storage units in which the valid data stored in the first storage space is the current-generation valid data, that is, may be configured to store the number of current-generation valid storage units in the second storage space.
The number in the second count storage unit is typically less than or equal to the number in the first count storage unit. The second count storage unit and the first count storage unit may be located in a heap memory or a stack memory, respectively.
In this embodiment, after a first count storage unit, a second count storage unit, a first storage space, a second storage space, and a third storage space are created, the data stored in the first count storage unit, the second count storage unit, each storage unit in the first storage space, each storage unit in the second storage space, and each storage unit in the third storage space is generally random data. In this way, the electronic device may initialize the first count storage unit and the second count storage unit, respectively, and may store 0 to the first count storage unit and the second count storage unit, respectively, for example. The electronic device does not need to initialize the storage unit in the first storage space, the storage unit in the second storage space and the storage unit in the third storage space. In this way, the electronic device may increase the speed of initialization.
Please refer to fig. 10. For example, the first storage space may include 10 memory locations with consecutive addresses, specifically, 10 memory locations with consecutive addresses
Z0-Z9. Wherein, the position index of the storage unit Z [0] can be 0; similarly, the location index for storage location Z [1] may be 1, … …, and the location index for storage location Z [9] may be 9. The second memory space may comprise 10 memory locations with consecutive addresses, in particular X0-X9. Wherein, the position index of the storage unit X [0] can be 0; similarly, the location index for storage location X [1] may be 1, … …, and the location index for storage location X [9] may be 9. The third memory space may comprise 10 memory locations with consecutive addresses, in particular Y0-Y9. Wherein, the position index of the storage unit Y [0] can be 0; similarly, the location index of storage unit Y [1] may be 1, … …, and the location index of storage unit Y [9] may be 9. The data stored in the storage unit in the first storage space, the second storage space and the second storage space may be R, where R represents random data. The number of the first count storage unit may be C1, and the value of C1 may be 0. The number of the second count storage unit may be C2, and the value of C2 may be 0.
The present embodiment may include the following steps.
Step S202: and acquiring data to be stored and a position index of the data to be stored.
Step S204: and storing the data to be stored to a storage unit pointed by the first position index in the first storage space by taking the position index of the data to be stored as the first position index.
Step S206: taking the number in the first counting storage unit as a second position index, taking the number in the second counting storage unit as a third position index, taking the position index of the third position index in the storage unit pointed by the second storage space as a fourth position index, and storing the fourth position index to the storage unit pointed by the second position index in the second storage space; and storing the second position index to a storage unit pointed by the fourth position index in the third storage space.
In this embodiment, after step S206, the storage unit pointed to by the second location index in the second storage space and the storage unit pointed to by the fourth location index in the third storage space may form a bidirectional reference relationship.
Step S208: storing the first position index to a storage unit pointed by the third position index in the second storage space; and storing the third position index to a storage unit pointed by the first position index in the third storage space.
In this embodiment, after step S208, the storage unit pointed to by the third position index in the second storage space and the storage unit pointed to by the first position index in the third storage space may form a bidirectional reference relationship.
Step S210: and respectively carrying out self-addition operation on the number in the first counting storage unit and the number in the second counting storage unit.
Please refer to fig. 11 and 12. For example, the first storage space, the second storage space, the third storage space, the first count storage unit, and the second count storage unit may be as shown in fig. 11. In FIG. 11, the data in memory cell Z [5] is the current generation valid data; the data in the storage units Z3 and Z7 is the previous generation valid data; the memory cell X [0] is a current generation valid memory cell; the memory cells X1 and X2 are previous generation valid memory cells. The data to be stored may be D, and the position index of the data to be stored may be 1. The electronic equipment can take the position index 1 of the data to be stored as a first position index; the number 3 in the first count storage unit may be used as a second position index; the number 1 in the second count storage unit may be used as a third position index; the fourth position index may be a position index 7 of the third position index in the storage unit pointed to by the second storage space.
The electronic device may store the data to be stored to a storage unit pointed to by the first location index in the first storage space. That is, the electronic device may store the data to be stored D to the storage unit Z [1 ].
The electronic device may store the fourth location index to a storage unit pointed to by the second location index in the second storage space; the second location index may be stored to a storage location pointed to by the fourth location index in the third storage space. That is, the electronic device may store the fourth position index 7 to a storage unit X [3 ]; the second position index 3 may be stored to the storage unit Y [7 ]. Thus, memory location X [3] and memory location Y [7] can form a two-way reference relationship.
The electronic device may store the first location index to a storage unit pointed to by the third location index in the second storage space; the third location index may be stored to a storage location pointed to by the first location index in the third storage space. That is, the electronic device may store the first location index 1 to a storage unit X [1 ]; the third location index 1 may be stored to storage location Y [1 ]. The storage unit X [1] and the storage unit Y [1] can form a bidirectional reference relationship.
The electronic device may perform a self-addition operation on the number in the first count storage unit and the number in the second count storage unit, respectively. That is, the electronic device may perform C1+ + and C2+ + operations, respectively.
In one embodiment of this embodiment, it may be necessary to perform an update process on the data in the storage unit in the first storage space. As such, the electronic device may obtain data for updating and the location index for the updating data; the location index of the location index for updating data in the storage unit pointed to by the third storage space may be used as a fifth location index. Wherein the position index for the update data is generally greater than or equal to 0 and less than the number in the first count storage unit.
Under the condition that the fifth location index is smaller than the third location index, the electronic device may consider that the valid storage unit, in which the location index for updating data is stored, in the second storage space is a current-generation valid storage unit. In this way, the electronic device may store the data for updating to a storage unit pointed to by the location index for updating data in the first storage space.
Under the condition that the fifth location index is equal to the third location index, the electronic device may consider that the valid storage unit, in the second storage space, storing the location index for updating data is a first previous generation valid storage unit. In this way, the electronic device may store the data for updating to a storage unit pointed to by the location index for updating data in the first storage space; a self-addition operation may be performed on the number in the second count storage unit.
Under the condition that the fifth position index is larger than the third position index, the electronic device may consider that the valid storage unit in the second storage space, in which the position index for updating data is stored, is a previous-generation valid storage unit other than the first previous-generation valid storage unit. As such, the electronic device may use the position index of the third position index in the storage unit pointed by the second storage space as a sixth position index; the location index of the fifth location index in the storage unit pointed to by the second storage space and the location index of the third location index in the storage unit pointed to by the second storage space may be swapped; the location index of the location index for updating data in the location pointed to by the third storage space and the location index of the sixth location index in the storage location pointed to by the third storage space may be swapped; the data for updating can be stored to a storage unit pointed to by the position index for updating data in the first storage space; a self-addition operation may be performed on the number in the second count storage unit. In this way, the storage location pointed to by the third location index in the second storage space and the location pointed to by the location index for updating data in the third storage space may form a bidirectional reference relationship; the storage unit pointed by the fifth position index in the second storage space and the storage unit pointed by the sixth position index in the third storage space can form a bidirectional reference relationship.
Please refer to fig. 11 and fig. 13. For example, the first storage space, the second storage space, the third storage space, the first count storage unit, and the second count storage unit may be as shown in fig. 11. The data for updating may be E; the location index for the update data may be 3. The electronic device may use the position index 2 of the position index 3 for updating data in the storage unit pointed to by the third storage space as a fifth position index.
The fifth position index 2 is greater than the third position index 1. Then, the electronic device may use the position index 7 of the third position index 1 in the storage unit pointed by the second storage space as a sixth position index; the location index of the fifth location index in the storage unit pointed to by the second storage space and the location index of the third location index in the storage unit pointed to by the second storage space may be swapped; the location index of the location index for updating data in the location pointed to by the third storage space and the location index of the sixth location index in the storage location pointed to by the third storage space may be swapped; the data for updating can be stored to a storage unit pointed to by the position index for updating data in the first storage space; a self-addition operation may be performed on the number in the second count storage unit. That is, the electronic device may swap the location indexes in storage units X [1] and X [2 ]; the position indexes in the memory cells Y3 and Y7 can be exchanged; the data for updating E can be stored to a storage unit Z [3 ]; c2+ + operations may be performed.
In one embodiment of this embodiment, it may be necessary to perform a deletion process on data in the storage unit in the first storage space. Thus, the electronic device can obtain the position index of the data to be deleted; the position index of the data to be deleted in the storage unit pointed by the third storage space can be used as a seventh position index; a difference between the third position index and the seventh position index may be calculated.
Under the condition that the difference value obtained by subtracting the seventh position index from the third position index is greater than 1, the electronic device may regard the valid storage unit in the second storage space, in which the position index of the data to be deleted is stored, as the other valid storage units except the last valid storage unit. In this way, the electronic device may store the position index of the difference value between the third position index and 1 in the storage unit pointed to by the second storage space to the storage unit pointed to by the seventh position index in the second storage space; the seventh position index may be stored to a storage unit to which the difference between the third position index and 1 points in the third storage space; a location index in a storage unit pointed to by the second storage space may be an eighth location index in a difference between the second location index and 1; the eighth location index may be stored to a storage location to which a difference between the third location index and 1 points in the second storage space; a difference between the third position index and 1 may be stored to a storage location to which the eighth position index points in the third storage space; the number in the first count storage unit and the number in the second count storage unit may be subjected to a self-subtraction operation, respectively. In this way, the storage unit pointed by the seventh position index in the second storage space and the storage unit pointed by the third position index in the third storage space have a difference value of 1 to form a bidirectional reference relationship; the storage unit pointed to by the difference value between the third position index and 1 in the second storage space and the storage unit pointed to by the eighth position index in the third storage space can form a bidirectional reference relationship.
Under the condition that the difference value obtained by subtracting the seventh position index from the third position index is equal to 1, the electronic device may regard the valid storage unit in the second storage space, in which the position index of the data to be deleted is stored, as the last current-generation valid storage unit. As such, the electronic device may use the position index of the difference between the second position index and 1 in the storage unit pointed to by the second storage space as the eighth position index; the eighth location index may be stored to a storage location pointed to by the seventh location index in the second storage space; the seventh location index may be stored to a storage location to which the eighth location index points in the third storage space; the number in the first count storage unit and the number in the second count storage unit may be subjected to a self-subtraction operation, respectively. In this way, the storage location pointed to by the seventh position index in the second storage space and the storage location pointed to by the eighth position index in the third storage space may form a bidirectional reference relationship.
Under the condition that the seventh position index is greater than or equal to the third position index and the difference value between the seventh position index and the second position index is greater than 1, the electronic device may regard the valid storage unit in the second storage space, in which the position index of the data to be deleted is stored, as a previous generation valid storage unit except for a last previous generation valid storage unit. As such, the electronic device may use the position index of the difference between the second position index and 1 in the storage unit pointed to by the second storage space as the eighth position index; the eighth location index may be stored to a storage location pointed to by the seventh location index in the second storage space; the seventh location index may be stored to a storage location to which the eighth location index points in the third storage space; a self-subtraction operation may be performed on the number in the first count storage unit. In this way, the storage location pointed to by the seventh position index in the second storage space and the storage location pointed to by the eighth position index in the third storage space may form a bidirectional reference relationship.
Under the condition that the difference between the seventh position index and the second position index is equal to 1, the electronic device may regard the valid storage unit, in the second storage space, in which the position index of the data to be deleted is stored as a last previous generation valid storage unit. In this way, the electronic device may perform a self-subtraction operation on the number in the first count storage unit.
Please refer to fig. 14 and 15 together. For example, the first storage space, the second storage space, the third storage space, the first count storage unit, and the second count storage unit may be as shown in fig. 14. The data to be deleted may be a, and the position index of the data to be deleted may be 5. The electronic device may use a position index 0 of the position index of the data to be deleted in the storage unit pointed by the third storage space as a seventh position index.
The difference between the third position index 2 minus the seventh position index is greater than 1. Then, the electronic device stores the position index of the difference value between the third position index and 1 in the storage unit pointed to by the second storage space to the storage unit pointed to by the seventh position index in the second storage space; the seventh location index may be stored to a storage location to which the difference between the third location index and 1 points in the third storage space. That is, the electronic device may store the position index 1 to the storage unit X [0 ]; the seventh position index, 0, may be stored to storage location Y [1 ]. Thus, memory location X [0] and memory location Y [1] can form a two-way reference relationship.
The electronic device may use a position index of a difference value between the second position index and 1 in the storage unit pointed to by the second storage space as an eighth position index; the eighth location index may be stored to a storage location to which a difference between the third location index and 1 points in the second storage space; the difference between the third position index and 1 may be stored to the memory location to which the eighth position index points in the third memory space. That is, the electronic device may use the position index 7 of the difference value between the second position index and 1 in the storage unit pointed to by the second storage space as the eighth position index; the eighth position index 7 may be stored to storage location X [1 ]; 1 may be stored to memory cell Y [7 ]. Thus, memory location X [1] and memory location Y [7] can form a two-way reference relationship.
The electronic device may perform a self-subtraction operation on the number in the first count storage unit and the number in the second count storage unit, respectively. That is, the electronic device may perform the C1-and C2-operations, respectively.
Please refer to fig. 14 and 16. As another example, the first storage space, the second storage space, the third storage space, the first count storage unit, and the second count storage unit may be as shown in fig. 14. The data to be deleted may be D, and the position index of the data to be deleted may be 1. The electronic device may use a position index 1 of the position index of the data to be deleted in the storage unit pointed by the third storage space as a seventh position index.
The difference of the third position index 2 minus the seventh position index is equal to 1. Then, the electronic device may use the position index of the difference value between the second position index and 1 in the storage unit pointed to by the second storage space as the eighth position index; the eighth location index may be stored to a storage location pointed to by the seventh location index in the second storage space; the seventh location index may be stored to a storage location to which the eighth location index points in the third storage space; the number in the first count storage unit and the number in the second count storage unit may be subjected to a self-subtraction operation, respectively. That is, the electronic device may use the position index 7 of the difference value 3 between the second position index and 1 in the storage unit pointed to by the second storage space as the eighth position index; the eighth position index 7 may be stored to storage location X [1 ]; the seventh position index 1 may be stored to the storage unit Y [7 ]. Thus, memory location X [1] and memory location Y [7] can form a two-way reference relationship.
The electronic device may perform a self-subtraction operation on the number in the first count storage unit and the number in the second count storage unit, respectively. That is, the electronic device may perform the C1-and C2-operations, respectively.
Please refer to fig. 14 and 17. As another example, the first storage space, the second storage space, the third storage space, the first count storage unit, and the second count storage unit may be as shown in fig. 14. The data to be deleted may be C, and the position index of the data to be deleted may be 3. The electronic device may use a position index 2 of the position index of the data to be deleted in the storage unit pointed by the third storage space as a seventh position index.
The seventh position index 2 is equal to the third position index 2 and a difference from the second position index 4 is greater than 1. Then, the electronic device may use the position index 7 of the difference between the second position index and 1 in the storage unit pointed to by the second storage space as the eighth position index; the eighth location index may be stored to a storage location pointed to by the seventh location index in the second storage space; the seventh location index may be stored to a storage location to which the eighth location index points in the third storage space. That is, the electronic device may store the eighth position index 7 to storage location X [2 ]; the seventh position index 2 may be stored to the storage unit Y [7 ]. Thus, memory location X [2] and memory location Y [7] can form a two-way reference relationship.
The electronic device may perform a self-subtraction operation on the number in the first count storage unit. That is, the electronic device may perform the C1 operation.
In one embodiment of this embodiment, it may be necessary to identify whether the data in the storage unit in the first storage space is valid data. In this way, the electronic device can obtain the position index of the storage unit to be identified; the position index of the storage unit to be identified can be used as a ninth position index; the location index of the ninth location index in the storage unit pointed to by the third storage space may be a tenth location index.
Under the condition that the tenth position index is greater than or equal to the number of the first counting storage units, or under the condition that the position index of the tenth position index in the storage unit pointed by the second storage space is different from the ninth position index, the electronic device may identify the data in the storage unit to be identified as invalid data.
Under the condition that the tenth position index is smaller than the number of the first counting storage units and the position index of the tenth position index in the storage unit pointed by the second storage space is the same as the ninth position index, the electronic device may identify the data in the storage unit to be identified as valid data.
Please refer to fig. 11 and 18. In an implementation manner of this embodiment, after a preset condition is satisfied, the electronic device may store the number in the second count storage unit to the first count storage unit, and may store 0 to the second count storage unit. In this way, the electronic device may use the current generation valid data in the first storage space as the previous generation valid data, and may consider the previous generation valid data in the first slave memory space as the invalid data. The preset condition may include reaching a preset time period. The preset time period can be flexibly set according to actual needs.
In this embodiment, the electronic device may provide a first storage space, a second storage space, a third storage space, a first count storage unit, and a second count storage unit; wherein the first storage space, the second storage space and the third storage space may respectively include N storage units; n is a natural number greater than zero; the storage unit in the first storage space is used for storing data; the storage unit in the second storage space is used for storing a position index of data; the storage unit in the third storage space is used for storing a position index of the storage unit; the first counting storage unit is used for storing the number of storage units of which the stored data are valid data; the second counting storage unit is used for storing the number of the storage units of which the stored valid data are the current valid data. The electronic device may store data through a first storage space, a second storage space, a third storage space, a first count storage unit, and a second count storage unit. The first count storage unit and the second count storage unit may be initialized after being opened up. The first storage space, the second storage space, and the third storage space may not need to be initialized after being opened up. Thus, the number of memory cells to be initialized can be reduced, and the initialization speed can be increased.
In addition, in this embodiment, the data in the storage unit in the first storage space is subjected to generation invalidation based on the count storage unit and the second count storage unit, so that a generation identifier that a storage unit is opened up for each storage unit in the first storage space in the heap memory to store data is avoided, and thus the memory space is saved.
Please refer to fig. 19. The embodiment of the specification also provides electronic equipment. The electronic device includes a memory and a processor.
In the present embodiment, the Memory includes, but is not limited to, a Dynamic Random Access Memory (DRAM), a Static Random Access Memory (SRAM), and the like.
In this embodiment, the memory includes a first storage space, a second storage space, a third storage space and a count storage unit; the first storage space, the second storage space and the third storage space respectively comprise N storage units; n is a natural number greater than zero; the storage unit in the first storage space is used for storing data; the storage unit in the second storage space is used for storing a position index of data; the storage unit in the third storage space is used for storing a position index of the storage unit; the counting storage unit is used for storing the number of the storage units of which the stored data are valid data.
In this embodiment, the processor may be implemented in any suitable manner. For example, the processor may take the form of, for example, a microprocessor or processor and a computer-readable medium that stores computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, an embedded microcontroller, and so forth.
In this embodiment, the processor may be configured to obtain data to be stored and a position index of the data to be stored; storing the data to be stored to a storage unit pointed by the first position index in the first storage space by taking the position index of the data to be stored as the first position index; taking the number in the counting storage unit as a second position index, and storing the first position index to a storage unit pointed by the second position index in the second storage space; storing the second position index to a storage unit pointed by the first position index in the third storage space; and performing self-addition operation on the number in the counting storage unit.
The specific functions of the electronic device, the memory thereof and the processor thereof, which are disclosed in the embodiments of the present specification, can be explained in contrast to the foregoing embodiments in the present application.
Please refer to fig. 20. An embodiment of the present specification further provides a data processing apparatus, including:
an obtaining unit 2002 for obtaining data to be stored and a position index of the data to be stored;
a first storage unit 2004, configured to store the data to be stored to a storage unit pointed to by the first location index in the first storage space, with the location index of the data to be stored as a first location index; the first storage space comprises N storage units, and each storage unit is used for storing data; n is a natural number greater than zero;
a second storage unit 2006, configured to use the number in the counting storage unit as a second location index, and store the first location index into a storage unit pointed by the second location index in the second storage space; storing the second position index to a storage unit pointed by the first position index in the third storage space; the counting storage unit is used for storing the number of storage units of which the stored data are valid data; the second storage space comprises N storage units, and each storage unit is used for storing a position index of data; the third storage space comprises N storage units, and each storage unit is used for storing the position index of the storage unit in the second storage space;
an operation unit 2008, configured to perform a self-addition operation on the number in the count storage unit.
Please refer to fig. 19. The embodiment of the specification also provides another electronic device. The electronic device includes a memory and a processor.
In the present embodiment, the Memory includes, but is not limited to, a Dynamic Random Access Memory (DRAM), a Static Random Access Memory (SRAM), and the like.
In this embodiment, the memory includes a first storage space, a second storage space, a third storage space, a first count storage unit and a second count storage unit; the first storage space, the second storage space and the third storage space respectively comprise N storage units; n is a natural number greater than zero; the storage unit in the first storage space is used for storing data; the storage unit in the second storage space is used for storing a position index of data; the storage unit in the third storage space is used for storing a position index of the storage unit; the first counting storage unit is used for storing the number of storage units of which the stored data are valid data; the second counting storage unit is used for storing the number of the storage units of which the stored valid data are the current valid data.
In this embodiment, the processor may be implemented in any suitable manner. For example, the processor may take the form of, for example, a microprocessor or processor and a computer-readable medium that stores computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, an embedded microcontroller, and so forth.
In this embodiment, the processor may be configured to obtain data to be stored and a position index of the data to be stored; storing the data to be stored to a storage unit pointed by the first position index in the first storage space by taking the position index of the data to be stored as the first position index; taking the number in the first counting storage unit as a second position index, taking the number in the second counting storage unit as a third position index, taking the position index of the third position index in the storage unit pointed by the second storage space as a fourth position index, and storing the fourth position index to the storage unit pointed by the second position index in the second storage space; storing the second position index to a storage unit pointed by the fourth position index in the third storage space; storing the first position index to a storage unit pointed by the third position index in the second storage space; storing the third position index to a storage unit pointed by the first position index in the third storage space; and respectively carrying out self-addition operation on the number in the first counting storage unit and the number in the second counting storage unit.
The specific functions of the electronic device, the memory thereof and the processor thereof, which are disclosed in the embodiments of the present specification, can be explained in contrast to the foregoing embodiments in the present application.
Please refer to fig. 21. An embodiment of the present specification further provides another data processing apparatus, including:
an acquiring unit 2102 configured to acquire data to be stored and a position index of the data to be stored;
a first storage unit 2104, configured to store the data to be stored to a storage unit pointed to by the first location index in the first storage space, with the location index of the data to be stored as a first location index; the first storage space comprises N storage units, and each storage unit is used for storing data; n is a natural number greater than zero;
a second storage unit 2106, configured to use the number in the first counting storage unit as a second location index, use the number in the second counting storage unit as a third location index, use a location index of the third location index in the storage unit pointed to by the second storage space as a fourth location index, and store the fourth location index to the storage unit pointed to by the second location index in the second storage space; storing the second position index to a storage unit pointed by the fourth position index in the third storage space; the first counting storage unit is used for storing the number of storage units of which the stored data are valid data; the second counting storage unit is used for storing the number of storage units of which the stored valid data are the current valid data; the second storage space comprises N storage units, and each storage unit is used for storing a position index of data; the third storage space comprises N storage units, and each storage unit is used for storing the position index of the storage unit in the second storage space;
a third storage unit 2108, configured to store the first location index to a storage unit pointed by the third location index in the second storage space; storing the third position index to a storage unit pointed by the first position index in the third storage space;
an arithmetic unit 2110 for performing a self-addition operation on the number in the first count storage unit and the number in the second count storage unit, respectively.
It should be noted that, in the present specification, each embodiment is described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the embodiments of the electronic device and the data processing apparatus, since they are substantially similar to the embodiments of the method, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the embodiments of the method.
In addition, it should be understood by those skilled in the art that after reading this specification, there is no need for inventive faculty to conceive of any combination of some or all of the embodiments recited in this document, which combinations are also within the scope of the disclosure and protection of this application.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, programmable logic devices
(PLD) (e.g. field Programmable Gate array (Fieldprogrammable Gate array)
Array, FPGA)) is one such integrated circuit whose logical functions are determined by the user programming the device. A digital system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate a dedicated integrated circuit chip 2. Furthermore, instead of manually manufacturing the integrated circuit chip, the programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used in the program development and writing, and the original code before compiling is written by a specific programming language, which is called hardware description language
(HDL), but HDL is not only one but many, such as ABEL (advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Central University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, LASPAM, RHDL (RubyHardware Description Language), etc., with VHDL (Very-High-Speedered Circuit Hardware) being the most commonly used at present
Description Language) and Verilog 2. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, 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.
From the above description of the embodiments, it is clear to those skilled in the art that the present specification can be implemented by software plus a necessary general hardware platform. Based on such understanding, the technical solutions of the present specification may be essentially or partially implemented in the form of software products, which may be stored in a storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and include instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments of the present specification.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The description is operational with numerous general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like.
This description may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
While the specification has been described with examples, those skilled in the art will appreciate that there are numerous variations and permutations of the specification that do not depart from the spirit of the specification, and it is intended that the appended claims include such variations and modifications that do not depart from the spirit of the specification.