CN113609160A - B + tree traversal method, system, storage medium and equipment - Google Patents
B + tree traversal method, system, storage medium and equipment Download PDFInfo
- Publication number
- CN113609160A CN113609160A CN202110682325.2A CN202110682325A CN113609160A CN 113609160 A CN113609160 A CN 113609160A CN 202110682325 A CN202110682325 A CN 202110682325A CN 113609160 A CN113609160 A CN 113609160A
- Authority
- CN
- China
- Prior art keywords
- key
- value
- value pair
- tree
- array
- 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.)
- Withdrawn
Links
- 238000000034 method Methods 0.000 title claims abstract description 36
- 230000004044 response Effects 0.000 claims abstract description 44
- 238000003780 insertion Methods 0.000 claims abstract description 39
- 230000037431 insertion Effects 0.000 claims abstract description 39
- 238000004590 computer program Methods 0.000 claims description 9
- 238000013507 mapping Methods 0.000 description 9
- 238000010586 diagram Methods 0.000 description 8
- 238000012986 modification Methods 0.000 description 5
- 230000004048 modification Effects 0.000 description 5
- 238000012217 deletion Methods 0.000 description 4
- 230000037430 deletion Effects 0.000 description 4
- 230000006870 function Effects 0.000 description 4
- 230000001360 synchronised effect Effects 0.000 description 3
- 238000013461 design Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 230000014509 gene expression Effects 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 238000012545 processing Methods 0.000 description 2
- 230000005856 abnormality Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000010076 replication Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
- G06F16/215—Improving data quality; Data cleansing, e.g. de-duplication, removing invalid entries or correcting typographical errors
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2228—Indexing structures
- G06F16/2246—Trees, e.g. B+trees
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computational Linguistics (AREA)
- Software Systems (AREA)
- Quality & Reliability (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention provides a B + tree traversal method, a system, a storage medium and a device, wherein the method comprises the following steps: traversing a first key-value pair in a leaf node of a first B + tree; searching the traversed first key value pair for a corresponding second key value pair in a leaf node of a second B + tree; in response to the corresponding second key-value pair not being found, inserting the corresponding second key-value pair into a leaf node of a second B + tree; in response to the insertion failure, copying the corresponding first key-value pair into an array, and continuously traversing the first key-value pair in the leaf node of the first B + tree; and in response to the number of the first key-value pairs in the array reaching a preset threshold value so that the copy of the first key-value pairs failed in the insertion, deleting the first key-value pairs in the array and the first key-value pairs in the corresponding first B + tree, and re-copying the first key-value pairs failed in the copy into the array and continuously traversing from the leaf nodes of the first key-value pairs. The invention solves the problem of low traversal efficiency of the first B + tree.
Description
Technical Field
The invention relates to the technical field of storage, in particular to a B + tree traversal method, a system, a storage medium and equipment.
Background
The current storage system generally adopts a B + tree data structure in software design to record storage data. The logical block address and the physical block address of the stored data have a specific mapping relationship, so that the data lost in some caches caused by system abnormality can be repaired by using the specific mapping relationship. The data repairing mode in the current system design is that B + trees which are dropped are traversed one by one and paired and repaired according to a mapping relation, if a certain key value pair in the B + trees needs to be deleted in the B + tree traversing process, the B + trees are traversed again after the key value pair is deleted, and the mode can cause repeated traversal due to modification of the B + trees, so that the time for traversing the B + trees is greatly increased, and the efficiency is reduced.
Disclosure of Invention
In view of the above, an objective of the present invention is to provide a B + tree traversal method, system, storage medium, and device, so as to solve the problem in the prior art that the traversal efficiency of a B + tree is low because the B + tree needs to be re-traversed for multiple times due to multiple modifications (e.g., deletion operations) performed on the B + tree.
Based on the above purpose, the present invention provides a B + tree traversal method, which comprises the following steps:
traversing a first key-value pair in a leaf node of a first B + tree;
searching the traversed first key value pair for a corresponding second key value pair in a leaf node of a second B + tree;
in response to the corresponding second key-value pair not being found, inserting the corresponding second key-value pair into a leaf node of a second B + tree;
in response to the insertion failure, copying the corresponding first key-value pair into an array, and continuously traversing the first key-value pair in the leaf node of the first B + tree;
and in response to the number of the first key-value pairs in the array reaching a preset threshold value so that the copy of the first key-value pairs failed in the insertion, deleting the first key-value pairs in the array and the first key-value pairs in the corresponding first B + tree, and re-copying the first key-value pairs failed in the copy into the array and continuously traversing from the leaf nodes of the first key-value pairs.
In some embodiments, re-copying the copy-failed first key-value pair into the array and continuing the traversal from its leaf node comprises:
and recording the cursor position of the leaf node of the first key-value pair failed in copying, copying the first key-value pair failed in copying into the array again, and continuously traversing from the leaf node corresponding to the cursor position.
In some embodiments, in response to the insertion failure, copying the corresponding first key-value pair into the array comprises:
responding to the insertion failure, and judging whether the number of the first key value pairs in the array reaches a preset threshold value or not;
and copying the corresponding first key-value pair into the array in response to the preset threshold value not being reached.
In some embodiments, in response to not finding the corresponding second key-value pair, inserting the corresponding second key-value pair in a leaf node of the second B + tree comprises:
and in response to the fact that the corresponding second key-value pair is not found, inserting the corresponding second key-value pair into the leaf node of the second B + tree, and checking a return value of an insertion result.
In some embodiments, responding to the insertion failure comprises:
in response to the return value being a second key-value pair overflow error.
In some embodiments, traversing the first key-value pair in a leaf node of the first B + tree comprises:
and traversing the root node of the first B + tree and the intermediate nodes below the root node until the intermediate nodes are traversed, and traversing the first key value pairs in the leaf nodes below the intermediate nodes.
In some embodiments, the key of the first key-value pair is a logical block address and its value is a physical block address, the key of the second key-value pair is a physical block address and its value is a logical block address, or
The key of the first key-value pair is a physical block address and its value is a logical block address, and the key of the second key-value pair is a logical block address and its value is a physical block address.
In another aspect of the present invention, a B + tree traversal system is further provided, including:
the first key-value pair traversal module is configured to traverse a first key-value pair in a leaf node of a first B + tree;
the second key-value pair searching module is configured to search the traversed first key-value pair for a corresponding second key-value pair in a leaf node of a second B + tree;
a second key-value pair insertion module configured to insert a corresponding second key-value pair in a leaf node of a second B + tree in response to the corresponding second key-value pair not being found;
the first key-value pair copying module is configured to respond to the insertion failure, copy the corresponding first key-value pair to the array, and continue traversing the first key-value pair in the leaf node of the first B + tree; and
and the deleting module is configured to respond to the condition that the number of the first key-value pairs in the array reaches a preset threshold value so that the copy of the first key-value pairs failed to insert is failed, delete the first key-value pairs in the array and the first key-value pairs in the corresponding first B + tree, re-copy the first key-value pairs failed to copy into the array and continuously traverse from leaf nodes of the first key-value pairs.
In yet another aspect of the present invention, there is also provided a computer readable storage medium storing computer program instructions which, when executed, implement any one of the methods described above.
In yet another aspect of the present invention, a computer device is provided, which includes a memory and a processor, the memory storing a computer program, the computer program executing any one of the above methods when executed by the processor.
The invention has at least the following beneficial technical effects:
according to the method, the corresponding second key value pair is searched in the leaf node of the second B + tree by the traversed first key value pair, and the corresponding second key value pair is inserted into the leaf node of the second B + tree when the corresponding second key value pair is not searched, so that the mapping relation between the first B + tree and each node of the second B + tree can be maintained; under the condition that the corresponding second key value pair is not successfully inserted into the leaf node of the second B + tree, the traversed first key value pair is copied into the array instead of immediately deleting the first key value pair, so that the problem that the first B + tree needs to be traversed again due to the deletion operation of the first B + tree is solved; the memory space occupied by the array can be controlled by setting a preset threshold value for the first key-value pairs in the array and deleting the first key-value pairs in the array and the corresponding first key-value pairs in the first B + tree when the number of the first key-value pairs reaches the preset threshold value; by deleting the first key value pairs in the first B + tree in batches and continuously traversing from the leaf nodes of the first key value pairs which fail to be copied, the problem that the traversing efficiency is low because the first B + tree needs to be traversed again for multiple times due to multiple deleting operations on the first B + tree is solved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other embodiments can be obtained by using the drawings without creative efforts.
Fig. 1 is a schematic diagram of a B + tree traversal method provided in an embodiment of the present invention;
FIG. 2 is a diagram illustrating a B + tree traversal system according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a computer-readable storage medium for implementing a B + tree traversal method according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a hardware structure of a computer device for executing a B + tree traversal method according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following embodiments of the present invention are described in further detail with reference to the accompanying drawings.
It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are used for distinguishing two non-identical entities with the same name or different parameters, and it is understood that "first" and "second" are only used for convenience of expression and should not be construed as limiting the embodiments of the present invention. Furthermore, the terms "comprises" and "comprising," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements does not include all of the other steps or elements inherent in the list.
In view of the above, a first aspect of the embodiments of the present invention provides an embodiment of a B + tree traversal method. Fig. 1 is a schematic diagram illustrating an embodiment of a B + tree traversal method provided by the present invention. As shown in fig. 1, the embodiment of the present invention includes the following steps:
step S10, traversing the first key value pair in the leaf node of the first B + tree;
step S20, searching the traversed first key value pair in a leaf node of a second B + tree for a corresponding second key value pair;
step S30, in response to the corresponding second key-value pair not found, inserting the corresponding second key-value pair into a leaf node of a second B + tree;
step S40, in response to the insertion failure, copying the corresponding first key-value pair to an array, and continuously traversing the first key-value pair in the leaf node of the first B + tree;
step S50, in response to the number of the first key-value pairs in the array reaching a preset threshold value to cause the copy of the first key-value pair with failed insertion to fail, deleting the first key-value pair in the array and the first key-value pair in the corresponding first B + tree, and re-copying the first key-value pair with failed copy to the array and continuously traversing from the leaf node thereof.
In this embodiment, the B + tree is a tree data structure, and is an n-ary tree, each node generally has a plurality of child nodes, and the B + tree includes a root node, a middle node, and leaf nodes. The B + tree is generally used in a file system of a database and an operating system, and is characterized by being capable of keeping data stable and ordered, and the insertion and modification of the B + tree have stable logarithmic time complexity. The B + tree is a variant of the B-tree, where leaf nodes on the B + tree store the key and the address of the corresponding record, and the layers above the leaf nodes are used as indexes.
In the embodiment of the invention, the mapping relation between the first B + tree and each node of the second B + tree can be maintained by searching the corresponding second key value pair in the leaf node of the second B + tree through the traversed first key value pair and inserting the corresponding second key value pair into the leaf node of the second B + tree when the corresponding second key value pair is not searched; under the condition that the corresponding second key value pair is not successfully inserted into the leaf node of the second B + tree, the traversed first key value pair is copied into the array instead of immediately deleting the first key value pair, so that the problem that the first B + tree needs to be traversed again due to the deletion operation of the first B + tree is solved; the memory space occupied by the array can be controlled by setting a preset threshold value for the first key-value pairs in the array and deleting the first key-value pairs in the array and the corresponding first key-value pairs in the first B + tree when the number of the first key-value pairs reaches the preset threshold value; by deleting the first key value pairs in the first B + tree in batches and continuously traversing from the leaf nodes of the first key value pairs which fail to be copied, the problem that the traversing efficiency is low because the first B + tree needs to be traversed again for multiple times due to multiple deleting operations on the first B + tree is solved.
In some embodiments, re-copying the copy-failed first key-value pair into the array and continuing the traversal from its leaf node comprises: and recording the cursor position of the leaf node of the first key-value pair failed in copying, copying the first key-value pair failed in copying into the array again, and continuously traversing from the leaf node corresponding to the cursor position.
In the embodiment, the traversal efficiency of the first B + tree can be improved by setting the cursor position, the problem that the first B + tree needs to be traversed again from the beginning when the failed key value pairs are inserted into the first B + tree in batch and deleted under the condition that the number of the first key value pairs in the array reaches the preset threshold value is solved, the traversal is continued by directly starting from the cursor position of the leaf node of the failed first key value pair, and the traversal complexity is effectively reduced.
In some embodiments, in response to the insertion failure, copying the corresponding first key-value pair into the array comprises: responding to the insertion failure, and judging whether the number of the first key value pairs in the array reaches a preset threshold value or not; and copying the corresponding first key-value pair into the array in response to the preset threshold value not being reached.
In this embodiment, by setting a preset threshold for the number of the first key value pairs stored in the array, the memory occupied by the array can be limited, and the performance of the storage system is prevented from being affected by the fact that the array occupies too much memory; and the first key-value pairs in the array can be better managed, and the first key-value pairs are prevented from being infinitely increased in the array.
In some embodiments, in response to not finding the corresponding second key-value pair, inserting the corresponding second key-value pair in a leaf node of the second B + tree comprises: and in response to the fact that the corresponding second key-value pair is not found, inserting the corresponding second key-value pair into the leaf node of the second B + tree, and checking a return value of an insertion result. In some embodiments, responding to the insertion failure comprises: in response to the return value being a second key-value pair overflow error.
In this embodiment, the result return value is set by inserting the second B + tree for the second key value pair, so that the insertion result can be directly known, and further processing is performed based on the insertion result, which also has a good effect of improving the traversal efficiency of the B + tree.
In some embodiments, traversing the first key-value pair in a leaf node of the first B + tree comprises: and traversing the root node of the first B + tree and the intermediate nodes below the root node until the intermediate nodes are traversed, and traversing the first key value pairs in the leaf nodes below the intermediate nodes.
In this embodiment, the B + tree includes a root node, a middle node, and a leaf node, the leaf node is located at the last layer of the B + tree structure, and there is no other node below the leaf node.
In some embodiments, the key of the first key-value pair is a logical block address and its value is a physical block address, the key of the second key-value pair is a physical block address and its value is a logical block address, or the key of the first key-value pair is a physical block address and its value is a logical block address, the key of the second key-value pair is a logical block address and its value is a physical block address.
In this embodiment, a first B + tree representing a B + tree of a mapping relationship from a logical block address to a physical block address may be set, and a second B + tree representing a B + tree of a mapping relationship from a physical block address to a logical block address, that is: the key (key) of the first key-value pair is a logical block address and its value (value) is a physical block address, and the key of the second key-value pair is a physical block address and its value is a logical block address; or setting a first B + tree representing a B + tree of the mapping relationship from the physical block address to the logical block address, and setting a second B + tree representing a B + tree of the mapping relationship from the logical block address to the physical block address, namely: the key of the first key-value pair is a physical block address and its value is a logical block address, and the key of the second key-value pair is a logical block address and its value is a physical block address. The Logical Block Address (LBA) may refer to an Address of a certain data Block or a data Block pointed at a certain Address, and the Physical Block Address (PBA) and the Logical Block Address have a one-to-one correspondence relationship.
In a second aspect of the embodiments of the present invention, a B + tree traversal system is further provided. FIG. 2 is a diagram illustrating an embodiment of a B + tree traversal system provided by the present invention. As shown in fig. 2, a B + tree traversal system includes: a first key-value pair traversal module 10 configured to traverse a first key-value pair in a leaf node of a first B + tree; a second key-value pair searching module 20 configured to search the traversed first key-value pair for a corresponding second key-value pair in a leaf node of a second B + tree; a second key-value pair insertion module 30 configured to insert a corresponding second key-value pair in a leaf node of a second B + tree in response to the corresponding second key-value pair not being found; a first key-value pair copying module 40 configured to, in response to an insertion failure, copy a corresponding first key-value pair into the array, and continue traversing the first key-value pairs in the leaf nodes of the first B + tree; and a deleting module 50 configured to delete the first key-value pair in the array and the corresponding first key-value pair in the first B + tree in response to the number of the first key-value pairs in the array reaching a preset threshold value so that the copy of the first key-value pair failed in the insertion fails, and re-copy the first key-value pair failed in the copy into the array and continue traversing from the leaf node thereof.
In some embodiments, the deletion module 50 includes a continue traversal module configured to record a cursor position of a leaf node of the first key-value pair that failed the copy, and to re-copy the first key-value pair that failed the copy into the array and continue traversal after the leaf node corresponding to the cursor position.
In some embodiments, the first key-value pair copying module 40 is further configured to determine, in response to an insertion failure, whether a number of first key-value pairs in the array reaches a preset threshold; and copying the corresponding first key-value pair into the array in response to the preset threshold value not being reached.
In some embodiments, the second key-value pair insertion module 30 is further configured to insert the corresponding second key-value pair in a leaf node of the second B + tree in response to the corresponding second key-value pair not being found, and to view a return value of the insertion result.
In some embodiments, the first key-value pair replication module 40 includes an insert failure module configured to respond to the return value being a second key-value pair overflow error.
In some embodiments, the first key-value pair traversal module 10 is further configured to traverse the root node of the first B + tree and the intermediate nodes therebelow until the intermediate nodes are traversed, traversing the first key-value pairs in the leaf nodes therebelow.
In some embodiments, the key of the first key-value pair is a logical block address and its value is a physical block address, the key of the second key-value pair is a physical block address and its value is a logical block address, or the key of the first key-value pair is a physical block address and its value is a logical block address, the key of the second key-value pair is a logical block address and its value is a physical block address.
In a third aspect of the embodiment of the present invention, a computer-readable storage medium is further provided, and fig. 3 is a schematic diagram of a computer-readable storage medium for implementing a B + tree traversal method according to an embodiment of the present invention. As shown in fig. 3, the computer-readable storage medium 3 stores computer program instructions 31, the computer program instructions 31 when executed by the processor implement the steps of:
traversing a first key-value pair in a leaf node of a first B + tree;
searching the traversed first key value pair for a corresponding second key value pair in a leaf node of a second B + tree;
in response to the corresponding second key-value pair not being found, inserting the corresponding second key-value pair into a leaf node of a second B + tree;
in response to the insertion failure, copying the corresponding first key-value pair into an array, and continuously traversing the first key-value pair in the leaf node of the first B + tree;
and in response to the number of the first key-value pairs in the array reaching a preset threshold value so that the copy of the first key-value pairs failed in the insertion, deleting the first key-value pairs in the array and the first key-value pairs in the corresponding first B + tree, and re-copying the first key-value pairs failed in the copy into the array and continuously traversing from the leaf nodes of the first key-value pairs.
In some embodiments, re-copying the copy-failed first key-value pair into the array and continuing the traversal from its leaf node comprises: and recording the cursor position of the leaf node of the first key-value pair failed in copying, copying the first key-value pair failed in copying into the array again, and continuously traversing from the leaf node corresponding to the cursor position.
In some embodiments, in response to the insertion failure, copying the corresponding first key-value pair into the array comprises: responding to the insertion failure, and judging whether the number of the first key value pairs in the array reaches a preset threshold value or not; and copying the corresponding first key-value pair into the array in response to the preset threshold value not being reached.
In some embodiments, in response to not finding the corresponding second key-value pair, inserting the corresponding second key-value pair in a leaf node of the second B + tree comprises: and in response to the fact that the corresponding second key-value pair is not found, inserting the corresponding second key-value pair into the leaf node of the second B + tree, and checking a return value of an insertion result.
In some embodiments, responding to the insertion failure comprises: in response to the return value being a second key-value pair overflow error.
In some embodiments, traversing the first key-value pair in a leaf node of the first B + tree comprises: and traversing the root node of the first B + tree and the intermediate nodes below the root node until the intermediate nodes are traversed, and traversing the first key value pairs in the leaf nodes below the intermediate nodes.
In some embodiments, the key of the first key-value pair is a logical block address and its value is a physical block address, the key of the second key-value pair is a physical block address and its value is a logical block address, or the key of the first key-value pair is a physical block address and its value is a logical block address, the key of the second key-value pair is a logical block address and its value is a physical block address.
It should be understood that all of the embodiments, features and advantages set forth above with respect to the B + tree traversal method according to the present invention are equally applicable to the B + tree traversal system and the storage medium according to the present invention, without conflicting therewith.
In a fourth aspect of the embodiments of the present invention, there is further provided a computer device, including a memory 402 and a processor 401, where the memory stores a computer program, and the computer program, when executed by the processor, implements the method of any one of the above embodiments.
Fig. 4 is a schematic hardware structural diagram of an embodiment of a computer device for executing the B + tree traversal method provided by the present invention. Taking the computer device shown in fig. 4 as an example, the computer device includes a processor 401 and a memory 402, and may further include: an input device 403 and an output device 404. The processor 401, the memory 402, the input device 403 and the output device 404 may be connected by a bus or other means, and fig. 4 illustrates an example of a connection by a bus. The input device 403 may receive input numeric or character information and generate key signal inputs related to user settings and function controls of the B + tree traversal system. The output device 404 may include a display device such as a display screen.
The memory 402, which is a non-volatile computer-readable storage medium, may be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as program instructions/modules corresponding to the B + tree traversal method in the embodiments of the present application. The memory 402 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created by use of the B + tree traversal method, and the like. Further, the memory 402 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some embodiments, memory 402 may optionally include memory located remotely from processor 401, which may be connected to local modules via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The processor 401 executes various functional applications of the server and data processing, i.e., implements the B + tree traversal method of the above-described method embodiment, by running non-volatile software programs, instructions, and modules stored in the memory 402.
Finally, it should be noted that the computer-readable storage medium (e.g., memory) herein can be either volatile memory or nonvolatile memory, or can include both volatile and nonvolatile memory. By way of example, and not limitation, nonvolatile memory can include Read Only Memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM), which can act as external cache memory. By way of example and not limitation, RAM is available in a variety of forms such as synchronous RAM (DRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The storage devices of the disclosed aspects are intended to comprise, without being limited to, these and other suitable types of memory.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as software or hardware depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the disclosed embodiments of the present invention.
The various illustrative logical blocks, modules, and circuits described in connection with the disclosure herein may be implemented or performed with the following components designed to perform the functions herein: a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination of these components. A general purpose processor may be a microprocessor, but in the alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. A processor may also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP, and/or any other such configuration.
The foregoing is an exemplary embodiment of the present disclosure, but it should be noted that various changes and modifications could be made herein without departing from the scope of the present disclosure as defined by the appended claims. The functions, steps and/or actions of the method claims in accordance with the disclosed embodiments described herein need not be performed in any particular order. Furthermore, although elements of the disclosed embodiments of the invention may be described or claimed in the singular, the plural is contemplated unless limitation to the singular is explicitly stated.
It should be understood that, as used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly supports the exception. It should also be understood that "and/or" as used herein is meant to include any and all possible combinations of one or more of the associated listed items. The numbers of the embodiments disclosed in the embodiments of the present invention are merely for description, and do not represent the merits of the embodiments.
Those of ordinary skill in the art will understand that: the discussion of any embodiment above is meant to be exemplary only, and is not intended to intimate that the scope of the disclosure, including the claims, of embodiments of the invention is limited to these examples; within the idea of an embodiment of the invention, also technical features in the above embodiment or in different embodiments may be combined and there are many other variations of the different aspects of the embodiments of the invention as described above, which are not provided in detail for the sake of brevity. Therefore, any omissions, modifications, substitutions, improvements, and the like that may be made without departing from the spirit and principles of the embodiments of the present invention are intended to be included within the scope of the embodiments of the present invention.
Claims (10)
1. A B + tree traversal method is characterized by comprising the following steps:
traversing a first key-value pair in a leaf node of a first B + tree;
searching the traversed first key value pair for a corresponding second key value pair in a leaf node of a second B + tree;
in response to not finding the corresponding second key-value pair, inserting the corresponding second key-value pair in a leaf node of the second B + tree;
in response to an insertion failure, copying the corresponding first key-value pair into an array, and continuing to traverse the first key-value pair in a leaf node of the first B + tree;
and in response to the number of the first key-value pairs in the array reaching a preset threshold value so that the copy of the first key-value pairs failed in the insertion, deleting the first key-value pairs in the array and the corresponding first key-value pairs in the first B + tree, and re-copying the first key-value pairs failed in the copy into the array and continuously traversing from leaf nodes of the first key-value pairs.
2. The method of claim 1, wherein re-copying the copy-failed first key-value pair into the array and continuing traversal from its leaf nodes comprises:
and recording the cursor position of the leaf node of the first key-value pair failed in copying, re-copying the first key-value pair failed in copying into the array, and continuously traversing from the leaf node corresponding to the cursor position.
3. The method of claim 1, wherein copying the corresponding first key-value pair into an array in response to an insertion failure comprises:
responding to the insertion failure, and judging whether the number of the first key value pairs in the array reaches the preset threshold value or not;
in response to not reaching the preset threshold, copying the corresponding first key-value pair into an array.
4. The method of claim 1, wherein inserting the corresponding second key-value pair in a leaf node of the second B + tree in response to the corresponding second key-value pair not being located comprises:
and in response to that the corresponding second key-value pair is not found, inserting the corresponding second key-value pair into a leaf node of the second B + tree, and checking a return value of an insertion result.
5. The method of claim 4, wherein responding to an insertion failure comprises:
in response to the return value being a second key-value pair overflow error.
6. The method of claim 1, wherein traversing the first key-value pair in a leaf node of the first B + tree comprises:
and traversing the root node of the first B + tree and the intermediate nodes below the root node until the intermediate nodes are traversed, and traversing the first key value pairs in the leaf nodes below the intermediate nodes.
7. The method of claim 1, wherein the key of the first key-value pair is a logical block address and its value is a physical block address, the key of the second key-value pair is a physical block address and its value is a logical block address, or
The key of the first key-value pair is a physical block address and its value is a logical block address, and the key of the second key-value pair is a logical block address and its value is a physical block address.
8. A B + tree traversal system, comprising:
the first key-value pair traversal module is configured to traverse a first key-value pair in a leaf node of a first B + tree;
the second key-value pair searching module is configured to search the traversed first key-value pair for a corresponding second key-value pair in a leaf node of a second B + tree;
a second key-value pair insertion module configured to insert the corresponding second key-value pair in a leaf node of the second B + tree in response to the corresponding second key-value pair not being found;
the first key-value pair copying module is configured to, in response to an insertion failure, copy the corresponding first key-value pair into an array and continue to traverse the first key-value pair in the leaf node of the first B + tree; and
and the deleting module is configured to respond to the condition that the number of the first key-value pairs in the array reaches a preset threshold value so that the copy of the first key-value pairs failed to insert is failed, delete the first key-value pairs in the array and the corresponding first key-value pairs in the first B + tree, and re-copy the first key-value pairs failed to copy into the array and continue traversing from leaf nodes of the first key-value pairs.
9. A computer-readable storage medium, characterized in that computer program instructions are stored which, when executed by a processor, implement the method according to any one of claims 1-7.
10. A computer device comprising a memory and a processor, characterized in that the memory has stored therein a computer program which, when executed by the processor, performs the method according to any one of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110682325.2A CN113609160A (en) | 2021-06-20 | 2021-06-20 | B + tree traversal method, system, storage medium and equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110682325.2A CN113609160A (en) | 2021-06-20 | 2021-06-20 | B + tree traversal method, system, storage medium and equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113609160A true CN113609160A (en) | 2021-11-05 |
Family
ID=78336623
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110682325.2A Withdrawn CN113609160A (en) | 2021-06-20 | 2021-06-20 | B + tree traversal method, system, storage medium and equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113609160A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114090157A (en) * | 2021-11-18 | 2022-02-25 | 中国平安财产保险股份有限公司 | Data processing method, device and equipment of tree control and storage medium |
-
2021
- 2021-06-20 CN CN202110682325.2A patent/CN113609160A/en not_active Withdrawn
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114090157A (en) * | 2021-11-18 | 2022-02-25 | 中国平安财产保险股份有限公司 | Data processing method, device and equipment of tree control and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR102455884B1 (en) | Data processing method and apparatus, computer device, and storage medium | |
CN111240595A (en) | Method, system, equipment and medium for optimizing storage cache | |
CN111177043A (en) | Method, system, device and medium for accelerating reading of field replaceable unit information | |
CN114780500B (en) | Data storage method, device and equipment based on log merging tree and storage medium | |
CN112559529B (en) | Data storage method, device, computer equipment and storage medium | |
CN114816266A (en) | Metadata repairing method, system, storage medium and equipment | |
CN113535708A (en) | Data deduplication method, system, storage medium and equipment | |
CN111488987B (en) | Method, system, equipment and medium for deep learning large model training | |
CN113609160A (en) | B + tree traversal method, system, storage medium and equipment | |
CN113297432B (en) | Method, processor-readable medium, and system for partition splitting and merging | |
CN114527938A (en) | Data reading method, system, medium and device based on solid state disk | |
CN112511629B (en) | Data compression method and system for account tree of MPT structure | |
CN111309264B (en) | Method, system, device and medium for making directory quota compatible with snapshot | |
CN111176904B (en) | Method, system, equipment and medium for data backup under private cloud architecture | |
CN112631833A (en) | Data archiving and querying method, system, storage medium and equipment | |
CN114546286B (en) | Method, system, storage medium and equipment for selecting members of homing group | |
CN113626089B (en) | Data operation method, system, medium and device based on BIOS (basic input output system) | |
CN111813507A (en) | Method, system, equipment and medium for high availability of virtual machine based on sanlock | |
CN111625203A (en) | Method, system, device and medium for hierarchical storage | |
CN114020525B (en) | Fault isolation method, device, equipment and storage medium | |
CN113885789A (en) | Method, system, device and medium for verifying data consistency after metadata repair | |
CN107315806B (en) | Embedded storage method and device based on file system | |
CN111130976B (en) | Method, equipment and medium for configuring virtual local area network of white box switch | |
CN111581288B (en) | Object cloning method, system, device and medium | |
CN111309525B (en) | Method, system, equipment and medium for controlling data recovery precision |
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 | ||
WW01 | Invention patent application withdrawn after publication | ||
WW01 | Invention patent application withdrawn after publication |
Application publication date: 20211105 |