CN109101438B - Method and apparatus for storing data - Google Patents

Method and apparatus for storing data Download PDF

Info

Publication number
CN109101438B
CN109101438B CN201810826491.3A CN201810826491A CN109101438B CN 109101438 B CN109101438 B CN 109101438B CN 201810826491 A CN201810826491 A CN 201810826491A CN 109101438 B CN109101438 B CN 109101438B
Authority
CN
China
Prior art keywords
node
data
command
indicated
pointer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810826491.3A
Other languages
Chinese (zh)
Other versions
CN109101438A (en
Inventor
杨笛
李涵
甘璐
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201810826491.3A priority Critical patent/CN109101438B/en
Publication of CN109101438A publication Critical patent/CN109101438A/en
Application granted granted Critical
Publication of CN109101438B publication Critical patent/CN109101438B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/0292User address space allocation, e.g. contiguous or non contiguous base addressing using tables or multilevel address translation means
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/06Addressing a physical block of locations, e.g. base addressing, module addressing, memory dedication
    • G06F12/0646Configuration or reconfiguration
    • G06F12/0653Configuration or reconfiguration with centralised address assignment

Abstract

The embodiment of the application discloses a method and a device for storing data. One embodiment of the above method comprises: allocating node pools with continuous memory block addresses to a pre-established linked list; in response to receiving a data insertion command for the linked list, determining an insertion position indicated by the data insertion command and acquiring an idle node from a node pool; writing data into the idle node; and setting pointers of a previous node, a next node and an idle node of an insertion position according to the idle node. The implementation mode reduces the time required for traversing the linked list and improves the efficiency of traversing the linked list.

Description

Method and apparatus for storing data
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a method and a device for storing data.
Background
A linked list is a non-continuous, non-sequential storage structure on a physical storage unit, and the logical order of data elements is realized by the order of pointer links in the linked list. The linked list structure can overcome the defect that the data size of the array linked list needs to be known in advance, and the linked list structure can fully utilize the memory space of a computer and realize flexible dynamic memory management.
Disclosure of Invention
The embodiment of the application provides a method and a device for storing data.
In a first aspect, an embodiment of the present application provides a method for storing data, including: allocating node pools with continuous memory block addresses to a pre-established linked list; in response to receiving a data insertion command for the linked list, determining an insertion position indicated by the data insertion command and acquiring an idle node from the node pool; writing data into the idle node; and setting a previous node and a next node of the insertion position and a pointer of the idle node according to the idle node.
In some embodiments, the above method further comprises: initializing the pre-created linked list.
In some embodiments, the above method further comprises: in response to receiving a data deletion command for the linked list, determining the position of a node indicated by the data deletion command and deleting data stored in the node indicated by the data deletion command; and setting pointers of a previous node and a next node of the position of the node indicated by the data deleting command and the node indicated by the data deleting command.
In some embodiments, the above method further comprises: resetting the node indicated by the data deleting command; and returning the reset nodes to the node pool.
In some embodiments, the pointers include a front pointer and a back pointer; and the setting of the previous and subsequent nodes of the insertion position and the pointer of the free node according to the free node includes: setting a back pointer of a previous node of the insertion position to point to the idle node; setting a front pointer of a node next to the insertion position to point to the idle node; setting the front pointer of the free node to point to the previous node of the insertion position and setting the back pointer of the free node to point to the next node of the insertion position.
In some embodiments, the pointers include a front pointer and a back pointer; and the setting of the pointers of the nodes indicated by the data deletion command, the nodes preceding and following the position of the node indicated by the data deletion command, includes: setting a back pointer of a node before the position of the node indicated by the data deleting command to point to a node after the position of the node indicated by the data deleting command; setting a front pointer of a node next to the position of the node indicated by the data deleting command to point to a node previous to the position of the node indicated by the data deleting command; and deleting the front pointer and the back pointer of the node indicated by the data deleting command.
In a second aspect, an embodiment of the present application provides an apparatus for storing data, including: the distribution unit is configured to distribute a node pool with continuous memory to a pre-established linked list; the acquisition unit is configured to respond to the received data insertion command aiming at the linked list, determine the insertion position indicated by the data insertion command and acquire a free node from the node pool; a writing unit configured to write data into the free node; a first setting unit configured to set a previous node, a next node, and a pointer of the free node of the insertion position, based on the free node.
In some embodiments, the above apparatus further comprises: and the initialization unit is configured to initialize the pre-created linked list.
In some embodiments, the above apparatus further comprises: a deleting unit configured to determine a position of a node indicated by the data deleting command and delete data stored in the node indicated by the data deleting command in response to receiving the data deleting command for the linked list; a second setting unit configured to set pointers of a node previous to and subsequent to the position of the node indicated by the data deletion command and the node indicated by the data deletion command.
In some embodiments, the above apparatus further comprises: a reset unit configured to reset the node indicated by the data delete command; and the return unit is configured to return the reset node to the node pool.
In some embodiments, the pointers include a front pointer and a back pointer; and the first setting unit is further configured to: setting a back pointer of a previous node of the insertion position to point to the idle node; setting a front pointer of a node next to the insertion position to point to the idle node; setting the front pointer of the free node to point to the previous node of the insertion position and setting the back pointer of the free node to point to the next node of the insertion position.
In some embodiments, the pointers include a front pointer and a back pointer; and the second setting unit is further configured to: setting a back pointer of a node before the position of the node indicated by the data deleting command to point to a node after the position of the node indicated by the data deleting command; setting a front pointer of a node next to the position of the node indicated by the data deleting command to point to a node previous to the position of the node indicated by the data deleting command; and deleting the front pointer and the back pointer of the node indicated by the data deleting command.
In a third aspect, an embodiment of the present application provides an apparatus, including: one or more processors; a storage device, on which one or more programs are stored, which, when executed by the one or more processors, cause the one or more processors to implement the method as described in any of the embodiments of the first aspect.
In a fourth aspect, the present application provides a computer-readable medium, on which a computer program is stored, which when executed by a processor implements the method as described in any one of the embodiments of the first aspect.
The method and the device for storing data provided by the above embodiments of the present application may first allocate a node pool with consecutive memory block addresses to a pre-created linked list. And then when a data insertion command for the linked list is received, determining the insertion position indicated by the data insertion command, and acquiring the idle node from the node pool. Then, the data is written into the acquired free node. And finally, setting pointers of a previous node, a next node and a free node of the insertion position according to the free node. According to the method and the device, the linked list is distributed with the node pools with continuous memory block addresses, so that the relative continuity of the addresses of all the nodes in the linked list can be ensured, the time for traversing the linked list is reduced, and the efficiency for traversing the linked list is improved.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is a flow diagram of one embodiment of a method for storing data according to the present application;
FIG. 2 is a schematic diagram of an application scenario of a method for storing data according to the present application;
FIG. 3 is a flow diagram of yet another embodiment of a method for storing data according to the present application;
FIG. 4 is a schematic block diagram illustrating one embodiment of an apparatus for storing data according to the present application;
FIG. 5 is a block diagram of a computer system suitable for use in implementing the apparatus of an embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
With continued reference to FIG. 1, a flow 100 of one embodiment of a method for storing data in accordance with the present application is shown. The method for storing data of the embodiment comprises the following steps:
step 101, allocating a node pool with continuous memory block addresses to a pre-established linked list.
In this embodiment, the execution body of the method for storing data may include a memory, and an operating system application program is installed in the execution body. The execution agent may create a linked list for storing data in advance, where the linked list may include a plurality of nodes, and each element in the linked list is called a node. The linked list may also include a head pointer and a tail pointer. The head pointer is used to determine the storage location corresponding to the first element in the linked list, i.e., the location of the first node. The tail pointer is used for determining the storage position corresponding to the last element in the linked list, namely the position of the last node. The execution subject may allocate a node pool with consecutive memory block addresses to the pre-created linked list. The application program usually uses a computer memory during running, and in this embodiment, the node pool may be allocated to the above linked list. The node pool includes a plurality of memory nodes, each memory node refers to a memory block of a specific size, and the memory block is a basic unit of an operating system operating memory. Each memory block has an address, and in this embodiment, the addresses of the memory blocks in the node pool allocated to the linked list by the execution main body are consecutive.
In some optional implementations of this embodiment, the execution agent may further initialize the pre-created linked list. The length of the initialized linked list is zero, at this time, the head pointer is null, and the tail pointer points to itself.
And 102, responding to the received data insertion command aiming at the linked list, determining the insertion position indicated by the data insertion command and acquiring the idle node from the node pool.
The execution body may determine an insertion location indicated by the data insertion command when receiving the data insertion command for the linked list. The data insertion command may be generated by a user for a certain operation of the linked list, or may be generated after an operating system installed in the execution body receives related information. After receiving the data insertion command, the execution body may parse the data insertion command, and determine an insertion location indicated by the data insertion command. It is to be understood that the data insertion command includes a position where the node where the data to be stored is to be inserted.
The execution body may also obtain a free node from the node pool after receiving the data insertion command. In some optional implementation manners of this embodiment, when acquiring the idle node, the execution main body may sequentially acquire the memory blocks as the idle node according to the addresses of the memory blocks. Therefore, the addresses corresponding to the nodes in the linked list are relatively continuous, and the time for traversing the linked list is reduced.
And 103, writing the data into the idle node.
After the execution main body acquires the idle node, the data to be stored can be written into the idle node. For example, the execution agent may write data to the free node in a predetermined storage manner.
And 104, setting pointers of a previous node, a next node and an idle node of the insertion position according to the idle node.
In this embodiment, each node in the linked list except the head node and the tail node may include 3 elements: a forward pointer prev, a backward pointer next and data. The head node and tail node include only two elements: a forward pointer prev and a backward pointer next. After the execution main body writes the data into the idle node, pointers of a previous node, a next node and the idle node of the insertion position can be set according to the idle node. For example, the execution agent may set the backward pointer of the previous node, the forward pointer of the next node, and the forward pointer and/or backward pointer of the free node at the same time.
In some optional implementations of this embodiment, the step 104 may be implemented by the following steps not shown in fig. 1: first, the back pointer of the previous node to the set insertion position points to the free node. Then, the front pointer of the next node to set the insertion position points to the free node. And finally, setting a front pointer of the idle node to point to a previous node of the insertion position and setting a back pointer of the idle node to point to a next node of the insertion position.
When setting the pointer of the previous node of the insertion position, the backward pointer of the previous node may be set to point to the free node. The forward pointer of the free node is then directed to the previous node and the backward pointer is directed to the next node. The forward pointer of the latter node is pointed to the free node.
With continued reference to fig. 2, fig. 2 is a schematic diagram of an application scenario of the method for storing data according to the present embodiment. In the application scenario of fig. 2, the linked list includes a plurality of nodes, and only 4 nodes in the middle portion are schematically shown in the figure, namely node 1, node 2, node 3, and node 4. The nodes are connected with each other through forward pointers and backward pointers. The node pool comprises a plurality of idle nodes, and the memory block addresses of the idle nodes are continuous. The execution body, upon receiving the data insertion command, determines that the insertion location is between node 2 and node 3. Meanwhile, the execution main body acquires the free nodes from the node pool. After writing data to the free node, the pointing of the forward and backward pointers of node 2, node 3 and the free node are adjusted. The storage of data is realized.
In the method for storing data provided by the above embodiment of the present application, a node pool with consecutive memory block addresses may be allocated to a pre-created linked list. And then when a data insertion command for the linked list is received, determining the insertion position indicated by the data insertion command, and acquiring the idle node from the node pool. Then, the data is written into the acquired free node. And finally, setting pointers of a previous node, a next node and a free node of the insertion position according to the free node. In the method of this embodiment, a node pool with continuous memory block addresses is allocated to the linked list, and because the memory addresses of the idle nodes acquired from the node pool by the operating system in the execution main body each time are relatively continuous, the probability of cache hit can be improved when the operating system accesses the linked list. Therefore, the speed of reading the linked list by the operating system is increased, the time for traversing the linked list is reduced, and the efficiency of traversing the linked list is improved.
With continued reference to FIG. 3, a flow 300 of another embodiment of a method for storing data in accordance with the present application is shown. As shown in fig. 3, the method for storing data of the present embodiment may further include the following steps:
step 301, in response to receiving a data delete command for the linked list, determining a location of a node indicated by the data delete command and deleting data stored in the node indicated by the data delete command.
When receiving a data deletion command for a linked list, an execution agent may first determine a location of a node indicated by the data deletion command. The data deleting command may be generated by a user operating a linked list, or may be generated by an operating system installed in the execution main body receiving related information. After receiving the data deletion command, the execution main body may parse the data deletion command, and determine a position of a node indicated by the data deletion command. It is understood that the data insertion command should include the location of the node where the data to be deleted is located.
Step 302, setting pointers of nodes before and after the position of the node indicated by the data deleting command and the node indicated by the data deleting command.
After determining the position of the node indicated by the data deletion command, the execution body may set pointers of a node previous to the position, a node subsequent to the position, and the node indicated by the data deletion command. For example, the execution agent may modify the pointing of the backward pointer of the previous node, the pointing of the forward pointer of the next node. The execution body may also delete the forward and backward pointers of the node indicated by the data delete command.
In some optional implementations of this embodiment, the step 302 may be specifically implemented by the following steps not shown in fig. 3: first, the back pointer of the node preceding the position of the node indicated by the data delete command is set to point to the node succeeding the position of the node indicated by the data delete command. Then, the front pointer of the node subsequent to the position of the node indicated by the data delete command is set to point to the node previous to the position of the node indicated by the data delete command. And finally, deleting the front pointer and the back pointer of the node indicated by the data deleting command.
Step 303, the node indicated by the data delete command is reset.
In this embodiment, the execution subject may reset the node indicated by the data delete command. In this way, the node can be written with data again.
And step 304, returning the reset nodes to the node pool.
The execution agent may return the reset nodes to the node pool for linked list recycling. Therefore, the operation system installed in the execution main body is prevented from calling the destructor to destruct the node, and the efficiency of deleting the node is effectively improved. Meanwhile, the condition that the number of available nodes in the node pool is less and less is avoided.
The method for storing data provided by the above embodiment of the application can reset the deleted node and then put the deleted node into the node pool again for reuse, thereby reducing the operation time.
With further reference to fig. 4, as an implementation of the methods shown in the above-mentioned figures, the present application provides an embodiment of an apparatus for storing data, which corresponds to the method embodiment shown in fig. 1, and which is particularly applicable to various electronic devices.
As shown in fig. 4, the apparatus 400 for storing data of the present embodiment includes: an allocation unit 401, an acquisition unit 402, a writing unit 403, and a first setting unit 404.
Wherein, the allocating unit 401 is configured to allocate a node pool with continuous memory to a pre-created linked list.
The obtaining unit 402 is configured to, in response to receiving a data insertion command for the linked list, determine an insertion position indicated by the data insertion command and obtain a free node from the node pool.
A write unit 403 configured to write data to the free node.
A first setting unit 404 configured to set pointers of a previous node, a next node, and a free node of the insertion position according to the free node.
In some optional implementations of the present embodiment, the apparatus 400 further includes an initialization unit, not shown in fig. 4, configured to initialize a pre-created linked list.
In some optional implementations of the present embodiment, the apparatus 400 further includes a deletion unit and a second setting unit, which are not shown in fig. 4.
And the deleting unit is configured to respond to the received data deleting command aiming at the linked list, and determine the position of the node indicated by the data deleting command and delete the data stored in the node indicated by the data deleting command.
A second setting unit configured to set pointers of a node preceding and succeeding the position of the node indicated by the data deletion command and the node indicated by the data deletion command.
In some optional implementations of the present embodiment, the apparatus 400 further includes a reset unit and a return unit, which are not shown in fig. 4.
And a resetting unit configured to reset the node indicated by the data delete command.
A returning unit configured to return the reset node to the node pool.
In some alternative implementations of the present embodiment, the pointers include a front pointer and a back pointer. The first setting unit 404 may be further configured to: setting a back pointer of a previous node of the insertion position to point to an idle node; setting a front pointer of a next node of the insertion position to point to a free node; the front pointer of the idle node is set to point to the previous node of the insertion position, and the back pointer of the idle node is set to point to the next node of the insertion position.
In some alternative implementations of the present embodiment, the pointers include a front pointer and a back pointer. The second setting unit described above is further configured to: setting a back pointer of a node before the position of the node indicated by the data deleting command to point to a node after the position of the node indicated by the data deleting command; setting a front pointer of a node next to the position of the node indicated by the data deleting command to point to a node previous to the position of the node indicated by the data deleting command; and deleting the front pointer and the back pointer of the node indicated by the data deleting command.
The apparatus for storing data provided in the foregoing embodiment of the present application may first allocate a node pool with consecutive memory block addresses to a pre-created linked list. And then when a data insertion command for the linked list is received, determining the insertion position indicated by the data insertion command, and acquiring the idle node from the node pool. Then, the data is written into the acquired free node. And finally, setting pointers of a previous node, a next node and a free node of the insertion position according to the free node. The device of the embodiment allocates the node pools with continuous memory block addresses for the linked list, and because the operating system in the execution main body acquires the memory addresses of the idle nodes from the node pools relatively continuously each time, the operating system can improve the probability of cache hit when accessing the linked list. Therefore, the speed of reading the linked list by the operating system is increased, the time for traversing the linked list is reduced, and the efficiency of traversing the linked list is improved.
It should be understood that units 401 to 404 recited in the apparatus 400 for storing data correspond to respective steps in the method described with reference to fig. 1. Thus, the operations and features described above for the method for storing data are equally applicable to the apparatus 400 and the units contained therein and will not be described again here.
Referring now to FIG. 5, shown is a block diagram of a computer system 500 suitable for use in implementing the apparatus of an embodiment of the present application. The apparatus shown in fig. 5 is only an example, and should not bring any limitation to the function and use range of the embodiments of the present application.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
To the I/O interface 505, AN input section 506 including a keyboard, a mouse, and the like, AN output section 507 including a keyboard such as a Cathode Ray Tube (CRT), a liquid crystal display (L CD), and the like, a speaker, and the like, a storage section 508 including a hard disk and the like, and a communication section 509 including a network interface card such as a L AN card, a modem, and the like, the communication section 509 performs communication processing via a network such as the internet, a drive 510 is also connected to the I/O interface 505 as necessary, a removable medium 511 such as a magnetic disk, AN optical disk, a magneto-optical disk, a semiconductor memory, and the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a machine-readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the method of the present application when executed by the Central Processing Unit (CPU) 501.
It should be noted that the computer readable medium described herein can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present application may be written in any combination of one or more programming languages, including AN object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present application may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes an allocation unit, an acquisition unit, a writing unit, and a first setting unit. Where the names of these elements do not in some cases constitute a limitation on the elements themselves, for example, an allocation element may also be described as an "element that allocates a contiguous pool of nodes to a pre-created linked list".
As another aspect, the present application also provides a computer-readable medium, which may be contained in the apparatus described in the above embodiments; or may be present separately and not assembled into the device. The computer readable medium carries one or more programs which, when executed by the apparatus, cause the apparatus to: allocating node pools with continuous memories to a pre-established linked list; in response to receiving a data insertion command for the linked list, determining an insertion position indicated by the data insertion command and acquiring an idle node from a node pool; writing data into the idle node; and setting pointers of a previous node, a next node and a free node of the insertion position according to the free node.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention herein disclosed is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the invention. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (10)

1. A method for storing data, comprising:
allocating node pools with continuous memory block addresses to a pre-established linked list;
in response to receiving a data insertion command for the linked list, determining an insertion position indicated by the data insertion command and acquiring a free node from the node pool;
writing data to the free node;
setting a previous node and a next node of the insertion position and a pointer of the idle node according to the idle node;
the acquiring of the idle node from the node pool includes: sequentially acquiring memory blocks as idle nodes according to the addresses of the memory blocks;
the method further comprises the following steps:
in response to receiving a data deletion command for the linked list, determining the position of a node indicated by the data deletion command and deleting data stored in the node indicated by the data deletion command;
setting pointers of a previous node and a next node of the position of the node indicated by the data deleting command and the node indicated by the data deleting command;
resetting the node indicated by the data deleting command;
and returning the reset nodes to the node pool.
2. The method of claim 1, wherein the method further comprises:
initializing the pre-created linked list.
3. The method of claim 1, wherein the pointers comprise a front pointer and a back pointer; and
the setting of the previous and subsequent nodes of the insertion position and the pointer of the idle node according to the idle node includes:
setting a back pointer of a previous node of the insertion position to point to the idle node;
setting a front pointer of a node next to the insertion position to point to the idle node;
setting a front pointer of the free node to point to a previous node of the insertion location and setting a back pointer of the free node to point to a next node of the insertion location.
4. The method of claim 1, wherein the pointers comprise a front pointer and a back pointer; and
the setting of the pointers of the nodes indicated by the data deletion command and the nodes before and after the position of the node indicated by the data deletion command includes:
setting a back pointer of a node before the position of the node indicated by the data deleting command to point to a node after the position of the node indicated by the data deleting command;
setting a front pointer of a node next to the position of the node indicated by the data deleting command to point to a node previous to the position of the node indicated by the data deleting command;
and deleting the front pointer and the back pointer of the node indicated by the data deleting command.
5. An apparatus for storing data, comprising:
the distribution unit is configured to distribute a node pool with continuous memory to a pre-established linked list;
an obtaining unit configured to determine an insertion position indicated by a data insertion command and obtain a free node from the node pool in response to receiving the data insertion command for the linked list;
a write unit configured to write data to the idle node;
a first setting unit configured to set a previous node, a next node, and a pointer of the free node of the insertion position, according to the free node;
the acquiring of the idle node from the node pool includes: sequentially acquiring memory blocks as idle nodes according to the addresses of the memory blocks;
the device further comprises:
a deleting unit configured to determine a position of a node indicated by the data deleting command and delete data stored in the node indicated by the data deleting command in response to receiving the data deleting command for the linked list;
a second setting unit configured to set pointers of a node previous to and subsequent to a position of a node indicated by the data deletion command and the node indicated by the data deletion command;
a reset unit configured to reset a node indicated by the data delete command;
a returning unit configured to return the reset node to the node pool.
6. The apparatus of claim 5, wherein the apparatus further comprises:
an initialization unit configured to initialize the pre-created linked list.
7. The apparatus of claim 5, wherein the pointers comprise a front pointer and a back pointer; and
the first setting unit is further configured to:
setting a back pointer of a previous node of the insertion position to point to the idle node;
setting a front pointer of a node next to the insertion position to point to the idle node;
setting a front pointer of the free node to point to a previous node of the insertion location and setting a back pointer of the free node to point to a next node of the insertion location.
8. The apparatus of claim 5, wherein the pointers comprise a front pointer and a back pointer; and
the second setting unit is further configured to:
setting a back pointer of a node before the position of the node indicated by the data deleting command to point to a node after the position of the node indicated by the data deleting command;
setting a front pointer of a node next to the position of the node indicated by the data deleting command to point to a node previous to the position of the node indicated by the data deleting command;
and deleting the front pointer and the back pointer of the node indicated by the data deleting command.
9. An apparatus for storing data, comprising:
one or more processors;
a storage device having one or more programs stored thereon,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-4.
10. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-4.
CN201810826491.3A 2018-07-25 2018-07-25 Method and apparatus for storing data Active CN109101438B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810826491.3A CN109101438B (en) 2018-07-25 2018-07-25 Method and apparatus for storing data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810826491.3A CN109101438B (en) 2018-07-25 2018-07-25 Method and apparatus for storing data

Publications (2)

Publication Number Publication Date
CN109101438A CN109101438A (en) 2018-12-28
CN109101438B true CN109101438B (en) 2020-07-28

Family

ID=64847385

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810826491.3A Active CN109101438B (en) 2018-07-25 2018-07-25 Method and apparatus for storing data

Country Status (1)

Country Link
CN (1) CN109101438B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113254364B (en) * 2021-05-24 2022-07-19 山东创恒科技发展有限公司 Information storage device for embedded system
CN115576501B (en) * 2022-12-06 2023-03-10 苏州浪潮智能科技有限公司 Node updating method, system and related device of RAID card

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101075214A (en) * 2007-06-28 2007-11-21 腾讯科技(深圳)有限公司 Method and system for managing memory
CN100517242C (en) * 2007-10-10 2009-07-22 中兴通讯股份有限公司 Quick memory application method
CN102760080B (en) * 2011-04-26 2016-08-03 腾讯科技(深圳)有限公司 A kind of method and apparatus of memory management
CN105095261A (en) * 2014-05-08 2015-11-25 北京奇虎科技有限公司 Data insertion method and device
CN105302739A (en) * 2014-07-21 2016-02-03 深圳市中兴微电子技术有限公司 Memory management method and device
US10133489B2 (en) * 2014-09-16 2018-11-20 Oracle International Corporation System and method for supporting a low contention queue in a distributed data grid
CN104239248B (en) * 2014-09-16 2017-06-06 国家计算机网络与信息安全管理中心 PCI E multiple buffer DMA data transfer methods
US9916359B2 (en) * 2015-06-01 2018-03-13 Sap Se Indexing dynamic hierarchical data
US20180181647A1 (en) * 2016-12-28 2018-06-28 Cerner Innovation, Inc. System and Method for Editing a Linked List

Also Published As

Publication number Publication date
CN109101438A (en) 2018-12-28

Similar Documents

Publication Publication Date Title
CN110008009B (en) Binding constants at runtime to improve resource utilization
CN111090628B (en) Data processing method and device, storage medium and electronic equipment
US9389997B2 (en) Heap management using dynamic memory allocation
US20200133875A1 (en) Method, apparatus and computer program product for managing data access
KR102594657B1 (en) Method and apparatus for implementing out-of-order resource allocation
US10789170B2 (en) Storage management method, electronic device and computer readable medium
CN110209493B (en) Memory management method, device, electronic equipment and storage medium
CN112130969A (en) Efficient execution of workloads specified via task graph
CN109101438B (en) Method and apparatus for storing data
CN116010300B (en) GPU (graphics processing Unit) caching method and device, electronic equipment and storage medium
CN111104347B (en) Heap memory block searching method, device, equipment and storage medium
US9875181B2 (en) Method and system for processing memory
CN109918381B (en) Method and apparatus for storing data
CN111208933A (en) Data access method, device, equipment and storage medium
US9891824B2 (en) Sub-block input/output (I/O) commands for storage device including byte stream buffer
US11144243B2 (en) Method and device for managing redundant array of independent disks and computer program product
US8429371B2 (en) System and method for robust and efficient free chain management
US9563363B2 (en) Flexible storage block for a solid state drive (SSD)-based file system
CN111897745B (en) Data storage method and device, electronic equipment and storage medium
CN110716946B (en) Method and device for updating feature rule matching library, storage medium and electronic equipment
CN110231983B (en) Data concurrent processing method, device and system, computer equipment and readable medium
US8966220B2 (en) Optimizing large page processing
CN116804915B (en) Data interaction method, processor, device and medium based on memory
US20230297426A1 (en) Reconfiguring register and shared memory usage in thread arrays
US9442835B1 (en) Dynamic memory allocation using suballocation of cell blocks

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant