CN112989130A - B + tree operating device - Google Patents

B + tree operating device Download PDF

Info

Publication number
CN112989130A
CN112989130A CN202110324501.5A CN202110324501A CN112989130A CN 112989130 A CN112989130 A CN 112989130A CN 202110324501 A CN202110324501 A CN 202110324501A CN 112989130 A CN112989130 A CN 112989130A
Authority
CN
China
Prior art keywords
node
tree
command
key
hit
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.)
Pending
Application number
CN202110324501.5A
Other languages
Chinese (zh)
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 Starblaze Technology Co ltd
Original Assignee
Beijing Starblaze 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 Starblaze Technology Co ltd filed Critical Beijing Starblaze Technology Co ltd
Priority to CN202110324501.5A priority Critical patent/CN112989130A/en
Publication of CN112989130A publication Critical patent/CN112989130A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9027Trees
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to a B + tree operating device, wherein the B + tree operating device is coupled with a CPU (central processing unit), the CPU extracts keywords from a command for operating a B + tree and operates the B + tree operating device by using the extracted keywords to search the B + tree; the B + tree operation device provides the search result to the CPU; the B + tree operation device includes: one or more search units; the search unit finds the hit node in the B + tree stored in the memory based on the received key.

Description

B + tree operating device
Technical Field
The present invention relates to information processing technology, and in particular, to a method for operating a B + tree in a SoC by combining software and hardware and a B + tree operating apparatus.
Background
The B + tree is a data structure, and is often used to store indexes in file systems, databases, and the like. Fig. 1 shows a B + tree. The B + tree includes a root node, a plurality of intermediate nodes, and a plurality of leaf nodes. Node 120 is the root node. Nodes 130, 132, and 134 are intermediate nodes, which are nodes that are neither root nor leaf nodes. The nodes (140, 142, 144 … … 150, 152, 154) are leaf nodes.
The middle node of the B + tree includes no more than m elements, with m being referred to as the rank of the B + tree. Each element of the root node and the intermediate node of the B + tree records a Key (Key) and a pointer to a subordinate node. For example, node 130 includes 3 elements, the first element having a key of 5 and a pointer to node 140, the second element having a key of 10 and a pointer to node 142, and the third element having a key of 20 and a pointer to node 144. The elements of the node are ordered by keyword.
In some embodiments, each element of the root and intermediate nodes records a pointer to a subordinate node, but not every element includes a key, but rather the root and intermediate nodes include one fewer key than the elements they include. For example, in node 120, the keyword "K: 5" may not be included, and in searching node 120, for a value less than the keyword "K: 28 "indicates the lower node 130 in the search result, and for a keyword no less than the keyword" K: 28 "and less than the keyword" K: 65 "indicates the lower node 134 in the search result.
The leaf nodes of the B + tree include no more than m elements. Each element of a leaf node records a Key (Key) and a Value (Value) corresponding to the Key. The elements of the leaf nodes are ordered by keyword. Thus, all keys of the B + tree have records in the leaf nodes, and the values corresponding to the keys can only be obtained from the leaf nodes. In order to ensure the balance of the B + tree, the number of elements of each non-root node of the B + tree is not less than m/2.
The elements of the non-root node of the B + tree are ordered by key, with the top element ordered, for example, to the left, and the key for that element present in the parent node of that node.
In the prior art, software builds and operates a B + tree in a memory, and a binary method is used to search for a keyword in the B + tree, for example. The dichotomy is the search algorithm with almost the best performance available to software, but in the big data era, the number of data items increases, so that the performance of the search algorithm of the software operating the B + tree cannot meet the requirement.
Disclosure of Invention
Faster implementation of B + tree operations is required. Hardware circuitry is required to assist software in performing B + tree operations. The searching process of the B + tree operation is completed by hardware, and the software controls the B + tree searching hardware to complete the complete operation of the B + tree. Therefore, the task load of a CPU (central processing unit) executing software is effectively reduced, and the execution efficiency of the B + tree operation is improved.
According to a first aspect of the present application, there is provided a first storage device according to the first aspect of the present application, comprising: CPU and B + tree operation device; the CPU extracts keywords from the command for operating the B + tree, and operates the B + tree operating device by using the extracted keywords to search the B + tree; the B + tree operation means supplies the search result to the CPU.
According to a first storage device of a first aspect of the present application, there is provided a second storage device of the first aspect of the present application, wherein the B + tree operation means includes: one or more search units; the search unit finds the hit node in the B + tree based on the received key.
The first or second storage device according to the first aspect of the present application provides the third storage device according to the first aspect of the present application, further comprising a memory storing one or more B + trees.
According to the second or third storage device of the first aspect of the present application, there is provided the fourth storage device of the first aspect of the present application, wherein the search unit compares the extracted key with respective keys of nodes of the B + tree to search for the hit node.
According to one of the first to fourth memory devices of the first aspect of the present application, there is provided the fifth memory device of the first aspect of the present application, wherein if the command to operate the B + tree is a search command, the CPU obtains a command processing result according to the search result to supply the command processing result to the host that issued the command to operate the B + tree.
According to one of the first to fourth memory devices of the first aspect of the present application, there is provided the sixth memory device of the first aspect of the present application, wherein if the command to operate the B + tree is an insert command or a delete command, the CPU updates the B + tree based on the command to operate the B + tree and the search result.
According to a sixth storage device of the first aspect of the present application, there is provided the seventh storage device of the first aspect of the present application, wherein if the command to operate the B + tree is an insert command or a delete command, the search result indicates a node to be inserted or deleted, or a node to be inserted or deleted and a keyword thereof.
According to a sixth or seventh storage device of the first aspect of the present application, there is provided the eighth storage device of the first aspect of the present application, wherein if the command to operate the B + tree is an insert command and the search result indicates a hit keyword of a hit node, the CPU updates a value corresponding to the hit keyword to a value indicated by the insert command.
According to a sixth or seventh storage device of the first aspect of the present application, there is provided the ninth storage device of the first aspect of the present application, wherein if the command to operate the B + tree is an insert command, the search result indicates a hit node and a miss key, the CPU adds the key or the key indicated by the insert command together with a corresponding value to the hit node.
According to a ninth storage apparatus of the first aspect of the present application, there is provided the tenth storage apparatus of the first aspect of the present application, wherein if the number of keys included in the hit node is not less than the threshold, the CPU splits the hit node into two nodes, and adds a key or a key indicated by the insert command together with a corresponding value to one of the two nodes.
According to a tenth storage device of the first aspect of the present application, there is provided the eleventh storage device of the first aspect of the present application, wherein the key indicated by the insert command is added to one of the two nodes after the split according to a position at which its value is sorted in the hit node.
According to a tenth or eleventh storage device of the first aspect of the present application, there is provided the twelfth storage device of the first aspect of the present application, wherein in response to a node split occurring at the hit node, a key indexing the split new node is added to a common parent node of the two nodes after the split.
According to a twelfth storage device of the first aspect of the present application, there is provided the thirteenth storage device of the first aspect of the present application, wherein in response to addition of a key of a new node of index splitting to a parent node, the CPU indicates completion of the insert command processing to a host that issues an operation B + tree.
According to a twelfth storage device of the first aspect of the present application, there is provided the fourteenth storage device of the first aspect of the present application, wherein if the common parent node of the hit node or the two split nodes is the root node, and the number of keys included in the common parent node of the hit node or the two split nodes is not less than the threshold value, the CPU indicates to the host that issued the operation B + tree that the insert command processing failed.
According to a sixth or seventh storage device of the first aspect of the present application, there is provided the fifteenth storage device of the first aspect of the present application, wherein if the command to operate the B + tree is a delete command, the search result indicates a hit keyword of the hit node, and the CPU deletes the hit keyword from the hit node.
According to a fifteenth storage device of the first aspect of the present application, there is provided the sixteenth storage device of the first aspect of the present application, wherein in response to deletion of the hit key in the hit node, the CPU instructs completion of the deletion command processing to the host that issued the command to operate the B + tree.
According to a fifteenth or sixteenth storage device of the first aspect of the present application, there is provided the seventeenth storage device of the first aspect of the present application, wherein if the number of keys of the hit node is not more than the first threshold and the sum of keys of the hit node and its right sibling node is more than the order of the B + tree, the CPU moves the key with the top ranking of the right sibling node to the hit node and deletes the hit key from the hit node.
According to a seventeenth storage device of the first aspect of the present application, there is provided the eighteenth storage device of the first aspect of the present application, wherein, in response to moving the top-ranked key of the right sibling to the hit node, the key indexing the right sibling among the parents of the right sibling is updated.
According to an eighteenth storage device of the first aspect of the present application, there is provided the nineteenth storage device of the first aspect of the present application, wherein the CPU indicates completion of the deletion command processing to the host that issued the command to operate the B + tree, in response to updating the key that indexes the right sibling node among the parent nodes of the right sibling nodes.
According to one of the seventeenth to nineteenth storage devices of the first aspect of the present application, there is provided the twentieth storage device of the first aspect of the present application, wherein if a sum of keys of the hit node and its right sibling node is not more than the order of the B + tree and a sum of the numbers of keys of the hit node and its left sibling node is more than the order of the B + tree, the CPU moves the key that is the last in the ranking of the left sibling node to the hit node as the key that is the first in the ranking of the hit node, and deletes the hit key from the hit node.
According to a twentieth storage device according to the first aspect of the present application, there is provided the twenty-first storage device according to the first aspect of the present application, wherein in response to moving the last-ranked key of the left sibling to the hit node as the top-ranked key of the hit node, the key indexing the hit node in the parent node of the hit node is updated.
According to a twentieth storage device of the first aspect of the present application, there is provided the twenty-second storage device of the first aspect of the present application, wherein in response to deleting the hit key from the hit node and updating the key of the node that is hit in the index from the parent node of the hit node, the CPU instructs the host that issued the command to operate the B + tree that the deletion command processing is completed.
According to one of the twentieth to twenty-second storage devices of the first aspect of the present application, there is provided the twenty-third storage device of the first aspect of the present application, wherein if a sum of the numbers of keys of the hit node and its left sibling node is not more than the order of the B + tree, the hit node and one of its sibling nodes are merged.
According to a twenty-third storage device of the first aspect of the present application, there is provided the twenty-fourth storage device of the first aspect of the present application, wherein if the hit node is merged with its left sibling node, the parent node of the deleted node is the new hit node, the key of the deleted node is indexed as the new hit key, and the new hit key is deleted from the new hit node.
A twenty-fourth storage device according to the first aspect of the present application provides the twenty-fifth storage device according to the first aspect of the present application, wherein in response to deletion of a key indexing a deleted node from the root node, the CPU indicates completion of the deletion command processing to the host that issued the command to operate the B + tree.
According to a sixth or seventh storage device of the first aspect of the present application, there is provided the twenty-sixth storage device of the first aspect of the present application, wherein if the command to operate the B + tree is a delete command and the search result indicates that the searched keyword is not included in the B + tree, the CPU indicates that the delete command processing has failed to the host that issued the command to operate the B + tree.
According to a second aspect of the present application, there is provided a method of operating a first B + tree according to the second aspect of the present application, comprising the steps of: extracting keywords from the command for operating the B + tree, and operating the B + tree operating device by using the extracted keywords to search the B + tree; and receives the search result provided by the B + tree operator.
According to the first B + tree operation method of the second aspect of the present application, there is provided the second B + tree operation method of the second aspect of the present application, wherein the hit node is found in the B + tree based on the extracted keyword.
According to the first or second B + tree operation method of the second aspect of the present application, there is provided the third B + tree operation method of the second aspect of the present application, wherein the extracted keywords are compared with respective keywords of nodes of the B + tree to search for a hit node.
According to the third B + tree operation method of the second aspect of the present application, there is provided the fourth B + tree operation method of the second aspect of the present application, wherein if the extracted keyword is a non-leaf node compared with the keyword of the B + tree, the keyword of the next node is obtained according to the hit keyword; if the hit keyword is a leaf node, a search result is obtained according to the hit keyword.
According to one of the first to fourth B + tree operation methods of the second aspect of the present application, there is provided the fifth B + tree operation method of the second aspect of the present application, wherein if the command to operate the B + tree is a search command, a command processing result is obtained according to the search result to provide the command processing result to the host that issued the command to operate the B + tree.
According to a fifth B + tree operation method of the second aspect of the present application, there is provided the sixth B + tree operation method of the second aspect of the present application, wherein the pointer or address indicating that the search command is to acquire data acquires the data according to the search result to obtain the command processing result.
According to one of the first to sixth B + tree operation methods of the second aspect of the present application, there is provided the seventh B + tree operation method of the second aspect of the present application, wherein if the command to operate the B + tree is an insert command or a delete command, the B + tree is updated according to the command to operate the B + tree and the search result.
According to a seventh B + tree operation method of the second aspect of the present application, there is provided the eighth B + tree operation method of the second aspect of the present application, wherein if the command to operate the B + tree is an insert command or a delete command, the search result indicates a node to be inserted or deleted, or an inserted or deleted node and a keyword thereof.
According to a seventh or eighth B + tree operation method of the second aspect of the present application, there is provided the ninth B + tree operation method of the second aspect of the present application, wherein if the command to operate the B + tree is an insert command and the search result indicates a hit key of the hit node, a value corresponding to the hit key is updated to a value indicated by the insert command.
According to a seventh or eighth B + tree operation method of the second aspect of the present application, there is provided the tenth B + tree operation method of the second aspect of the present application, wherein if the command to operate the B + tree is an insert command, the search result indicates that a node is hit and a keyword is not hit, the keyword or the keyword indicated by the insert command is added to the hit node together with a corresponding value.
According to a tenth B + tree operation method of the second aspect of the present application, there is provided the eleventh B + tree operation method of the second aspect of the present application, wherein if the number of keys included in the hit node is not less than the threshold, the hit node is split into two nodes, and the key or the key indicated by the insert command is added to one of the two nodes together with the corresponding value.
According to an eleventh B + tree operation method of the second aspect of the present application, there is provided the twelfth B + tree operation method of the second aspect of the present application, wherein a key indicated by the insert command is added to one of the two nodes after the split depending on a position at which its value is sorted in the hit node.
According to an eleventh or twelfth B + tree operation method of the second aspect of the present application, there is provided the thirteenth B + tree operation method of the second aspect of the present application, wherein in response to a node split occurring at the hit node, a key indexing the split new node is added to a common parent node of the two nodes after the split.
According to a thirteenth B + tree operation method of the second aspect of the present application, there is provided the fourteenth B + tree operation method of the second aspect of the present application, wherein in response to addition of a key of a new node of the index split to the parent node, completion of the insert command processing is indicated to the host that issued the operation B + tree.
According to a thirteenth B + tree operation method of the second aspect of the present application, there is provided the fifteenth B + tree operation method of the second aspect of the present application, wherein if the common parent node of the hit node or the two split nodes is the root node and the number of keys contained in the common parent node of the hit node or the two split nodes is not less than the threshold, a failure of the insert command process is indicated to the host that issued the operation B + tree.
According to a seventh or eighth B + tree operation method of the second aspect of the present application, there is provided the sixteenth B + tree operation method of the second aspect of the present application, wherein if the command to operate the B + tree is a delete command, the search result indicates a hit keyword of the hit node, and the hit keyword is deleted from the hit node.
According to a sixteenth B + tree operation method of the second aspect of the present application, there is provided the seventeenth B + tree operation method of the second aspect of the present application, wherein, in response to deletion of the hit key in the hit node, completion of the deletion command processing is indicated to the host that issued the command to operate the B + tree.
According to a sixteenth or seventeenth B + tree operation method of the second aspect of the present application, there is provided the eighteenth B + tree operation method of the second aspect of the present application, wherein if the number of keys of the hit node is not more than the first threshold and the sum of the keys of the hit node and its right sibling is more than the order of the B + tree, the key with the top ranking of the right sibling is moved to the hit node, and the hit key is deleted from the hit node.
According to an eighteenth B + tree operation method of the second aspect of the present application, there is provided the nineteenth B + tree operation method of the second aspect of the present application, wherein, in response to moving the top-ranked key of the right sibling to the hit node, the key indexing the right sibling among the parents of the right sibling is updated.
According to a nineteenth B + tree operation method of the second aspect of the present application, there is provided the twentieth B + tree operation method of the second aspect of the present application, wherein in response to updating a key of an index right sibling node among parents of the right sibling nodes, completion of the deletion command processing is instructed to a host that issued a command to operate the B + tree.
According to one of the eighteenth to twenty-fifth B + tree operation methods of the second aspect of the present application, there is provided the twenty-first B + tree operation method of the second aspect of the present application, wherein if a sum of keys of a hit node and its right sibling node is not more than the order of the B + tree and a sum of numbers of keys of the hit node and its left sibling node is more than the order of the B + tree, the last key ranked to the left sibling node is moved to the hit node, the top key ranked to the hit node is ranked, and the hit key is deleted from the hit node.
According to a twenty-first B + tree operation method of the second aspect of the present application, there is provided the twenty-second B + tree operation method of the second aspect of the present application, wherein, in response to moving the last-ranked key of the left sibling node to the hit node as the top-ranked key of the hit node, the key of the hit node indexed in the parent node of the hit node is updated.
According to a twenty-first B + tree operation method of the second aspect of the present application, there is provided the twenty-third B + tree operation method of the second aspect of the present application, in response to deleting a hit key from a hit node and updating a key of an index of the hit node in a parent node of the hit node, indicating completion of a deletion command process to a host that issues a command to operate a B + tree.
According to one of the twenty-first to twenty-third B + tree operation methods of the second aspect of the present application, there is provided the twenty-fourth B + tree operation method of the second aspect of the present application, wherein if a sum of the numbers of keys of the hit node and its left sibling node is not more than the order of the B + tree, the hit node and one of its sibling nodes are merged.
According to a twenty-fourth B + tree operation method of the second aspect of the present application, there is provided the twenty-fifth B + tree operation method of the second aspect of the present application, wherein if a hit node and its left sibling node are merged, a parent node of the deleted node is taken as a new hit node, a key of the deleted node is indexed as a new hit key, and the new hit key is deleted from the new hit node.
According to a twenty-fifth B + tree operation method of the second aspect of the present application, there is provided the twenty-sixth B + tree operation method of the second aspect of the present application, wherein in response to deletion of a key indexing a deleted node from a root node, completion of processing of a deletion command is indicated to a host that issued a command to operate the B + tree.
According to a seventh or eighth B + tree operation method of the second aspect of the present application, there is provided the twenty-seventh B + tree operation method of the second aspect of the present application, wherein if the command to operate the B + tree is a delete command and the search result indicates that the searched keyword is not included in the B + tree, a deletion command processing failure is indicated to the host that issued the command to operate the B + tree.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings can be obtained by those skilled in the art according to the drawings.
FIG. 1 illustrates a B + tree;
FIG. 2 illustrates a block diagram of a B + tree manipulation apparatus according to an embodiment of the present application;
FIG. 3A is a schematic diagram illustrating operation of a B + tree using a B + tree operation apparatus according to an embodiment of the present application;
FIG. 3B shows a flow chart for operating a B + tree using a B + tree operating device according to an embodiment of the present application;
FIG. 4 is a flowchart of a B + tree operation device operating a plurality of B + trees according to an embodiment of the present application;
FIG. 5A illustrates a block diagram of a B + tree manipulation device according to an embodiment of the present application;
FIG. 5B illustrates a block diagram of a B + tree manipulation device according to yet another embodiment of the present application;
FIG. 5C illustrates a flow diagram for processing a search command according to the embodiment of FIG. 5A or FIG. 5B;
FIG. 6A illustrates a block diagram of a B + tree manipulation device according to yet another embodiment of the present application;
FIG. 6B illustrates a flow diagram for processing an insert command according to the embodiment of FIG. 6A;
FIG. 7A illustrates a block diagram of a B + tree manipulation device according to yet another embodiment of the present application;
FIG. 7B illustrates a flow diagram for processing a delete command according to the embodiment of FIG. 7A;
FIG. 8 illustrates a block diagram of a B + tree manipulation device according to yet another embodiment of the present application;
FIG. 9 illustrates a flow diagram according to the embodiment of FIG. 8;
FIG. 10 is a flowchart of processing a B + tree insert command according to the embodiment of FIG. 8;
FIG. 11 is a flowchart of processing a B + tree delete command according to the embodiment of FIG. 8.
Detailed Description
The technical solutions in the embodiments of the present application are clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Fig. 2 shows a block diagram of a B + tree manipulation apparatus according to an embodiment of the present application.
The B + tree manipulation device according to an embodiment of the present application includes a command interface 210, one or more search units (220 … … 22n), a data cache 230, a DMA unit 240, an extended command processing unit 270, a bus 280, and a memory 290. Memory 290 stores one or more B + trees (B + tree 0 … … B + tree n).
An external unit such as a CPU operates the B + tree operating means to accomplish acceleration of the B + tree operation. The CPU provides commands to operate the B + tree to the B + tree operating device through command interface 210. The command to operate the B + tree (hereinafter, simply referred to as a command) includes a command to search the B + tree for a specified Key (Key) (referred to as a search command), a command to insert the specified Key into the B + tree (referred to as an insert command), and/or a command to delete the specified Key from the B + tree (referred to as a delete command), and the like. The command also indicates, for example, one of the B + trees to be accessed, a pointer or value associated with a key, etc., where keys of root or intermediate node records of the B + tree are associated with the pointer and keys of leaf node records of the B + tree are associated with the value.
The command interface 210 receives a command provided from an external unit and provides the command to the search unit and/or the extended command processing unit. The result of the command processing by the search unit and/or the extended command processing unit is provided to the command interface 210, so that the external unit obtains the result of the command processing through the command interface 210.
A search unit (220 … … 22n) searches the B + tree based on the keyword obtained from the command. The search unit (220 … … 22n) accesses the memory 290 through the bus 280 to retrieve the key of the node of the B + tree recorded by the memory 290 to identify whether the key in the command hits the key of the node to process the search command.
The data cache 230 stores one or more keys for nodes of the B + tree, or also stores pointers/values corresponding to the keys. DMA unit 240 moves data between data cache 230 and memory 290, the moved data including keys and/or pointers/values corresponding to the keys of the nodes of the B + tree. The extended command processing unit 270 accesses the data cache 230. DMA unit 240 accesses memory 290 through bus 280. Alternatively, the extended command processing unit 270 accesses the memory 290 through the bus 280.
Fig. 3A shows a schematic diagram of operating a B + tree using a B + tree operating apparatus according to an embodiment of the present application.
The command interface unit 310 of the B + tree operation device includes, for example, a command receiving buffer 312, a command result buffer 314, command queues (360, 361 … …, 36n) corresponding to the search units one by one, an extended command queue 316, and a search result queue 318. The command receiving buffer 312 and/or the command result buffer 314 are provided in the form of queues, FIFOs (first-in-first-out buffers), shared memories, and the like. Optionally, the command queues (360, 361 … …, 36n), extended command queue 316, and search result queue 318 are provided in shared memory, FIFO, or the like.
The external unit populates the command reception cache 312 with commands to operate the B + tree to the B + tree operating device, and acquires the processing results of the commands from the command result cache 314. The commands in the command receiving cache 312, according to the B + tree they are to operate on, are added to the command queue associated with the search unit corresponding to the B + tree to provide the commands to the search unit.
After the search is complete (350), for the search command (352), the search unit presents the command processing results and adds to the command results cache 314. For an insert command or a delete command (352), after the search unit performs a search on the B + tree based on the keywords in the command, the search unit also adds the command to the extended command queue 316 and the results of the search on the B + tree to the search results queue 318. As can be appreciated, commands in the extended command queue 316 are associated with search results in the search results queue 318 such that the search results with which the commands are associated are simultaneously retrieved from each of the extended command queue 316 and the search results queue 318.
The extended command processing unit 340 retrieves commands and search results from the extended command queue 316 and search results queue 318 and further processes the commands, such as adding or removing keywords to or from the B + tree. After further processing of the command by the extended command processing unit 340 is completed (342), the result of the processing of the command is added to the command result cache 314, so that the external unit can obtain the result of the processing of the command from the command result cache 314.
Fig. 3B shows a flow chart for operating a B + tree using a B + tree operating device according to an embodiment of the present application.
In response to the command reception buffer 312 being added with a command or periodically checking that the command reception buffer 312 is added with a command, a command provided from the external unit to the B + tree processing apparatus is acquired from the command reception buffer 312 (370). The command is added to one of the command queues (360, 361 … … 36n) according to the B + tree to be accessed by the fetched command. Optionally, the retrieved command is provided to an available search unit (372), or a search unit with a low workload, without selecting the search unit depending on the B + tree to which the command is to access.
Commands in the command queue (360, 361 … … 36n) are provided to a search unit coupled thereto. The search unit searches the B + tree (374) according to the key word (and the B + tree) indicated by the command and obtains a search result. If the command is a search command (376), the results of the processing of the command (search results) are added to the command results cache 314 (384). If the command is not a search command (e.g., is an insert command or a delete command) (376), the results of the processing of the command (search results) are added to the search results queue 318(378) and the command is added to the extended command queue 316 (380).
The extended command processing unit 342 retrieves the command from the extended command queue 316 and further processes the command (382). For example, for an insert command, a key specified by the command (along with a corresponding value) is added to the node indicated by the search result, or for a delete command, a key specified by the command (along with a corresponding value) is deleted from the node indicated by the search result. After further processing of the command by the extended command processing unit 342 is completed, the command processing result is added to the command result (e.g., command processing success or failure) cache 314 (384).
Fig. 4 is a flowchart of a B + tree operating apparatus operating a plurality of B + trees according to an embodiment of the present application.
The external unit populates the command receiving cache 312 of the command interface 310 with commands to provide the B + tree operating device with commands to operate the B + tree (see also fig. 3A). In response to the command receiving cache 312 being non-empty (410), a command provided by the external unit to the B + tree processing device is retrieved from the command receiving cache 312 (420). The command is added to one of the command queues (360, 361 … … 36n) according to the B + tree to be accessed by the fetched command. By way of example, the command queue (360, 361 … … 36n) is set with an identification derived from the B + tree that the command it contains accesses; or the search unit corresponding to the command queue is set with an identification derived from the B + tree accessed by the command it is processing. From the identification of the B + tree accessed by the command retrieved from the command receiving cache 312, it is identified whether there is an identification of the B + tree accessed by the command being processed by the search unit that has the same identification as the pending command retrieved from the command receiving cache (430). If the identification of the command to be processed is the same as the identification of the B + tree accessed by the command being processed by one of the search units (denoted as search unit A), the command to be processed is sent to the command queue corresponding to the search unit A (460). If the identity of the command to be processed is not the same as the identity of the B + tree accessed by the command being processed by any of the search units, then a search unit is assigned to the command to be processed (440), and the command to be processed is provided to the command queue corresponding to the search unit assigned to the command queue (450). By way of example, at step 440, the free search unit for the currently unprocessed command is selected as the allocated search unit. And if no idle searching unit exists currently, selecting the idle searching unit as the distributed searching unit after the searching unit becomes idle after finishing processing the command. As yet another example, in step 440, a search unit with a low workload is selected as the assigned search unit, wherein the load of the search unit is derived according to the number of commands included in the command queue corresponding to the search unit.
FIG. 5A shows a block diagram of a B + tree operation apparatus according to an embodiment of the present application.
The B + tree manipulation device according to an embodiment of the present application includes a command interface 510, one or more search units (520 … … 52n), a data cache 530, a DMA unit 540, a bus 580, and a memory 590.
Memory 590 stores one or more B + trees (B + tree 0 … … B + tree n). And data cache 530 stores one or more nodes of the operated-on B + tree (node 0 … … node n).
An external unit such as a CPU operates the B + tree operating means to accomplish acceleration of the B + tree operation. The CPU provides commands to operate the B + tree to the B + tree operating device through command interface 210.
The command interface 210 receives a search command provided from an external unit and provides the search command to one of the search units (520 … … 52 n). The result of the search unit's processing of the command is provided to the command interface 510, so that the external unit obtains the result of the processing of the command through the command interface 510.
A search unit (520 … … 52n) searches the B + tree based on the keyword obtained from the command. The search unit (520 … … 52n) acquires each key of a node of the B + tree from the data cache 530, compares the search command with each key of the node to identify a hit key, and acquires a key of a next node from the data cache 530 according to the hit key or, when the current node is a leaf node, acquires a processing result of the search command according to the hit key.
If the node to be accessed by the search unit is not included in data cache 530, data cache 530 may load the node to be accessed from memory 590 into data cache 530 via bus 580 using DMA unit 540.
FIG. 5B shows a block diagram of a B + tree operation device according to yet another embodiment of the present application.
In contrast to the embodiment shown in FIG. 5A, the search unit (570 … … 57n) of the B + tree operator of the embodiment of FIG. 5B obtains the node of the B + tree to be accessed (node 0 … … node n) directly from memory 590 over bus 580, without using data cache 530.
FIG. 5C illustrates a flow diagram for processing a search command according to the embodiment of FIG. 5A or FIG. 5B.
In response to obtaining the search command, one of the search units (520 … … 52n) obtains a root node of the B + tree to be accessed as an initial current node in processing the search command according to the search command. The search unit acquires the number of keywords of the current node (560). The keys of the nodes are placed in order in the memory 590 or the data cache 530, such that the number of keys of the node is used to determine the storage locations of the keys of the node, and one or more keys of the current node are read (562). The search unit compares the key indicated by the search command with the key of the node to obtain a hit key (564). For example, if the keyword indicated by the search command is ordered between the ith keyword and the (i + 1) th keyword of the current node, the search command hits the ith keyword of the current node.
The search unit identifies whether the current node is a leaf node (566). If the current node is a leaf node (566), a search result is generated based on the key of the hit current node and the search result is saved in a result queue of the command interface (569). If the current node is not a leaf node (566), the next node is obtained according to the key of the hit current node and is taken as the current node (568), and the process is returned to the step 560 to continue the process for the new current node.
FIG. 6A shows a block diagram of a B + tree operation device according to yet another embodiment of the present application.
The B + tree operation device according to the embodiment of the present application includes a command interface 610, one or more search units (620 … … 62n), a data cache 630, a DMA unit 640, an extended command processing unit 670, a bus 680, and a memory 690.
Memory 690 stores one or more B + trees (B + tree 0 … … B + tree n). For example, node 692 is the root node of the B + tree, and nodes (693, 694, and 695) are children of node 692.
The search unit (620 … … 62n) processes the search command. The extended command processing unit 670 processes an insert command and/or a delete command.
The extended command processing unit 670 obtains, for example, an insert command from the command interface 610 (see also FIG. 3, e.g., through the extended command queue 316). Based on the obtained insert command, the extended command processing unit 670 maintains one or more keys of the updated node in the data cache 630 and instructs the DMA unit 640 to move the one or more keys in the data cache 630 to the memory 690 to update the node in the memory 690 and/or to move the one or more keys of the node from the memory 690 to the data cache 630 via the DMA unit 640. The extended command processing unit 670 provides the command processing result to the command interface 610 in response to the insertion command being processed, so that the external unit obtains the processing result of the command through the command interface 610.
FIG. 6B illustrates a flow diagram for processing an insert command according to the embodiment of FIG. 6A.
Referring also to fig. 3A and 3B, the insert command is processed in two phases. A first stage of searching the insertion command by a search unit (620 … … 62n) to find a leaf node into which the keyword is to be inserted; in the second stage, a key is inserted into a leaf node by the extended command processing unit 670, and one or more upper nodes are updated in response to a possible node split.
Referring to FIG. 6B, the flow shown begins with obtaining the current node indicated in the search results of the search unit (650), it being understood that the insert operation of the B + tree by the extended command processing unit 670 begins with the leaf node being hit.
The extended command processing unit 670 obtains the number of keys of the current node (652) to determine whether node splitting is to occur after the current node is inserted with a new key (654). In the B + tree insertion operation, if the number of keys of a node is greater than a threshold, the node needs to be split into two nodes.
If the number of keys of the current node is identified to be not greater than the threshold (654) (i.e., no node splitting is caused after a new key is inserted into the current node), the key to be inserted indicated by the insert command is written into the data cache 630 (656). The extended command processing unit 670 also identifies all keys of the current node that are ordered after the key to be inserted (657) and instructs the DMA unit 640 to move those keys from the memory 690 to the data cache 630 (658). Optionally, the key moved from memory 690 is placed in order in data cache 630 after the key to be inserted. The extended command processing unit 670 updates 659 the current node in the memory 690 with all keys in the data cache 630 having a key to be inserted and a key of the current node ordered after the key to be inserted. Specifically, all the keys of the current node in the memory 690 ordered after the key to be inserted are overwritten with the key to be inserted in the data cache 630 and all the keys of the current node ordered after the key to be inserted to complete the processing of the insert command.
Returning to step 654, if the number of keys of the current node is identified to be greater than the threshold, it means that the current node needs to be split into two nodes after the key is inserted. Generally, when a node is split, the first half of the keys in the sequence belong to the front node, and the second half of the keys in the sequence belong to the rear node. The two nodes formed by splitting the current node are referred to as a front node and a back node respectively.
And determining whether the key to be inserted belongs to a front node or a rear node after the current node is split according to the position of the key to be inserted in the key of the current node (655). If the key to be inserted belongs to the front node (655), the key to be inserted is written into the data cache 630 (660). The extended command processing unit 670 also identifies all keys (661) of the current node ordered after the key to be inserted, reads out all keys of the current node ordered after the key to be inserted from the memory 690 and writes them into the data cache 630(662), writes the key of the previous node after the split in the data cache into the memory 690 to update the current node (663) as the previous node after the split, and writes the key of the next node after the split in the data cache 630 into the memory 690(664) as the next node after the split.
And as the splitting of the node occurs, the common parent node of the front node and the rear node after the splitting needs to be updated so as to record the keywords and the corresponding indexes (pointers) for indexing the front node and the rear node in the parent node. For this purpose, the extended command processing unit 670 takes the parent node as the current node (669), takes, for example, the top-ranked key of the following node as the key to be inserted, and returns to step 652.
Returning to step 655, if the key to be inserted belongs to the back node (655), the key to be inserted is written into the data cache 630 (665). Extended command processing unit 670 also identifies all keys belonging to the back node for the current node (666), writes all keys belonging to the back node to data cache 630(667), and clears the read keys in the current node to generate a split front node.
As an example, the extended command processing unit 670 sorts the read-out keys belonging to the back node together with the key to be inserted, and writes all the sorted keys into the memory 690 to generate the back node (668).
As still another example, the extended command processing unit 670 sequentially writes all the keys to be inserted, which are read out and have the top of the ranking of the keys belonging to the following node to the current node, before the key to be inserted, which is written in the data cache 630, and sequentially writes the keys to be inserted, which are read out and have the top of the ranking of the keys belonging to the following node, to the last of the ranking of the keys belonging to the following node, which is written in the data cache 630, after the key to be inserted. In this way, the read-out keywords belonging to the rear nodes and the keywords to be inserted are sequenced together.
And since the splitting of the node has occurred, the extended command processing unit 670 takes the common parent node of the front node and the rear node after the splitting as the current node (669), takes, for example, the top-ranked key of the rear node as the key to be inserted, and returns to step 652.
Those skilled in the art will appreciate that in inserting a key into the B + tree, the value of the leaf node associated with the key or a pointer to a lower level node is also inserted.
Fig. 7A shows a block diagram of a B + tree operation apparatus according to still another embodiment of the present application.
The B + tree operation device according to the embodiment of the present application includes a command interface 710, one or more search units (720 … … 72n), a data cache 730, a DMA unit 740, an extended command processing unit 770, a bus 780, and a memory 790.
Memory 790 stores one or more B + trees (B + tree 0 … … B + tree n). For example, node 792 is the root node of the B + tree and nodes (794, 796, and 798) are children of node 792.
The search unit (720 … … 72n) processes the search command. The extended command processing unit 770 processes a delete command and/or an insert command.
Extended command processing unit 770 obtains, for example, a delete command from command interface 710 (see also FIG. 3, e.g., through extended command queue 316). Based on the obtained delete command, extended command processing unit 770 maintains one or more keys for the updated node in data cache 730 and instructs DMA unit 740 to move the one or more keys in data cache 730 to memory 790 to update the node in memory 790 and/or to move the one or more keys for the node from memory 790 to data cache 730 via DMA unit 740. The extended command processing unit 770 provides the command processing result to the command interface 710 in response to the deletion command being processed, so that the external unit obtains the processing result of the deletion command through the command interface 710.
FIG. 7B illustrates a flow diagram for processing a delete command according to the embodiment of FIG. 7A.
Referring also to fig. 3A and 3B, the delete command is processed in two stages. A first stage of performing a search by a search unit (720 … … 72n) according to a delete command, finding a leaf node that hits a key to be inserted; in the second stage, the key is deleted from the hit leaf node and one or more upper nodes are possibly updated by the extended command processing unit 770.
Referring to FIG. 7B, the flow shown begins with obtaining the current node and the key to be deleted indicated in the search results for the search unit (750). It is to be understood that the delete operation of the extended command processing unit 770 on the B + tree starts with the hit leaf node.
The extended command processing unit 770 identifies whether the keyword to be deleted is the top-ranked keyword in the current node (752). If the key to be deleted is the top-ranked key of the current node, deletion of the key causes an update to the parent node of the current node (the node immediately above the current node), modifying the key of the parent node that indexes the current node, so that the key of the parent node is updated to the next key of the current node key that is ranked after the key to be deleted (758). And also identifies whether the updated key in the parent node is the top-ranked key (759). If the updated key in the parent node is also the top-ranked key of the parent node, go back to the step 758 to update the key in the previous node of the parent node that indexes the parent node.
If the key to be deleted is identified as not the top-ranked key in the current node in step 752 or the updated key in the parent node is identified as not the top-ranked key of the parent node in step 759, go to step 760. Extended command processing unit 770 identifies all keys following the key to be deleted for the current node (760), moves all identified keys from memory 790 to data cache 730(762) via DMA unit 740, and updates the current node in memory 790 with all keys following the key to be deleted in data cache 730 (764) to complete the deletion of the key to be deleted. For example, all keys of the current node in memory 790 beginning with the node to be deleted and ending with the last are replaced with all keys following the key to be deleted in data cache 730.
Alternatively, deletion of a key to a B + tree node may cause a merge of nodes. For example, after step 764, if the updated number of keys for the current node is less than the threshold, a merge of the nodes will result. For example, the current node is merged with the siblings of the current node, and the key of the parent node of the current node, which indexes the nodes participating in the merging, is modified to index the merged node.
Those skilled in the art will appreciate that in deleting a key from the B + tree, the value of a pointer to a lower level node or leaf node associated with the key is also deleted.
FIG. 8 shows a block diagram of a B + tree manipulation device according to yet another embodiment of the present application.
The CPU800 is coupled to a command interface 810 of the B + tree operator to provide commands to the B + tree operator and obtain search results provided by the B + tree operator. The B + tree manipulation device includes a command interface 810, one or more search units (820 … … 82n), and a data cache 830. The B + tree operation device and CPU800 are also coupled to DMA unit 840 and memory 890.
Memory 890 stores one or more B + trees (B + tree 0 … … B + tree n). And data cache 830 stores one or more nodes of the B + tree that are operated on (node 0 … … node n).
The CPU800 generates a command to operate the B + tree including a command to search for a specified Key (Key) in the B + tree (referred to as a search command), a command to insert the specified Key into the B + tree (referred to as an insert command), and/or a command to delete the specified Key from the B + tree (referred to as a delete command), etc., according to a data access request from, for example, an external host.
An external unit such as the CPU800 operates the B + tree operating means to accomplish acceleration of the B + tree operation. For the search command, the CPU800 supplies a Key (Key) to be searched to the B + tree operator through the command interface 810, and obtains a search result given by the B + tree operator from the command interface 810. For the insert command or the delete command, the CPU800 supplies a Key (Key) indicated by the insert command or the delete command to the B + tree operating device through the command interface 810, and obtains a search result given by the B + tree operating device from the command interface 810, and the CPU800 updates one or more nodes of the B + tree according to the search result.
The CPU800 or B + tree operating device reads one or more nodes of the B + tree from the memory 890 or writes one or more nodes of the B + tree to the memory 890 through the DMA unit 840.
The command interface 810 receives a command including a keyword supplied from the CPU800, and supplies the keyword to one of the search units (820 … … 82 n). The search unit supplies the processing result of searching the B + tree with the keyword to the command interface 810, so that the CPU800 obtains the processing result of the command through the command interface 810.
A search unit (820 … … 82n) searches the B + tree based on the keyword obtained from the command. The search unit (820 … … 82n) acquires each key of a node of the B + tree from the data cache 830, compares the key acquired from the command with each key of the node to identify a hit key, acquires a key of the next node from the hit key when the current node is a non-leaf node, or acquires a processing result of the command from the hit key when the current node is a leaf node.
If data cache 830 does not include a node to be accessed by the search unit, DMA unit 840 is used to load the node to be accessed from memory 890 into data cache 830.
Fig. 9 shows a flow chart according to the embodiment of fig. 8.
The embodiment according to fig. 9 is described taking as an example a storage device coupled to a host. The host issues a command (910) to the storage device to access the storage device. The storage device is, for example, a KV (key-value) storage device. Commands provided by the host to the storage device include, for example, search, insert, and delete of the KV storage device. The KV memory device comprises a CPU and a B + tree operation device. The KV storage device stores the mapping relation between a Key (Key) and a Value (Value) in a B + tree structure.
The CPU receives a command provided from the host, extracts a Key (Key) from the command, and operates the B + tree operation device to process the command according to the instruction of the command, and operates the B + tree operation device to search the extracted Key (Key) from the B + tree using the Key (Key) extracted from the command, regardless of whether the received command is a search command, an insert command, or a delete command (920).
The B + tree operating device searches the B + tree for a keyword (930) according to the received keyword (Key), and returns the search result to the CPU. The CPU acquires a search result for the B + tree from the B + tree operating device according to a Key (Key) (940). If the command is a search command, the CPU obtains a command processing result according to the search result and provides the command processing result to the host computer which sends the command. Optionally, the search result indicates a pointer or an address of the data to be acquired by the search command, and the CPU also acquires the data according to the pointer or the address. If the command is an insert command or a delete command, the leaf node (and its key) to be updated (to be inserted or deleted) is indicated in the search results. The CPU also updates the B + tree in memory (942) as directed by the command, including updating the leaf node indicated in the search results and, optionally, performing a merge/split operation on the leaf node and updating one or more parent nodes of the leaf node.
FIG. 10 is a flowchart of processing a B + tree insert command according to the embodiment of FIG. 8.
For the insert command, the CPU extracts a Key (Key) from the command, and operates the B + tree operating device according to the instruction of the command to search the extracted Key (Key) from the B + tree (1020). The B + tree operating device searches the B + tree for a keyword (1030) according to the received keyword (Key), and returns the search result to the CPU. The CPU acquires a search result for the B + tree from the B + tree operating device according to a Key (Key) (1040).
The B + tree operator may present two search results (1050). For example, if the search result indicates that the specified key for the specified leaf node is hit, the CPU updates the value corresponding to the specified key for the hit leaf node to the value indicated by the insert command (1060), and indicates to the host that the insert command processing is complete. The host receives the command processing result provided by the CPU (1070).
If the search result from the B + tree operator indicates a specified leaf node but does not hit any key, the CPU inserts a new key and value into the leaf node in response. The CPU determines whether the number of keys contained in the designated leaf node is less than a threshold (1052). The number of keys of a leaf node is less than a threshold, meaning that the leaf node will not cause the leaf node to split after a new key is inserted into the leaf node; otherwise, if the number of keys of a leaf node is not less than the threshold, the leaf node will be split after a new key is inserted.
If the CPU determines that the number of keys contained in the specified leaf node is less than a threshold (1052), the CPU adds the key and corresponding value indicated by the insert command to the specified leaf node (1058), and indicates to the host that the insert command processing is complete.
If the CPU determines that the number of keys included in the specified leaf node is not less than a threshold (1052), the specified leaf node is split into two nodes (1054). The keywords included in the two nodes after splitting are the keywords included in the specified leaf node and the keywords to be inserted. The key to be inserted is recorded in one of the two leaf nodes after splitting, depending on where its value is sorted in the designated leaf node.
Since the node split produces a new node, the new node needs to be indexed by the previous level node (parent node). The CPU also obtains the parent node of the aforementioned specified leaf node, and identifies whether the number of keys of the parent node is less than a threshold (1056). If the number of keys of the father node is less than the threshold, the father node is not split after a new key is inserted into the father node; otherwise, if the number of the keywords of the parent node is not less than the threshold, the parent node will be split.
If the parent key number is less than a threshold (1056), the CPU adds the key in the parent node that indexes the new node that is split and indicates to the host that the insert command processing is complete. If the parent's key number is not less than the threshold (1056), the parent is split into two nodes (1054). And further identifying whether the number of keys of the parent's superordinate node is less than a threshold (1056).
Alternatively, if the current node is the root node (which does not have an upper level node), meaning that the B + tree is full and cannot carry new keys any more, the CPU indicates to the host that the insert command processing failed in response, step 1056.
FIG. 11 is a flowchart of processing a B + tree delete command according to the embodiment of FIG. 8.
For the delete command, the CPU extracts a Key (Key) from the command, and operates the B + tree operating device according to the instruction of the command to search the extracted Key (Key) from the B + tree (1120). The B + tree operating device searches the B + tree for a keyword (1130) according to the received keyword (Key), and returns the search result to the CPU. The CPU acquires a search result for the B + tree from the B + tree operating device according to a keyword (Key) (1140).
The B + tree operator may present two search results (1050). For example, if the search result indicates that a specified key for a specified leaf node is hit, then the CPU deletes the specified key from the hit leaf node and optionally also updates other nodes of the B + tree. If the search result indicates that the searched keyword is not included in the B + tree, the CPU indicates to the host that the delete command processing failed (1160).
The search result indicates that the specified key for the specified leaf node is hit (1050), the CPU retrieves the leaf node as the current node, and identifies whether the number of keys for the current node is greater than a first threshold (1152). If the number of keys of the current node is greater than the first threshold value, the current node is updated by deleting the specified key from the current node without causing merging of nodes (1159), and the host receives a result of processing of the deletion command by indicating completion of processing of the deletion command to the host (1170).
In step 1152, if the CPU identifies that the number of keywords of the current node is not greater than the first threshold, it further identifies whether the current node and its sibling nodes need to be merged. The siblings that have the recorded key ordered before the current node are called the left sibling of the current node, and the siblings that have the recorded key ordered after the current node are called the right sibling of the current node. For example, if the sum of the keys of the current node and its right sibling is greater than the order of the B + tree (1153), the key with the top ranking of the right sibling is moved to the current node, the specified key is deleted from the current node and the key indexing the right sibling in the parent of the right sibling is updated (1159), and the completion of the processing of the delete command is indicated to the host, which receives the processing result of the delete command (1170).
If the sum of the keys of the current node and its right sibling is not greater than the order of the B + tree (1153), and further if the sum of the number of keys of the current node and its left sibling is greater than the order of the B + tree (1154), moving the last-ordered key of the left sibling to the current node as the most-ordered key of the current node, deleting the specified key from the current node and updating the key of the current node index from the parent node of the current node (1159), and indicating to the host that the deletion command processing is complete, the host receiving the processing result of the deletion command (1170).
At step 1154, if the sum of the number of keys of the current node and its left sibling is not greater than the order of the B + tree (1154), the current node and one of its siblings are merged (1155). By way of example, the current node is merged with its left sibling. As a node is deleted, the key that indexed the node also needs to be deleted from the parent of the deleted node. If the parent node of the deleted node is the root node, the key indexing the deleted node is deleted from the root node (1159), and the completion of the processing of the delete command is indicated to the host, which receives the processing result of the delete command (1170). If the parent node of the deleted node is not the root node, the flow goes to step 1152 to repeat the node deletion process for the parent node under the control of the CPU.
While the preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all alterations and modifications as fall within the scope of the application. It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.

Claims (13)

1. A B + tree manipulator, said B + tree manipulator coupled to a CPU, said CPU extracting keywords from commands for manipulating the B + tree and operating said B + tree manipulator with the extracted keywords to search the B + tree; the B + tree operation device provides the search result to the CPU;
the B + tree operation device includes: one or more search units; the search unit finds the hit node in the B + tree stored in the memory based on the received key.
2. The B + tree operating apparatus according to claim 1, wherein if the command to operate the B + tree is an insert command or a delete command, the CPU updates the B + tree based on the command to operate the B + tree and the search result;
wherein the search result indicates a node to be inserted or deleted, or the search result indicates a node to be inserted or deleted and a keyword thereof.
3. The B + tree operation device of claim 2, wherein if the command to operate the B + tree is an insert command, the search result indicates a hit node and a miss key, the CPU adds the key or the key indicated by the insert command together with a corresponding value to the hit node; alternatively, the first and second electrodes may be,
if the command to operate the B + tree is an insert command, the search result indicates a hit node and a miss key, then the CPU adds the key or keys indicated by the insert command along with the corresponding values to the hit node.
4. The B + tree operation device according to claim 3, wherein if the hit node contains a number of keys not less than the threshold, the CPU splits the hit node into two nodes, and adds a key or a key indicated by the insert command together with a corresponding value to one of the two nodes.
5. The B + tree operation device of claim 4, wherein in response to a hit node splitting, a key is added to a common parent node of the two split nodes that indexes the split new node.
6. The B + tree operating apparatus according to claim 2, wherein if the command to operate the B + tree is a delete command, the search result indicates a hit keyword of the hit node, and the CPU deletes the hit keyword from the hit node.
7. The B + tree operation device of claim 6, wherein if the number of keys of the hit node is not greater than the first threshold and the sum of the keys of the hit node and its right sibling node is greater than the order of the B + tree, the CPU moves the key with the top ranking of the right sibling node to the hit node and deletes the hit key from the hit node.
8. The B + tree operation device of claim 7, wherein the key indexing the right sibling among the parents of the right sibling is updated in response to moving the top-ranked key of the right sibling to the hit node.
9. The B + tree operation device according to claim 7 or 8, wherein if the sum of the keywords of the hit node and its right sibling node is not more than the order of the B + tree and the sum of the keywords of the hit node and its left sibling node is more than the order of the B + tree, the CPU moves the last-ranked keyword of the left sibling node to the hit node as the first-ranked keyword of the hit node, and deletes the hit keyword from the hit node.
10. The B + tree operation device of claim 9, wherein if the sum of the number of keys of the hit node and its left sibling is not greater than the order of the B + tree, merging the hit node and one of its sibling.
11. The B + tree operation apparatus according to claim 10, wherein when the hit node and its left sibling node are merged, a parent node of the deleted node is a new hit node, the key in which the deleted node is indexed is a new hit key, and the new hit key is deleted from the new hit node.
12. The B + tree manipulation apparatus of any of claims 6 and 8-9,
in response to deletion of the hit keyword in the hit node, the CPU indicates completion of the deletion command processing to the host that issued the command to operate the B + tree; alternatively, the first and second electrodes may be,
in response to updating the key of the index right sibling node in the parent node of the right sibling node, the CPU indicates completion of the deletion command processing to the host that issued the command to operate the B + tree; alternatively, the first and second electrodes may be,
in response to deleting the hit key from the hit node and updating the key of the index hit node in the parent node of the hit node, the CPU indicates completion of the deletion command processing to the host that issued the command to operate the B + tree; alternatively, the first and second electrodes may be,
in response to deleting the key indexing the deleted node from the root node, the CPU indicates to the host issuing the command to operate the B + tree that the delete command processing is complete.
13. The B + tree manipulation device of claim 5,
in response to the addition of the key of the index split new node to the parent node, the CPU indicates to the host issuing the operation B + tree that the insertion command processing is complete; and/or the presence of a gas in the gas,
if the hit node or the common parent node of the two split nodes is the root node and the number of the keywords contained in the hit node or the common parent node of the two split nodes is not less than the threshold value, the CPU indicates that the insert command processing fails to the host that issues the operation B + tree.
CN202110324501.5A 2019-03-28 2019-03-28 B + tree operating device Pending CN112989130A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110324501.5A CN112989130A (en) 2019-03-28 2019-03-28 B + tree operating device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110324501.5A CN112989130A (en) 2019-03-28 2019-03-28 B + tree operating device
CN201910244351.XA CN111581440B (en) 2019-03-28 2019-03-28 Hardware acceleration B + tree operation device and method thereof

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN201910244351.XA Division CN111581440B (en) 2019-03-28 2019-03-28 Hardware acceleration B + tree operation device and method thereof

Publications (1)

Publication Number Publication Date
CN112989130A true CN112989130A (en) 2021-06-18

Family

ID=72118567

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202110324501.5A Pending CN112989130A (en) 2019-03-28 2019-03-28 B + tree operating device
CN201910244351.XA Active CN111581440B (en) 2019-03-28 2019-03-28 Hardware acceleration B + tree operation device and method thereof

Family Applications After (1)

Application Number Title Priority Date Filing Date
CN201910244351.XA Active CN111581440B (en) 2019-03-28 2019-03-28 Hardware acceleration B + tree operation device and method thereof

Country Status (1)

Country Link
CN (2) CN112989130A (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112559529B (en) * 2020-12-16 2023-06-09 杭州趣链科技有限公司 Data storage method, device, computer equipment and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6859808B1 (en) * 2001-05-31 2005-02-22 Oracle International Corporation Mapping logical row identifiers for primary B+tree-like structures to physical row identifiers
CN103765381B (en) * 2011-08-29 2016-08-31 英特尔公司 Parallel work-flow to B+ tree
CN102915346B (en) * 2012-09-26 2015-07-01 中国科学院软件研究所 Data index building and query method for Internet of Things intellisense
US9323771B2 (en) * 2013-04-24 2016-04-26 Dell Products, Lp Efficient rename in a lock-coupled traversal of B+tree
CN104408177B (en) * 2014-12-15 2017-08-25 西安电子科技大学 Cipher text retrieval method based on cloud document system
CN109359062A (en) * 2018-11-02 2019-02-19 郑州云海信息技术有限公司 A kind of metadata read buffer method, device and equipment

Also Published As

Publication number Publication date
CN111581440A (en) 2020-08-25
CN111581440B (en) 2021-04-23

Similar Documents

Publication Publication Date Title
CN110083601B (en) Key value storage system-oriented index tree construction method and system
US7558802B2 (en) Information retrieving system
AU608872B2 (en) Device for enabling concurrent access of indexed sequential data files
CN103902623B (en) Method and system for the accessing file in storage system
US7831626B1 (en) Integrated search engine devices having a plurality of multi-way trees of search keys therein that share a common root node
US7603346B1 (en) Integrated search engine devices having pipelined search and b-tree maintenance sub-engines therein
CN105320775A (en) Data access method and apparatus
US9047363B2 (en) Text indexing for updateable tokenized text
US20180349422A1 (en) Database management system, database server, and database management method
US8515976B2 (en) Bit string data sorting apparatus, sorting method, and program
US7987205B1 (en) Integrated search engine devices having pipelined node maintenance sub-engines therein that support database flush operations
CN111581440B (en) Hardware acceleration B + tree operation device and method thereof
JPH10260876A (en) Data structure of database, and data processing method for database
CN113392089B (en) Database index optimization method and readable storage medium
US7953721B1 (en) Integrated search engine devices that support database key dumping and methods of operating same
US8285691B2 (en) Binary method for locating data rows in a compressed data block
US7302377B1 (en) Accelerated event queue for logic simulation
CN111581204B (en) Multi-B + tree operation device and method thereof
CN114416741A (en) KV data writing and reading method and device based on multi-level index and storage medium
CN109241098B (en) Query optimization method for distributed database
CN112328630A (en) Data query method, device, equipment and storage medium
CN113536058A (en) Spatial index modification method, device, equipment and storage medium
KR20220099745A (en) A spatial decomposition-based tree indexing and query processing methods and apparatus for geospatial blockchain data retrieval
JP2000112973A (en) Space index method and medium storing space index processing program
CN111723266A (en) Mass data processing method and device

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