Data processing method and device, and storage medium
By using free slots to write data in parallel in non-leaf nodes of the radix tree, the problem of low data writing efficiency caused by lock competition is solved, and the data writing efficiency of the key-value storage system under the memory separation architecture is improved.
Patent Information
- Application Number
- PCT/CN2023/139314
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-04-20
- Filing Date
- 2023-12-16
- Publication Date
- 2024-10-03
AI Technical Summary
In the key-value storage system under the memory separation architecture, when the computing end needs to add or read key-value pairs to non-leaf nodes of the radix tree, the efficiency of writing data is often reduced due to lock occupation, especially in a multi-processor environment. The write operation needs to wait for the lock to be released, which affects system performance.
By using free slots to save fragment key and pointer information in the content part of non-leaf nodes of the radix tree, multiple processors are allowed to write data in different slots in parallel, avoiding lock competition and improving the efficiency of writing data.
It realizes parallel writing of data without occupying locks in a multi-processor environment, improves the data writing efficiency of the key-value storage system, and improves the overall performance of the system.
Smart Images

Figure CN2023139314_03102024_PF_FP_ABST
Abstract
Description
Data processing method, device and storage medium
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on March 25, 2023, with application number 202310308715.2 and application name “A method, device and other equipment for concurrent control”, and claims priority to the Chinese patent application filed with the China Patent Office on April 20, 2023, with application number 202310432124.6 and application name “Data processing method, device and storage medium”, all contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of storage technology, and in particular to a data processing method, device and storage medium. Background Art
[0003] A key-value storage system with a memory-separated architecture consists of a compute side and a memory side. The compute side includes multiple central processing units (CPUs), and the memory side includes multiple memories. The CPUs on the compute side access the memory side's memory over the network. The memory side uses a key-value storage format to store data, and the CPUs on the compute side use a radix tree to access the key-value pairs stored in the memory side.
[0004] Each leaf node in the radix tree stores a key and a value corresponding to the key. The key includes multiple fragment keys, and each non-leaf node on the path from the root of the radix tree to the leaf node stores at least one fragment key of the key. The CPU can match the path from the radix tree based on the fragment keys included in the key, determine the leaf node based on the path, and obtain the value corresponding to the key from the leaf node.
[0005] When the CPU on the computing side needs to add a fragment key of a key to a non-leaf node of the radix tree, it first occupies the lock of the non-leaf node, and then writes the fragment key of the key to the non-leaf node. If other CPUs on the computing side also need to write fragment keys of other keys to the non-leaf node at this time, because the lock of the non-leaf node is already occupied, they need to wait for the lock of the non-leaf node to be released before writing the fragment key of the other key to the non-leaf node, which reduces the efficiency of writing data.
[0006] Summary of the Invention
[0007] This application provides a data processing method, device, and storage medium to improve the efficiency of writing data. The technical solution is as follows:
[0008] In a first aspect, the present application provides a method for data processing, which is applied to a key-value storage system under a memory separation architecture. The key-value storage system stores data in the form of key-value pairs. The key-value storage system includes a computing end and a memory end. The computing end indexes the stored key-value pairs through a radix tree. In the method, a first key-value pair to be saved is obtained. The first key-value pair includes a first key and a first value. The first key includes multiple fragment keys. A first node is determined. The first node is a non-leaf node in the radix tree. Each node passed through by the path from the root node of the radix tree to the parent node of the first node includes at least one fragment key in the first key. In the first key, the at least one fragment key is located before the first fragment key. The content portion of the first node does not include the first fragment key. The first fragment key and first pointer information are saved in the first slot of one or more slots in the content portion of the first node. The first pointer information is used to point to the first leaf node. The first leaf node stores the first key-value pair. The first slot is an idle slot in the content portion. The address of the first slot is used to indicate the storage location of the first fragment key and the first pointer information in the memory end.
[0009] Since the first fragment key and the first pointer information are saved in a free slot in the content part of the first node, if other processors also need to save other fragment keys and other pointer information to the first node, the other processors also save other fragment keys and other pointer information to other free slots in the content part of the first node in the above manner. Since two processors can write data to two different free slots respectively without affecting each other, the first node does not need to set a lock. When each processor writes a key including a fragment key to the first node, it does not need to occupy the lock of the first node, so that multiple processors can write fragment keys to the first node in parallel, thereby improving the efficiency of writing data.
[0010] In one possible implementation, the first slot stores one or more of the following information: first indication information or the data volume of the first leaf node. The first indication information is used to indicate that the node pointed to by the first pointer information is a leaf node. In this way, when indexing a leaf node based on a key, the first leaf node can be accurately read based on the first indication information in the first slot or the data volume of the first leaf node.
[0011] In another possible implementation, the size of the first slot is equal to 8 bytes, so that the first fragment key and the first pointer information can be written into the first slot through one atomic operation.
[0012] In another possible implementation, the content portion of a first node stores fragment keys for multiple keys, and the header of the first node includes at least one consecutive common fragment key. This at least one common fragment key is the common fragment key of the multiple keys, and the multiple keys include a first key, and the fragment key preceding the first fragment key in the first key is the last common fragment key in the at least one common fragment key. Including the at least one common fragment key in the header thus implements path compression, reducing the path length corresponding to the first key in the radix tree.
[0013] In another possible implementation, the size of the header of the first node is equal to 8 bytes, which makes it easy to write data to the header of the first node through an atomic operation.
[0014] In another possible implementation, the header of the first node also includes a first type of the first node, where the first type indicates that the first node includes N slots, where N is an integer greater than 1 and that the first node does not include any free slots. M slots are added to the first node, and the first type included in the header of the first node is updated to a second type, where the second type indicates that the first node includes M+N slots, where M is an integer greater than 0. Adding slots to the first node ensures that there are sufficient slots to store the fragment key, and updating the first type of the header to the second type also avoids errors.
[0015] In another possible implementation, the first key also includes a second fragment key, and the second fragment key in the first key is the next fragment key after the first fragment key. Get the second key-value pair to be saved, the second key-value pair includes the second key and the second value, the second key includes the first fragment key and the third fragment key, the third fragment key in the second key is the next fragment key after the first fragment key, the fragment keys before the second fragment key in the first key and the fragment keys before the third fragment key in the second key are the same, and the second fragment key and the third fragment key are different. Determine the second node, the content part of the second node includes the second slot and the third slot, the second slot includes the second fragment key and the second pointer information, the third slot includes the third fragment key and the third pointer information, the second pointer information points to the first leaf node, the third pointer information points to the second leaf node, and the second leaf node stores the second key-value pair. Set the first pointer information to point to the second node.
[0016] Since the fragment keys before the second fragment key in the first key and the fragment keys before the third fragment key in the second key are the same, and the second fragment keys and third fragment keys are different, the first key-value pair and the second key-value pair are two leaf nodes stored in the first slot. Therefore, the second node is determined. The content portion of the second node includes the second slot and the third slot. The second slot includes the second fragment key and the second pointer information. The third slot includes the third fragment key and the third pointer information. The second pointer information points to the first leaf node, and the third pointer information points to the second leaf node. The first pointer information is set to point to the second node. This ensures that the first pointer information in the first slot points to the second node, and the first and second leaf nodes are child nodes of the two slots in the second node. This ensures that when reading the first key-value pair using the first key and the second key-value pair using the second key, the first leaf node can be accurately queried using the first key, and the second leaf node can be accurately queried using the second key. This ensures that the first key-value pair can be accurately read from the first leaf node, and the second key-value pair can be accurately read from the second leaf node.
[0017] In another possible implementation, the parent node of the first node includes fourth pointer information, the fourth pointer information points to the first node, the at least one public fragment key includes a fourth fragment key, and the fourth fragment key is not the first fragment key in the at least one public fragment key. The third key-value pair to be saved is obtained, the third key-value pair includes a third key and a third value, the third key includes a fifth fragment key, the fragment keys of the first key before the fourth fragment key and the fragment keys of the third key before the fifth fragment key are the same, and the fourth fragment key and the fifth fragment key are different. The third node and the fourth node are determined, the header of the third node includes the public fragment keys in the at least one public fragment key before the fourth fragment key, the content portion of the third node includes a fourth slot and a fifth slot, the fourth slot includes a fourth fragment key and a fifth pointer information, the fifth pointer information points to the fourth node, the fifth slot includes a fifth fragment key and a sixth pointer information, the sixth pointer information points to the third leaf node, the third leaf node stores the third key-value pair, and the content portion of the fourth node includes each slot in the first node. The fourth pointer information is set to point to the third node.
[0018] Since the fragment keys of the first key before the fourth fragment key and the fragment keys of the third key before the fifth fragment key are the same, the fourth fragment key and the fifth fragment key are different. In other words, the common fragment key before the fourth fragment key is the common fragment key of the first key and the third key, and the fourth fragment key and the common fragment key after the fourth fragment key are not the common fragment keys of the first key and the third key. Therefore, the head of the first node needs to be split. That is, the third node, the fourth node, and the third leaf node are determined. The head of the third node includes the fragment keys before the fourth fragment key in at least one common fragment key. The content of the third node includes the fourth slot and the fifth slot. The fourth slot includes the fourth fragment key and the fifth pointer information. The fifth pointer information points to the fourth node. The fifth slot includes the fifth fragment key and the sixth pointer information. The sixth pointer information points to the third leaf node. The head of the fourth node includes the fragment keys after the fourth fragment key in the at least one common fragment key. The content of the fourth node includes each slot in the first node. The third leaf node includes the third key-value pair. The fourth pointer information is set to point to the third node, thereby splitting the head of the first node. It is ensured that when reading the first key-value pair through the first key and reading the third key-value pair through the third key, the first leaf node can be accurately queried through the first key and the third leaf node can be accurately queried through the second key, so that the first key-value pair can be accurately read from the first leaf node and the third key-value pair can be accurately read from the third leaf node.
[0019] In another possible implementation, the fourth slot further includes one or more of the following information: second indication information or a node type of the fourth node, the second indication information being used to indicate that the fourth node pointed to by the fifth pointer information is a non-leaf node, and the node type of the fourth node being used to indicate the number of slots included in the fourth node. In this way, when indexing a leaf node based on a key, the fourth node can be accurately read based on the second indication information in the fourth slot or the node type of the fourth node.
[0020] In another possible implementation, the first leaf node also includes a first check code, the first check code is stored before the first key-value pair, and the first check code is obtained based on the first key-value pair. The fourth key-value pair to be saved and the second check code are obtained, the fourth key-value pair includes a first key and a fourth value, the first value and the fourth value are different, and the second check code is obtained based on the fourth key-value pair. The first check code and the first key-value pair included in the first leaf node are updated to the second check code and the fourth key-value pair respectively. Among them, the second check code can effectively avoid read-write conflicts, ensuring that the processor can successfully read the key-value pair in the first leaf node.
[0021] In another possible implementation, the first leaf node further includes a write operation lock. When the write operation lock is occupied, the first check code and the first key-value pair included in the first leaf node are updated to the second check code and the fourth key-value pair, respectively. In this way, by occupying the write operation lock, write-write conflicts can be avoided.
[0022] In a second aspect, the present application provides a data processing device for executing the method in the first aspect or any possible implementation of the first aspect. Specifically, the device includes a unit for executing the method in the first aspect or any possible implementation of the first aspect.
[0023] In a third aspect, the present application provides a data processing cluster, the cluster comprising at least one computing device, each of the at least one computing device comprising at least one processor and at least one memory, the at least one memory storing computer-readable instructions; the at least one processor executes the computer-readable instructions so that the cluster implements the method in the first aspect or any possible implementation of the first aspect.
[0024] In a fourth aspect, the present application provides a computer program product, which includes a computer program stored in a computer-readable storage medium, and the computer program is loaded by a processor to implement the method of the above-mentioned first aspect or any possible implementation method of the first aspect.
[0025] In a fifth aspect, the present application provides a computer-readable storage medium for storing a computer program, wherein the computer program is loaded by a processor to execute the method of the above-mentioned first aspect or any possible implementation of the first aspect.
[0026] In a sixth aspect, the present application provides a chip comprising a memory and a processor, wherein the memory is used to store computer instructions, and the processor is used to call and run the computer instructions from the memory to execute the method of the above-mentioned first aspect or any possible implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] FIG1 is a schematic diagram of the structure of a key-value storage system according to an embodiment of the present application;
[0028] FIG2 is a schematic diagram of the structure of a non-leaf node provided in an embodiment of the present application;
[0029] FIG3 is a schematic diagram of the structure of a leaf node provided in an embodiment of the present application;
[0030] FIG4 is a schematic diagram of the structure of a radix tree provided in an embodiment of the present application;
[0031] FIG5 is a flow chart of a data processing method provided in an embodiment of the present application;
[0032] FIG6 is a flow chart of a method for determining a first node provided in an embodiment of the present application;
[0033] FIG7 is a schematic diagram of the structure of another radix tree provided in an embodiment of the present application;
[0034] FIG8 is a flow chart of another data processing method provided in an embodiment of the present application;
[0035] FIG9 is a flowchart of another method for determining a first node provided in an embodiment of the present application;
[0036] FIG10 is a schematic diagram of the structure of another radix tree provided in an embodiment of the present application;
[0037] FIG11 is a flow chart of another data processing method provided in an embodiment of the present application;
[0038] FIG12 is a flowchart of another method for determining a first node provided in an embodiment of the present application;
[0039] FIG13 is a schematic diagram of the structure of another radix tree provided in an embodiment of the present application;
[0040] FIG14 is a flow chart of another data processing method provided in an embodiment of the present application;
[0041] FIG15 is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application;
[0042] FIG16 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0043] FIG17 is a schematic diagram of the structure of a data processing cluster provided in an embodiment of the present application;
[0044] FIG18 is a schematic diagram of the structure of another data processing cluster provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] In the description of this application, it should be understood that the terms "first", "second", etc. are used for descriptive purposes only and should not be understood to indicate or imply relative importance. In the description of this application, it should be noted that, unless otherwise expressly specified and limited, "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to the specific circumstances. In addition, in the description of this application, unless otherwise specified, "multiple" refers to two or more. "and / or" describes the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0046] To facilitate understanding of the solutions of the embodiments of the present application, the technical terms involved in this document are first explained below.
[0047] Memory separation architecture refers to an architecture in which the computing end and the memory end are decoupled. The computing end is connected to the memory end through a communication network, and the computing end reads and writes the memory end through the communication network.
[0048] A key-value storage system is a system that stores data in the form of key-value pairs.
[0049] A key-value pair is a pair of data consisting of a key and a value, where the key is the index information of the value.
[0050] A partial key is a component of a key. A key often includes multiple fragment keys.
[0051] A radix tree is a tree index structure that indexes by matching fragment keys. The leaf nodes of the radix tree are used to store key-value pairs, and the non-leaf nodes are used to store fragment keys. The key-value pairs including the key are obtained by matching the fragment key in the key to be queried with the radix tree index.
[0052] A leaf node is a node in a radix tree that is used to store key-value pairs. A leaf node is a storage space in the memory.
[0053] Non-leaf nodes, also known as internal nodes of the radix tree, consist of a header and a content portion. They also represent a storage space within the memory. Optionally, the header of a non-leaf node can be 8 bytes in size, and the content can be an integer multiple of 8 bytes.
[0054] A slot is an 8-byte storage space in the content portion of a non-leaf node that can be read and written through atomic operations.
[0055] Atomic operations are data writing operations. Atomic operations are indivisible and will not be interrupted by any other tasks or events before the data writing is completed. The amount of data that can be written by an atomic operation does not exceed 8 bytes.
[0056] The embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
[0057] 1 , an embodiment of the present application provides a key-value storage system 100 with a memory separation architecture. The key-value storage system 100 includes a computing end 101 and a memory end 102 , and the computing end 101 communicates with the memory end 102 .
[0058] In some embodiments, both the computing end 101 and the memory end 102 are connected to a communication network, and the computing end 101 communicates with the memory end 102 through the communication network.
[0059] 1 , the computing end 101 includes multiple processors 1011 , and the memory end 102 includes multiple memories 1021 . Each processor 1011 in the computing end 101 can read and write one or more memories 1021 in the memory end 102 .
[0060] In some embodiments, the memory terminal 102 stores data in a key-value pair storage manner. The processor 1011 in the computing terminal 101 reads and writes the key-value pairs stored in the memory terminal 102 using a radix tree stored in the memory terminal 102 .
[0061] In some embodiments, the multiple processors 1011 include one or more of the following: a central processing unit (CPU), a graphics processing unit (GPU), or a network processing unit (NPU).
[0062] A key-value pair includes a key and a value, and a key includes multiple fragment keys. For example, if the key is hexadecimal data and each fragment key includes two hexadecimal digits, assuming the key is 0012567843CC, the key includes six fragment keys, and the six fragment keys are 00, 12, 56, 78, 43, and CC.
[0063] Nodes in a radix tree include leaf nodes and non-leaf nodes. Leaf nodes store key-value pairs. Non-leaf nodes include a header and a content portion. The content portion stores at least one fragment key, which corresponds one-to-one with at least one key. Any fragment key in the at least one fragment key belongs to the key corresponding to the fragment key. In other words, the content portion contains a fragment key for each key in the at least one key.
[0064] In some embodiments, the header may store at least one common fragment key, which is a common fragment key in multiple keys. In this case, the content part includes multiple fragment keys, and the multiple fragment keys correspond one-to-one to the multiple keys.
[0065] The path corresponding to each key in the at least one key in the radix tree is long, so at least one common fragment key in the at least one key is compressed in the header by using path compression, thereby reducing the path length corresponding to each key.
[0066] In some embodiments, a leaf node includes a key and a value corresponding to the key, and for each non-leaf node passed through by the path from the root node to the leaf node in the radix tree, each non-leaf node includes one or more fragment keys in the key.
[0067] For any processor 1011 in the computing end 101, when the processor 1011 needs to read the key-value pair included in the leaf node, it obtains the key, matches the fragment key included in the key with the node in the radix tree, and can match the path from the root node to the leaf node. Based on the path, the leaf node is obtained and the key-value pair included in the leaf node is read.
[0068] In some embodiments, referring to FIG. 1 , the computing end 101 further includes a plurality of caches 1012 , the plurality of processors 1011 correspond one to one with the plurality of caches 1012 , and each processor 1011 can read and write the cache 1012 corresponding to each processor 1011 .
[0069] Referring to FIG2 , for each non-leaf node in the radix tree, the non-leaf node includes a header and a content portion, and the header includes a first storage space 11 , a second storage space 12 , a third storage space 13 and / or a fourth storage space 14 , etc.
[0070] The first storage space 11 is used to store the depth of the fragment keys in the content portion, the second storage space 12 is used to store the node type of the non-leaf node, the third storage space 13 is used to store the number of public fragment keys, and the fourth storage space 14 is used to store the number of public fragment keys. If the number of public fragment keys stored in the third storage space 13 is 0, the fourth storage space 14 is empty.
[0071] FIG2 shows an example of the header structure. The header is 8 bytes in size, with first storage space 11 being 8 bits, second storage space 12 being 5 bits, third storage space 13 being 3 bits, and fourth storage space 14 being 6 bytes. Assuming each public segment key is two hexadecimal digits, fourth storage space 14 can store no more than six public segment keys.
[0072] If there are many common fragment keys between multiple keys, which exceeds the maximum number of common fragment keys that can be included in the head of a non-leaf node, then another non-leaf node is used to store the common fragment keys. Assuming there are 10 common fragment keys, and the maximum number of common fragment keys included in the head of the non-leaf node is 6, the fourth storage space 14 of the head of the non-leaf node includes the 1st to 6th common fragment keys, and the content part of the non-leaf node includes a slot that stores the 7th common fragment key and pointer information pointing to a child node. The child node is a non-leaf node, and the fourth storage space of the head of the child node includes the 8th to 10th common fragment keys. The content part of the child node includes multiple fragment keys, and the multiple fragment keys belong to the multiple keys.
[0073] The content portion of the non-leaf node is used to store at least one fragment key and at least one pointer information, the at least one fragment key and the at least one pointer information have a one-to-one correspondence, and the at least one fragment key belongs to at least one key. For each key in the at least one key, and for a fragment key of the key stored in the content portion, the depth stored in the first storage space 11 of the head of the non-leaf node is the depth of the fragment key in the key, and the depth is used to indicate the position of the fragment key in the key. For example, assuming that the fragment key is the i-th fragment key in the key, the depth can be i-1, i=1, 2,... If the fourth storage space 14 stores a public fragment key, the public fragment key is the public fragment key of the at least one key.
[0074] Referring to FIG. 2 , the content portion of the non-leaf node includes a plurality of slots, i.e., the content portion of the non-leaf node can be divided into a plurality of slots of equal size. The at least one fragment key is stored in at least one slot. The node type in the non-leaf node is used to indicate the number of slots included in the non-leaf node.
[0075] In some embodiments, the number of slots included in the non-leaf node may be 4, 8, 16, 32, 64, or 128. Assume that the number of slots included in the non-leaf node is 4, and a fragment key and pointer information corresponding to the fragment key can be stored in each slot of the non-leaf node, that is, 4 fragment keys and 4 pointer information corresponding to the 4 fragment keys are stored in the 4 slots.
[0076] In some embodiments, the node type of the non-leaf node is N4, N8, N16, or N32. For example, the node type of the non-leaf node is N4, indicating that the number of slots included in the content portion of the non-leaf node is 4; the node type of the non-leaf node is N8, indicating that the number of slots included in the content portion of the non-leaf node is 8; and the node type of the non-leaf node is N16, indicating that the number of slots included in the content portion of the non-leaf node is 16.
[0077] 2 , for each slot, the slot includes a fifth storage space 21 , a sixth storage space 22 , a seventh storage space 23 and / or an eighth storage space 24 .
[0078] The fifth storage space 21 is used to store the partial key of the key. The eighth storage space 24 is used to store pointer information (child pointer), which is used to point to a child node of the non-leaf node.
[0079] The sixth storage space 22 is used to store indication information (leaf), which indicates whether the child node is a leaf node or a non-leaf node. If the child node is a non-leaf node, the indication information stored in the sixth storage space 22 is the first indication information (for example, represented by leaf=0), which indicates that the child node pointed to by the pointer information is a non-leaf node. The seventh storage space 23 is used to store the node type (typenode) of the child node. Optionally, the node type of the child node may be N4, N8, N16, or N32, etc.
[0080] If the child node is a leaf node, the sixth storage space 22 stores the second indication information (e.g., leaf=1), which indicates that the child node pointed to by the pointer is a leaf node. The seventh storage space 23 stores the data size of the leaf node (lenleaf).
[0081] For example, the leaf node shown in FIG3 occupies 80 bits in total, that is, the data volume of the leaf node is 10 bytes.
[0082] In some embodiments, the size of each header in the non-leaf node is less than or equal to 8 bytes. Assume that the size of the first storage space 11 is 8 bits, the size of the second storage space 12 is 5 bits, the size of the third storage space 13 is 3 bits, and the size of the fourth storage space 14 is 6 bytes. Thus, the size of the header of the non-leaf node is 8 bytes.
[0083] In some embodiments, each slot in the non-leaf node is a space of a specified size. Optionally, the specified size is equal to 8 bytes.
[0084] Assume that the child node pointed to by the pointer information stored in the eighth storage space 24 of the slot is a non-leaf node. The size of the fifth storage space 21 is 8 bits, the size of the sixth storage space 22 is 1 bit, the size of the seventh storage space 23 is 5 bits, and the size of the eighth storage space 24 is 48 bits. The size of the slot is 62 bits, and the slot also includes 2 bits of reserved bits, so the size of the slot is 64 bits, which is equal to 8 bytes. In this case, when writing data to the slot through an atomic operation implemented by masking, the amount of data written to the slot can be less than 8 bytes.
[0085] Assume that the child node pointed to by the pointer information stored in the eighth storage space 24 of this slot is a leaf node. The size of the fifth storage space 21 is 8 bits, the size of the sixth storage space 22 is 1 bit, the size of the seventh storage space 23 is 7 bits, and the size of the eighth storage space 24 is 48 bits. The size of this slot is 64 bits, which is equal to 8 bytes.
[0086] In some embodiments, when the size of the slot is 8 bytes, the fragment key and pointer information can be saved to the slot through an atomic operation. The amount of data saved to the slot may be equal to 8 bytes, or may be less than 8 bytes.
[0087] In some embodiments, the head of the non-leaf node also includes pointer information (reverse pointer) pointing to the parent node of the non-leaf node. Referring to Figure 2, the pointer information is located before the head of the non-leaf node.
[0088] Referring to Figure 3, for each leaf node in the radix tree, the leaf node includes a checksum, a key-value pair, and a write lock. The checksum is obtained based on the key-value pair and is used to verify the key-value pair. The write lock is used to indicate whether data is currently being written to the leaf node. If data has been written to the leaf node, the write lock indicates that data has been written to the leaf node. If data is being written to the leaf node, the write lock indicates that data is being written to the leaf node.
[0089] In some embodiments, the check code is a parity check code or a cyclic redundancy check (CRC) code.
[0090] In some embodiments, the leaf node also includes pointer information (reverse pointer) and / or valid information (valid) of the parent node, where the pointer information is used to point to the parent node of the leaf node, and the valid information is used to indicate whether the leaf node is valid.
[0091] In some embodiments, when the memory terminal 102 deletes the leaf node, if the leaf node is being read by a processor, the valid information in the leaf node is set to indicate that the leaf node is invalid. After the processor finishes reading the leaf node, the space occupied by the leaf node is released.
[0092] In this way, before releasing the space occupied by the leaf node, if other processors come to read and write the leaf node and find that the valid information in the leaf node indicates that the leaf node is invalid, they stop reading and writing the leaf node.
[0093] In some embodiments, the write operation lock may be a single bit, where when the bit value is 1, it indicates that the write operation lock indicates that data has been written to the leaf node, and when the bit value is 0, it indicates that the write operation lock indicates that data is being written to the leaf node. Alternatively, when the bit value is 0, it indicates that the write operation lock indicates that data has been written to the leaf node, and when the bit value is 1, it indicates that the write operation lock indicates that data is being written to the leaf node.
[0094] In some embodiments, the validity information may be a single bit, where a bit value of 1 indicates that the leaf node is valid, and a bit value of 0 indicates that the leaf node is invalid. Alternatively, a bit value of 0 indicates that the leaf node is valid, and a bit value of 1 indicates that the leaf node is invalid.
[0095] For example, referring to the radix tree shown in Figure 4, the root node, node A, node B and node E (node E is not described in detail in the figure) are all non-leaf nodes of the radix tree, and node C, node D, node F and node G (node F and node G are not described in detail in the figure) are all leaf nodes.
[0096] The header of the root node includes the depth "0" of the fragment key in the content part of the root node, the node type "N4" of the root node and the number of public fragment keys "0", that is, the header of the root node does not include a public fragment key. The content part of the root node includes four slots, and the first slot includes the fragment key 00 and pointer information pointing to node A (not shown in the figure). Among them, N4 indicates that the content part of the root node includes four slots, which means that the content part of the root node can store 4 fragment keys. The depth "0" of the fragment key means that the position of the fragment key 00 in the content part in the key is 0, that is, the fragment key 00 is the first fragment key in the key. Assume that the key may be 0012567843CC, and the fragment key 00 is the first fragment key in 0012567843CC.
[0097] The header of node A includes the depth "1" of the fragment key in the content part of node A, the node type "N4" of node A and the number of public fragment keys "0", that is, the header of node A does not include a public fragment key. The content part of node A includes four slots, the first slot includes the fragment key 12 and pointer information pointing to node B (not shown in the figure), and the second slot includes the fragment key 34 and pointer information pointing to node E. Among them, the depth "1" of the fragment key means that the position of the fragment key in the content part in the key is 1, that is, the fragment key in the content part is the second fragment key in the key. For example, the fragment key 12 in the content part is the second fragment key in two keys, and the two keys are 0012567843CC and 00125678FF25.
[0098] The header of node B includes the depth "4" of the fragment key in the content part of node B, the node type "N4" of node B, the number of public fragment keys "2", and two public fragment keys "56" and "78". The content part of node B includes four slots, the first slot includes the fragment key 43 and the pointer information pointing to the leaf node C (not shown in the figure), and the second slot includes the fragment key FF and the pointer information pointing to the leaf node D. Among them, the depth "4" of the fragment key means that the position of the fragment key in the content part in the key is 4, that is, the fragment key in the content part is the 5th fragment key in the key. For example, the fragment key 43 in the content part is the 5th fragment key in the key, and the key is 0012567843CC; the fragment key FF in the content part is the 5th fragment key in the key, and the key is 00125678FF25.
[0099] Leaf node C includes a key-value pair including key1 and value1, where key1 is "0012567843CC". Leaf node D includes a key-value pair including key2 and value2, where key2 is "00125678FF25".
[0100] Assume that when processor 1011 needs to obtain the value corresponding to key1, it obtains key1 "0012567843CC". The first fragment key "00" of key1 matches the fragment key "00" in the first slot of the root node, so the node A pointed to by the pointer information included in the first slot of the root node is obtained. The second fragment key "12" of key1 matches the fragment key "12" in the first slot of node A, and the node B pointed to by the pointer information included in the first slot of node A is obtained. The third fragment key "56" and the fourth fragment key "78" of key1 match the public fragment keys "56" and "78" in the header of node B respectively, and the fifth fragment key "43" of key1 matches the fragment key "43" in the first slot of node B, and the node C pointed to by the pointer information included in the first slot of node B is obtained. Node C is a leaf node, so processor 1011 obtains value1 corresponding to key1 from node C.
[0101] In some embodiments, the radix tree is stored in the memory end 102, and the radix tree includes a large number of non-leaf nodes. For each processor 1011 in the computing end 101, the number of keys that the processor 1011 needs to query is limited. In order to improve the efficiency of the processor 1011 querying the memory end 102, some of the non-leaf nodes included in the radix tree can be cached in the cache 1012 corresponding to the processor 1011, and each leaf node of the radix tree is stored on the memory end 102. These leaf nodes include fragment keys in the key that the processor 1011 needs to query.
[0102] For example, referring to Figure 4, assuming that processor 1011 needs to query key1 and key2, the root node, node A and node B all include the fragment key of key1 and the fragment key of key2, so the root node, node A and node B can be cached in the cache 1012 corresponding to processor 1011.
[0103] 5 , an embodiment of the present application provides a data processing method 500 , which is applied to the network architecture 100 shown in FIG1 . The method 500 includes:
[0104] Step 501: Obtain a first key-value pair to be saved, where the first key-value pair includes a first key and a first value, and the first key includes multiple fragment keys.
[0105] The first key-value pair to be saved is a key-value pair that the processor needs to save to the memory end.
[0106] For example, the processor obtains a first key-value pair to be saved to the memory end, the first key-value pair includes a first key "00125678441A" and "value3", and the first key "00125678441A" includes six fragment keys.
[0107] Step 502: Determine the first node.
[0108] The first node is a non-leaf node in the radix tree, each node passed by the path from the root node of the radix tree to the parent node of the first node includes at least one fragment key in the first key, the at least one fragment key is located before the first fragment key in the first key, the content portion of the first node does not include the first fragment key, and the first leaf node includes a first key-value pair.
[0109] In some embodiments, the head of the first node may further include at least one consecutive common fragment key, where the last fragment key of the at least one common fragment key is the previous fragment key of the first fragment key in the first key.
[0110] For example, referring to Figure 4 , the first node is Node B, the first fragment key is "44," the parent node of the first node is Node A, and each node along the path from the root node to the parent node of the first node includes the root node and Node A. Both the root node and Node A include the fragment keys in the first key. As shown in Figure 4 , the root node includes the first fragment key "00" in the first key, and Node A includes the second fragment key "12" in the first key. The public fragment key in the header of Node B also includes the third fragment key "56" and the fourth fragment key "78" of the first key, and the content portion of Node B does not include the first fragment key "44."
[0111] In step 502, referring to FIG6, a first node is determined through the following operations.
[0112] 5021: Match the first fragment key included in the first key with the fragment keys included in each slot in the root node, and match the slot including the first fragment key.
[0113] In some embodiments, the slot includes pointer information, first indication information and the node type of the node pointed to by the pointer information. Based on the first indication information, the node is determined to be a non-leaf node. Based on the node type, the number of slots included in the content part of the node is obtained. Based on the header size of the node and the number of slots included in the content part, the size of the node is obtained.
[0114] 5022: Get the node pointed to by the pointer information included in the slot, and determine whether the head of the node includes a public fragment key. If the node includes a public fragment key, execute 5023; if the node does not include a public fragment key, execute 5025.
[0115] In 5022, based on the size of the node, the node is obtained from the location indicated by the pointer information in the memory.
[0116] In some embodiments, the head of the node includes the number of public fragment keys. If the number of public fragment keys is greater than 0, it is determined that the head of the node includes the public fragment key. If the number of public fragment keys is equal to 0, it is determined that the head of the node does not include the public fragment key.
[0117] In some embodiments, the node in the slot is the parent node of the node, and the parent node may be located in the cache corresponding to the processor. The node may also be located in the cache corresponding to the processor, and the node pointed to by the pointer information included in the slot is obtained from the cache. Alternatively, if the node is not in the cache corresponding to the processor, the node pointed to by the pointer information included in the slot is obtained from the memory.
[0118] In some embodiments, the node header includes the node type of the node. If the node type included in the node header differs from the node type of the node in the slot, the parent node in the cache is invalid. Therefore, the parent node is also obtained from the memory, and the parent node in the cache is updated to the parent node obtained from the memory.
[0119] 5023: Determine whether the x fragment keys included in the header of the node are the same as the i+1th to i+xth fragment keys included in the first key. If they are the same, execute 5024, where x is an integer greater than or equal to 1.
[0120] The initial value of i is 1.
[0121] 5024: Match the i+x+1th fragment key included in the first key with the fragment keys included in each slot in the node. If a slot including the i+x+1th fragment key is matched, set i=i+x+1 and execute 5022. If no slot including the i+x+1th fragment key is matched, set the node as the first node and end.
[0122] 5025: Match the i+1th fragment key included in the first key with the fragment keys included in each slot in the node. If a slot including the i+1th fragment key is matched, set i=i+1 and execute 5022. If a slot including the i+1th fragment key is not matched, set the node as the first node and end.
[0123] For example, the first fragment key "00" in the first key "00125678441A" is matched with the fragment keys included in each slot in the root node shown in Figure 4, and the slot including the fragment key "00" is matched, which includes pointer information pointing to node A.
[0124] Get the node A pointed to by the pointer information. The head of node A does not include a public fragment key. Match the second fragment key "12" in the first key with the fragment keys included in each slot in node A. Match the slot including the fragment key "12", which includes pointer information pointing to node B.
[0125] Get the node B pointed to by the pointer information. The header of node B includes two public fragment keys. The third and fourth fragment keys "56" and "78" in the first key are the same as the two public fragment keys "56" and "78" included in the header of node B, respectively. Match the fifth fragment key "44" in the first key with the fragment keys included in each slot in node B. Match the slots that do not include the fragment key "44" and set node B as the first node.
[0126] In step 502, a first leaf node is created, and the first leaf node stores a first key-value pair. Optionally, a storage space corresponding to the first leaf node is allocated in the memory end, and the first key-value pair is stored in the storage space.
[0127] In some embodiments, a check code is generated based on the first key-value pair, and the first leaf node also includes the check code, and the storage location of the check code is located before the storage location of the first key-value pair.
[0128] In some embodiments, the first leaf node further includes validity information, a write operation lock, and / or pointer information of the parent node of the first leaf node. The write operation lock is used to indicate that data has been written to the first leaf node, and the validity information is used to indicate that the first leaf node is valid and the parent node of the first leaf node is the first node.
[0129] For example, referring to FIG7 , a node H including a first key-value pair is generated in the memory of the memory end, and the first key-value pair is “00125678441A”-value3.
[0130] Step 503: Save the first fragment key and the first pointer information in the first slot of one or more slots in the content part of the first node, where the first pointer information is used to point to the first leaf node, and the first slot is an idle slot in the content part of the first node.
[0131] The address of the first slot is used to indicate the storage location of the first fragment key and the first pointer information in the memory end.
[0132] In some embodiments, first indication information and / or the data volume of the first leaf node is also saved in the first slot, and the first indication information is used to indicate that the node pointed to by the first pointer information is a leaf node.
[0133] In some embodiments, the first pointer information includes the address of the first leaf node in the memory, etc.
[0134] In step 503, if the content portion of the first node includes free slots, an free slot is selected as the first slot, and the first fragment key and first pointer information are stored in the first slot. If the content portion of the first node does not include free slots, multiple slots are added to the content portion of the first node, a slot is selected from the multiple slots as the first slot, and the first fragment key and first pointer information are stored in the first slot. Optionally, first indication information and / or the data size of the first leaf node are also stored in the first slot.
[0135] In some embodiments, an atomic operation is used to save data (such as the first fragment key and the first pointer information) to the first slot. Optionally, the atomic operation can be a remote direct memory access compare and swap (RDMA CAS) operation.
[0136] For example, referring to Figure 7 , the third and fourth slots of node B are both idle slots, and the first fragment key "44," first indication information, the data volume of node H, and first pointer information are stored in the third slot (i.e., the third slot is the first slot). The first pointer information is used to point to node H, and the first indication information is used to indicate that node H is a leaf node.
[0137] In some embodiments, for a first type of the first node included in the header of the first node, the first type indicates that the number of slots included in the first node is N, where N is an integer greater than 1. If multiple slots are added to the content portion of the first node, the number of the multiple slots is M, where M is an integer greater than 1. In this case, the number of slots included in the first node is N+M, and therefore the first type included in the header of the first node needs to be updated to the second type. The second type indicates that the number of slots included in the first node is M+N.
[0138] When generating the first node, the memory allocates Z slots in the memory, where Z is greater than or equal to M+N. N slots are selected from the Z slots and allocated to the first node, so that the content portion of the first node includes N slots. When the processor adds M slots to the content portion of the first node, it sends a request to the memory. The memory selects M slots from the remaining ZN slots and allocates them to the first node, so that the content portion of the first node includes M+N slots.
[0139] For example, assume that the first type included in the header of the first node is N4, indicating that the number of slots included in the first node is 4, that is, N = 4. The number of slots included in the content portion of the first node before the addition is 4. Four slots are added to the content portion of the first node. After the addition, the number of slots included in the content portion of the first node is 8. The first type N4 included in the header of the first node is then updated to the second type N8. The second type N8 indicates that the number of slots included in the content portion of the first node is 8.
[0140] In an embodiment of the present application, since the first fragment key and the first pointer information are saved in a free slot in the content part of the first node, if other processors also need to save other fragment keys and other pointer information to the first node, the other processors save the other fragment keys and other pointer information in other free slots in the content part of the first node. Since the two processors write data to two different free slots respectively, the two do not affect each other, so the first node does not need to set a lock. Each processor needs to save the key-value pair to the memory end, and does not occupy the lock of the first node when writing the fragment key included in the key in the key-value pair to the first node, so that multiple processors can add fragment keys to the first node in parallel, thereby improving the efficiency of writing fragment keys, that is, improving the efficiency of writing data to the first node and the efficiency of saving key-value pairs to the memory end.
[0141] 8 , an embodiment of the present application provides a data processing method 800 , which is applied to the network architecture 100 shown in FIG1 . The method 800 includes:
[0142] Step 801: Obtain a second key-value pair to be saved, where the second key-value pair includes a second key and a second value.
[0143] Assuming that the first fragment key is not the last fragment key of the first key, for ease of explanation, the next fragment key after the first fragment key in the first key is called the second fragment key. The second key includes the first fragment key and the third fragment key. In the second key, the third fragment key is the next fragment key after the first fragment key. The fragment keys before the second fragment key of the first key and the fragment keys before the third fragment key of the second key are the same, and the second fragment key and the third fragment key are different.
[0144] For example, the processor obtains the second key-value pair to be saved to the memory end, and the second key-value pair includes the second key "001256784498" and "value4". In the first key "00125678441A", the next fragment key after the first fragment key "44" is "1A", that is, the second fragment key is "1A". In the second key "001256784498", the next fragment key after the first fragment key "44" is "98", that is, the third fragment key is "98". The fragment keys before the second fragment key "1A" in the first key "00125678441A" and the fragment keys before the third fragment key "98" in the second key "001256784498" are the same.
[0145] Step 802: Determine the first node.
[0146] A first node is a non-leaf node in a radix tree. A content portion of the first node includes a first fragment key. Each node in a path from the root node of the radix tree to the parent node of the first node includes at least one fragment key in a second key, and the at least one fragment key is located before the first fragment key. For a first slot in the first node that includes the first fragment key, first pointer information included in the first slot points to a first leaf node.
[0147] In some embodiments, the head of the first node may further include at least one consecutive common fragment key, where the last fragment key of the at least one common fragment key is the previous fragment key of the first fragment key in the second key.
[0148] For example, referring to Figure 7, the first node is node B, the first fragment key is "44", the parent node of the first node is node A, and each node passed through by the path from the root node to the parent node of the first node includes the root node and node A. The root node and node A both include the fragment key in the second key. As shown in Figure 8, the root node includes the first fragment key "00" in the second key, and node A includes the second fragment key "12" in the second key. The public fragment key of the head of node B also includes the third fragment key "56" and the fourth fragment key "78" of the second key, and the content part of node B includes the first fragment key "44". The first pointer information in the third slot including the first fragment key "44" in node B points to the first leaf node H.
[0149] In step 802, referring to FIG. 9 , a first node is determined through the following operations.
[0150] 8021: Match the first fragment key included in the second key with the fragment keys included in each slot in the root node, and match the slot including the first fragment key.
[0151] In some embodiments, the slot includes pointer information, first indication information and the node type of the node pointed to by the pointer information. Based on the first indication information, the node is determined to be a non-leaf node. Based on the node type, the number of slots included in the content part of the node is obtained. Based on the header size of the node and the number of slots included in the content part, the size of the node is obtained.
[0152] 8022: Get the node pointed to by the pointer information included in the slot, and determine whether the head of the node includes a public fragment key. If the node includes a public fragment key, execute 8023; if the node does not include a public fragment key, execute 8026.
[0153] In 8022, based on the size of the node, the node is obtained from the location indicated by the pointer information in the memory.
[0154] In some embodiments, the head of the node includes the number of public fragment keys. If the number of public fragment keys is greater than 0, it is determined that the head of the node includes the public fragment key. If the number of public fragment keys is equal to 0, it is determined that the head of the node does not include the public fragment key.
[0155] 8023: Determine whether the x fragment keys included in the header of the node are the same as the i+1 to i+x fragment keys included in the second key. If they are the same, execute 8024, where x is an integer greater than or equal to 1.
[0156] The initial value of i is 1.
[0157] 8024: Match the i+x+1th fragment key included in the second key with the fragment keys included in each slot in the node. If a slot including the i+x+1th fragment key is matched, execute 8025.
[0158] 8025: Determine whether the node pointed to by the pointer information included in the slot is a leaf node. If the node pointed to by the pointer information included in the slot is a non-leaf node, set i=i+x+1 and execute 8022. If the node pointed to by the pointer information included in the slot is a leaf node, use the node as the first node and end.
[0159] When the indication information included in the slot is the first indication information, it is determined that the node pointed to by the pointer information included in the slot is a leaf node. When the indication information included in the slot is the second indication information, it is determined that the node pointed to by the pointer information included in the slot is a non-leaf node.
[0160] If the node pointed to by the pointer information included in the slot is a leaf node, the i+x+1th fragment key included in the second key is the first fragment key.
[0161] 8026: Match the i+1th fragment key included in the second key with the fragment keys included in each slot in the node. If a slot including the i+1th fragment key is matched, execute 8027.
[0162] 8027: Determine whether the node pointed to by the pointer information included in the slot is a leaf node. If the node pointed to by the pointer information included in the slot is a non-leaf node, set i=i+1 and execute 8022. If the node pointed to by the pointer information included in the slot is a leaf node, use the node as the first node and end.
[0163] If the node pointed to by the pointer information included in the slot is a leaf node, the i+1th fragment key included in the second key is the first fragment key.
[0164] For example, the first fragment key "00" in the second key "001256784498" is matched with the fragment keys included in each slot in the root node shown in Figure 7, and the slot including the fragment key "00" is matched, which includes pointer information pointing to node A.
[0165] Get the node A pointed to by the pointer information. The head of node A does not include a public fragment key. Match the second fragment key "12" in the second key with the fragment keys included in each slot in node A. Match the slot including the fragment key "12", which includes pointer information pointing to node B.
[0166] Get the node B pointed to by the pointer information. The header of node B includes two public fragment keys. The third to fourth fragment keys "56" and "78" in the second key are respectively the same as the two public fragment keys "56" and "78" included in the header of node B. Match the fifth fragment key "44" in the second key with the fragment keys included in each slot in node B to match the slot including the fragment key "44". Among them, the pointer information in the slot including the fragment key "44" points to the first leaf node H, and node B is used as the first node.
[0167] Step 803: Create a second node and a second leaf node.
[0168] In step 803, a second node and a second leaf node are generated in the memory of the memory terminal. The content portion of the second node includes a second slot and a third slot, the second slot includes a second fragment key and second pointer information, the third slot includes a third fragment key and third pointer information, the second pointer information points to the first leaf node and the third pointer information points to the second leaf node, and the second leaf node stores the second key-value pair.
[0169] For the second fragment key, the first slot containing the first fragment key is retrieved from the content portion of the first node. The first leaf node is determined based on the first pointer information contained in the first slot and the size of the first leaf node. The next fragment key following the first fragment key is retrieved from the first key contained in the first leaf node as the second fragment key.
[0170] For example, referring to Figure 10 , the first node is node B, the first fragment key is "44," and the third slot in node B includes the first fragment key "44." The first leaf node H is determined based on the first pointer information included in the third slot and the size of the first leaf node H. From the first key "00125678441A" included in the first leaf node H, the next fragment key "1A" following the first fragment key "44" is obtained as the second fragment key.
[0171] A second node J and a second leaf node K are generated in the memory of the memory end. The first slot in the content portion of the second node J (the first slot in the second node J is the second slot) includes the second fragment key "1A" and second pointer information pointing to the first leaf node H, and the second slot (the second slot in the second node J is the third slot) includes the second pointer information of the third fragment key "98" pointing to the second leaf node K.
[0172] Step 804: Set the first pointer information to point to the second node.
[0173] For example, referring to FIG10 , the third slot in the node B includes first pointer information, and the first pointer information points to the second node J.
[0174] In an embodiment of the present application, the first key also includes a second fragment key, and the second fragment key in the first key is the next fragment key after the first fragment key. A second key-value pair to be saved is obtained, and the first node is determined based on the second key included in the second key-value pair. The second key includes a first fragment key and a third fragment key, and in the second key, the third fragment key is the next fragment key after the first fragment key. The fragment keys before the second fragment key in the first key and the fragment keys before the third fragment key in the second key are the same, and the second fragment key and the third fragment key are different. In other words, the first key-value pair and the second key-value pair should be saved in the two leaf nodes under the first slot. Therefore, a second node and a second leaf node are created. The content portion of the second node includes the second slot and the third slot. The second slot includes the second fragment key and second pointer information. The third slot includes the third fragment key and third pointer information. The second pointer information points to the first leaf node, and the third pointer information points to the second leaf node. The first pointer information is set to point to the second node. This makes the first pointer information in the first slot point to the second node, and the first leaf node and the second leaf node are child nodes under the two slots in the second node. It is ensured that when reading the first key-value pair through the first key and reading the second key-value pair through the second key, the first leaf node can be accurately queried through the first key and the second leaf node can be accurately queried through the second key, so that the first key-value pair can be accurately read from the first leaf node and the second key-value pair can be accurately read from the second leaf node.
[0175] Referring to FIG11 , an embodiment of the present application provides a data processing method 1100 , which is applied to the network architecture 100 shown in FIG1 . In the method shown in FIG5 , the parent node of the first node includes fourth pointer information, the fourth pointer information points to the first node, and at least one consecutive public fragment key in the header of the first node includes the fourth fragment key, which is not the first public fragment key. The method 1100 includes:
[0176] Step 1101: Obtain a third key-value pair to be saved, where the third key-value pair includes a third key and a third value.
[0177] The third key includes the fifth fragment key, the fragment keys of the first key before the fourth fragment key and the fragment keys of the third key before the fifth fragment key are the same, and the fourth fragment key and the fifth fragment key are different.
[0178] For example, the processor obtains the third key-value pair to be saved to the memory end, and the third key-value pair includes the third key "0012564644FF" and "value5". The first key is "00125678441A", and the fifth fragment key is "46". The first node is node B in Figure 7, and the head of node B includes two public fragment keys, which are "56" and "78", and the fourth fragment key is "78". The fragment keys before the fourth fragment key "78" in the first key "00125678441A" are the same as the fragment keys before the fifth fragment key "46" in the third key "0012564644FF".
[0179] Step 1102: Determine the first node.
[0180] The first node is a non-leaf node in the radix tree, the head of the first node includes the fourth fragment key but does not include the fifth fragment key, and each node passed by the path from the root node of the radix tree to the parent node of the first node includes at least one fragment key in the third key, and the at least one fragment key is located before the fifth fragment key.
[0181] In some embodiments, the third key further includes a fragment key that precedes the fourth fragment key in the public fragment key of the header of the first node.
[0182] For example, referring to Figure 7 , the first node is Node B, the fourth fragment key is "78," the parent node of the first node is Node A, and each node along the path from the root node to the parent node of the first node includes the root node and Node A. Both the root node and Node A include the fragment keys in the third key. As shown in Figure 7 , the root node includes the first fragment key "00" in the third key, and Node A includes the second fragment key "12" in the third key. The public fragment key at the head of Node B includes the fragment keys "56" and "78," and the third key "0012564644FF" also includes the public fragment key "56" before the fourth fragment key is "78."
[0183] In step 1102, referring to FIG. 12 , the first node is determined through the following operations.
[0184] 1021: Match the first fragment key included in the third key with the fragment key included in each slot in the root node, and match the slot including the first fragment key.
[0185] In some embodiments, the slot includes pointer information, first indication information and the node type of the node pointed to by the pointer information. Based on the first indication information, the node is determined to be a non-leaf node. Based on the node type, the number of slots included in the content part of the node is obtained. Based on the header size of the node and the number of slots included in the content part, the size of the node is obtained.
[0186] 1022: Get the node pointed to by the pointer information included in the slot, and determine whether the head of the node includes a public fragment key. If the node includes x public fragment keys, execute 1023; if the node does not include a public fragment key, execute 1025, where x is an integer greater than or equal to 1.
[0187] In 1022 , based on the size of the node, the node is obtained from the location indicated by the pointer information in the memory.
[0188] In some embodiments, the head of the node includes the number of public fragment keys. If the number of public fragment keys is greater than 0, it is determined that the head of the node includes the public fragment key. If the number of public fragment keys is equal to 0, it is determined that the head of the node does not include the public fragment key.
[0189] 1023: Compare the x fragment keys included in the node header with the i+1th to i+xth fragment keys included in the second key. If the x fragment keys included in the node header are the same as the i+1th to i+xth fragment keys included in the second key, execute 1024. If the first y fragment keys included in the node header are the same as the i+1th to i+yth fragment keys included in the third key, and y is greater than or equal to 1 and less than x, determine the node as the first node and end.
[0190] The initial value of i is 1.
[0191] 1024: Match the i+x+1th fragment key included in the third key with the fragment keys included in each slot in the node. If a slot including the i+x+1th fragment key is matched, execute 1022.
[0192] 1025: Determine whether the node pointed to by the pointer information included in the slot is a leaf node. If the node pointed to by the pointer information included in the slot is a non-leaf node, set i=i+x+1 and execute 1022. If the node pointed to by the pointer information included in the slot is a leaf node, end.
[0193] For example, the first fragment key "00" in the third key "0012564644FF" is matched with the fragment keys included in each slot in the root node shown in Figure 7, and the slot including the fragment key "00" is matched, which includes pointer information pointing to node A.
[0194] Get the node A pointed to by the pointer information. The head of node A does not include the public fragment key. Match the second fragment key "12" in the third key "0012564644FF" with the fragment keys included in each slot in node A. Match the slot including the fragment key "12", which includes pointer information pointing to node B.
[0195] Get the node B pointed to by the pointer information. The head of node B includes 2 public fragment keys. The third fragment key "56" in the third key "0012564644FF" is the same as the first public fragment key "56" included in the head of node B, and the fourth fragment key "46" in the third key is different from the second public fragment key "78" included in the head of node B. Take node B as the first node.
[0196] Step 1103: Create the third node, the fourth node, and the third leaf node.
[0197] In step 1103, a third node, a fourth node, and a third leaf node are created in the memory of the memory terminal. The header of the third node includes each fragment key in the at least one common fragment key that is located before the fourth fragment key. The content portion of the third node includes a fourth slot and a fifth slot. The fourth slot includes the fourth fragment key and fifth pointer information. The fifth pointer information points to the fourth node. The fifth slot includes the fifth fragment key and sixth pointer information. The sixth pointer information points to the third leaf node. The header of the fourth node includes each fragment key in the at least one common fragment key that is located after the fourth fragment key. The fourth node includes each slot in the content portion of the first node. The third leaf node stores a third key-value pair.
[0198] For example, referring to Figure 13, the first node is node B, and the third node L, the fourth node M and the third leaf node N are generated in the memory of the memory end. The head of the third node L includes the fragment key "56" in the first node B that is located before the fourth fragment key "78", and the content part of the third node L includes the fourth slot and the fifth slot (respectively the first slot and the second slot in the content part of the third node L). The fourth slot includes the fourth fragment key "78" and the fifth pointer information, and the fifth pointer information points to the fourth node M. The fifth slot includes the fifth fragment key "46" and the sixth pointer information, and the sixth pointer information points to the third leaf node N. The third leaf node stores the third key-value pair, that is, the third key "0012564644FF"-value5. The content part of the fourth node M includes each slot in the content part of the first node B.
[0199] Step 1104: Set the fourth pointer information to point to the third node.
[0200] For example, referring to FIG7 , the parent node of the first node B is node A, and the first slot in the node including the fragment key “12” stores the fourth pointer information, and the fourth pointer information is set to point to the third node L.
[0201] In an embodiment of the present application, the parent node of the first node includes fourth pointer information, the fourth pointer information points to the first node, and at least one public fragment key in the header of the first node includes a fourth fragment key, and the fourth fragment key is not the first public fragment key. The third key-value pair to be saved is obtained, the third key-value pair includes a third key and a third value, the third key includes a fifth fragment key, the fragment keys of the first key before the fourth fragment key and the fragment keys of the third key before the fifth fragment key are the same, and the fourth fragment key and the fifth fragment key are different. In other words, the public fragment key before the fourth fragment key is the public fragment key of the first key and the third key, and the fourth fragment key and the public fragment key after the fourth fragment key are not the public fragment keys of the first key and the third key, so the header of the first node needs to be split. That is, a third node, a fourth node, and a third leaf node are created. The header of the third node includes each fragment key in at least one common fragment key that precedes the fourth fragment key. The content of the third node includes a fourth slot and a fifth slot. The fourth slot includes the fourth fragment key and fifth pointer information. The fifth pointer information points to the fourth node. The fifth slot includes the fifth fragment key and sixth pointer information. The sixth pointer information points to the third leaf node. The header of the fourth node includes each fragment key in the at least one common fragment key that follows the fourth fragment key. The content of the fourth node includes each slot in the first node. The third leaf node includes the third key-value pair. The fourth pointer information is set to point to the third node, thereby splitting the header of the first node. This ensures that when reading the first key-value pair using the first key and reading the third key-value pair using the third key, the first leaf node can be accurately queried using the first key and the third leaf node can be accurately queried using the second key, thereby accurately reading the first key-value pair from the first leaf node and the second key-value pair from the third leaf node.
[0202] Referring to FIG14 , an embodiment of the present application provides a method 500 for processing a node, which is applied to the network architecture 100 shown in FIG1 . The first leaf node in the method shown in FIG5 includes a first check code, which is obtained based on the first key-value pair in the first leaf node. The method 1400 includes:
[0203] Step 1401: Obtain a fourth key-value pair to be saved and a second verification code, the fourth key-value pair includes a first key and a fourth value, the first value and the fourth value are different, and the second verification code is obtained based on the fourth key-value pair.
[0204] Step 1402: Obtain the first leaf node based on the first key and the radix tree.
[0205] The first leaf node also includes a write operation lock, which is used to indicate that data has been written to the first leaf node.
[0206] In some embodiments, the first leaf node also includes valid information. If the valid information indicates that the first leaf node is valid, the following step 1403 is executed.
[0207] Step 1403: The write operation lock in the first leaf node indicates that the data has been written to the first leaf node, occupying the write operation lock in the first leaf node.
[0208] After the write operation lock is occupied, the write operation lock is used to indicate that data is being written to the first leaf node.
[0209] In step 1403, the processor detects whether the write operation lock in the first leaf node indicates that data has been written to the first leaf node. If the write operation lock indicates that data has been written to the first leaf node, it is determined that no other processor is currently writing data to the first leaf node, so the write operation lock is modified to indicate that data is being written to the first leaf node, thereby occupying the write operation lock. In this way, other processors detect that the write operation lock in the first leaf node indicates that data is being written to the first leaf node. If it is determined that a processor is writing data to the first leaf node, the other processors will not write data to the first leaf node, thereby avoiding write-write conflicts.
[0210] In some embodiments, the write operation lock occupies one bit. Assume that when the write operation lock is bit 0, it indicates that data has been written to the first leaf node. The processor modifies the value of the write operation lock to bit 1 to occupy the write operation lock. At this time, the write operation lock indicates that data is being written to the first leaf node.
[0211] Step 1404: Update the first check code included in the first leaf node to the second check code.
[0212] Step 1405: Update the first key-value pair included in the first leaf node to a fourth key-value pair.
[0213] In step 1405, the write operation lock included in the first leaf node is released. At this time, the write operation lock is used to indicate that data has been written to the first leaf node.
[0214] In an embodiment of the present application, before the first key-value pair is updated to the fourth key-value pair, the first check code located before the first key-value pair in the first leaf node is first updated to the second check code. In this way, in the process of updating the first key-value pair to the fourth key-value pair, if other processors read the key-value pair in the first leaf node, they first read the second check code from the first leaf node, and then read the key-value pair from the first leaf node, and generate a third check code based on the read key-value pair. If before completing the update of the first key-value pair to the fourth key-value pair, other processors read the key-value pair from the first leaf node, and the read key-value pair is different from the fourth key-value pair, so that the third check code is different from the second check code, the other processors determine that a processor has written data to the first leaf node, and then re-read the data in the first leaf node. This avoids read-write conflicts and ensures that other processors can successfully read the key-value pair.
[0215] Referring to Figure 15, an embodiment of the present application provides a data processing device 1500, which is applied to a key-value storage system under a memory separation architecture. The key-value storage system stores data in the form of key-value pairs. The key-value storage system includes the device 1500 and a memory end. The device 1500 indexes the stored key-value pairs through a radix tree. The device 1500 can be deployed on the computing end in the key-value storage system shown in Figure 1, or the device 1500 can be deployed on the computing end in the method 500 shown in Figure 5, the method 800 shown in Figure 8, the method 1100 shown in Figure 11, or the method 1400 shown in Figure 14. The device 1500 includes:
[0216] Processing unit 1501 is configured to obtain a first key-value pair to be saved, where the first key-value pair includes a first key and a first value, where the first key includes multiple fragment keys.
[0217] The processing unit 1501 is further configured to determine a first node, where the first node is a non-leaf node in the radix tree, each node passed through by a path from a root node of the radix tree to a parent node of the first node includes at least one fragment key in the first key, the at least one fragment key is located before the first fragment key in the first key, and a content portion of the first node does not include the first fragment key;
[0218] Saving unit 1502 is used to save the first fragment key and the first pointer information in the first slot of one or more slots in the content part of the first node, the first pointer information is used to point to the first leaf node, the first leaf node stores the first key-value pair, the first slot is an idle slot in the content part, and the address of the first slot is used to indicate the storage location of the first fragment key and the first pointer information on the memory end.
[0219] Optionally, the detailed implementation process of the processing unit 1501 obtaining the first key-value pair is shown in step 501 of the method 500 shown in FIG5 , and will not be described in detail here.
[0220] Optionally, the detailed implementation process of the processing unit 1501 determining the first node refers to step 502 of the method 500 shown in FIG5 , which is not described in detail here.
[0221] Optionally, the detailed implementation process of the saving unit 1502 saving the first fragment key and the first pointer information in the first slot is referred to step 503 of the method 500 shown in FIG5 , which will not be described in detail here.
[0222] Optionally, the storage unit 1502 is further used to store one or more of the following information in the first slot: first indication information or the data volume of the first leaf node, where the first indication information is used to indicate that the node pointed to by the first pointer information is a leaf node.
[0223] Optionally, the detailed implementation process of the storage unit 1502 storing the one or more information in the first slot refers to step 503 of the method 500 shown in FIG5 , which will not be described in detail here.
[0224] Optionally, the size of the first slot is equal to 8 bytes.
[0225] Optionally, the content portion of the first node stores fragment keys of multiple keys, the header of the first node includes at least one consecutive common fragment key, the at least one common fragment key is the common fragment key of the multiple keys, the multiple keys include the first key, and the previous fragment key before the first fragment key in the first key is the last common fragment key in the at least one common fragment key.
[0226] Optionally, the size of the header of the first node is equal to 8 bytes.
[0227] Optionally, the header of the first node further includes a first type of the first node, where the first type is used to indicate that the number of slots included in the first node is N, where N is an integer greater than 1, and the first node does not include an idle slot.
[0228] The processing unit 1501 is further configured to add M slots to the first node, and update the first type included in the header of the first node to a second type, where the second type indicates that the number of slots included in the first node is M+N, where M is an integer greater than 0.
[0229] Optionally, the detailed implementation process of the processing unit 1501 adding M slots in the first node refers to step 503 of the method 500 shown in FIG5 , which is not described in detail here.
[0230] Optionally, the first key further includes a second fragment key, where the second fragment key is the next fragment key after the first fragment key in the first key. The processing unit 1501 is further configured to:
[0231] Get a second key-value pair to be saved, where the second key-value pair includes a second key and a second value, the second key includes a first fragment key and a third fragment key, the third fragment key in the second key is the next fragment key after the first fragment key, each fragment key in the first key that is located before the second fragment key is the same as each fragment key in the second key that is located before the third fragment key, and the second fragment key and the third fragment key are different;
[0232] Determine a second node, where a content portion of the second node includes a second slot and a third slot, the second slot includes a second fragment key and second pointer information, the third slot includes a third fragment key and third pointer information, the second pointer information points to the first leaf node, the third pointer information points to the second leaf node, and the second leaf node stores a second key-value pair;
[0233] Set the first pointer information to point to the second node.
[0234] Optionally, the detailed implementation process of the processing unit 1501 obtaining the second key-value pair is shown in step 801 of the method 800 shown in FIG8 , and will not be described in detail here.
[0235] Optionally, the detailed implementation process of the processing unit 1501 determining the second node refers to step 803 of the method 800 shown in FIG8 , and will not be described in detail here.
[0236] Optionally, the detailed implementation process of the processing unit 1501 setting the first pointer information to point to the second node is shown in step 804 of the method 800 shown in FIG8 , and will not be described in detail here.
[0237] Optionally, the parent node of the first node includes fourth pointer information, the fourth pointer information points to the first node, the at least one common fragment key includes a fourth fragment key, and the fourth fragment key is not the first fragment key in the at least one common fragment key. The processing unit 1501 is further configured to:
[0238] Obtain a third key-value pair to be saved, the third key-value pair including a third key and a third value, the third key including a fifth fragment key, the fragment keys of the first key preceding the fourth fragment key and the fragment keys of the third key preceding the fifth fragment key being the same, and the fourth fragment key and the fifth fragment key being different;
[0239] Determining a third node and a fourth node, wherein a header portion of the third node includes each public fragment key of the at least one public fragment key that precedes the fourth fragment key, a content portion of the third node includes a fourth slot and a fifth slot, the fourth slot includes a fourth fragment key and fifth pointer information, the fifth pointer information points to the fourth node, the fifth slot includes a fifth fragment key and sixth pointer information, the sixth pointer information points to a third leaf node, the third leaf node stores a third key-value pair, and the content portion of the fourth node includes each slot in the first node;
[0240] Set the fourth pointer information to point to the third node.
[0241] Optionally, the detailed implementation process of the processing unit 1501 obtaining the third key-value pair is shown in step 1101 of the method 1100 shown in FIG11 , and will not be described in detail here.
[0242] Optionally, the detailed implementation process of the processing unit 1501 determining the third node and the fourth node is referred to step 1103 of the method 1100 shown in FIG11 , and will not be described in detail here.
[0243] Optionally, the detailed implementation process of the processing unit 1501 setting the fourth pointer information to point to the third node is shown in step 1104 of the method 1100 shown in Figure 11, which is not described in detail here.
[0244] Optionally, the fourth slot also includes one or more of the following information: second indication information or the node type of the fourth node, the second indication information is used to indicate that the fourth node pointed to by the fifth pointer information is a non-leaf node, and the node type of the fourth node is used to indicate the number of slots included in the fourth node.
[0245] Optionally, the first leaf node further includes a first check code, the first check code is stored before the first key-value pair, and the first check code is obtained based on the first key-value pair. The processing unit 1501 is further configured to:
[0246] Obtain a fourth key-value pair to be saved and a second verification code, the fourth key-value pair including a first key and a fourth value, the first value and the fourth value being different, and the second verification code being obtained based on the fourth key-value pair;
[0247] The first check code and the first key-value pair included in the first leaf node are updated to the second check code and the fourth key-value pair respectively.
[0248] Optionally, the detailed implementation process of the processing unit 1501 obtaining the fourth key-value pair and the second verification code is shown in step 1401 of the method 1400 shown in FIG14 , and will not be described in detail here.
[0249] Optionally, the detailed implementation process of the processing unit 1501 updating the first check code and the first key-value pair included in the first leaf node to the second check code and the fourth key-value pair respectively can be found in steps 1403 and 1404 of the method 1400 shown in Figure 14, which will not be described in detail here.
[0250] Optionally, the first leaf node also includes a write operation lock, and the processing unit 1501 is used to update the first check code and the first key-value pair included in the first leaf node to the second check code and the fourth key-value pair respectively when occupying the write operation lock.
[0251] The processing unit 1501 and the storage unit 1502 can be implemented by software or hardware. For example, the implementation of the processing unit 1501 will be described below using the processing unit 1501 as an example. Similarly, the implementation of the storage unit 1502 can refer to the implementation of the processing unit 1501.
[0252] As an example of a software functional unit, the processing unit 1501 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Furthermore, the computing instance may be one or more. For example, the processing unit 1501 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed in the same region or in different regions. Furthermore, the multiple hosts / virtual machines / containers used to run the code may be distributed in the same availability zone (AZ) or in different AZs, each AZ including one data center or multiple geographically close data centers. Typically, a region may include multiple AZs.
[0253] Similarly, multiple hosts / virtual machines / containers running the code can be distributed within the same virtual private cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Cross-region communication between two VPCs within the same region, or between VPCs in different regions, requires a communication gateway within each VPC to interconnect the VPCs.
[0254] As an example of a hardware functional unit, processing unit 1501 may include at least one computing device, such as a server. Alternatively, processing unit 1501 may be implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0255] The multiple computing devices included in processing unit 1501 can be distributed in the same region or in different regions. The multiple computing devices included in processing unit 1501 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in processing unit 1501 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of servers, ASICs, PLDs, CPLDs, FPGAs, GALs, and other computing devices.
[0256] It should be noted that, in other embodiments, the processing unit 1501 can be used to execute any step of the method provided in any of the above embodiments, and the storage unit 1502 can be used to execute any storage step of the method provided in any of the above embodiments. The steps that the processing unit 1501 and the storage unit 1502 are responsible for implementing can be specified as needed. The full functionality of the data processing device 1500 is achieved by having the processing unit 1501 and the storage unit 1505 respectively implement different steps of the method provided in any of the above embodiments.
[0257] In an embodiment of the present application, since the storage unit stores the first fragment key and the first pointer information in an idle slot in the content portion of the first node, if a processor also needs to store other fragment keys and other pointer information in the first node, the processor also stores other fragment keys and other pointer information in other idle slots in the content portion of the first node in the above manner. Since writing data to two different idle slots does not affect each other, the first node does not need to set a lock, and the fragment keys included in the key written to the first node can be written in parallel, thereby improving the efficiency of writing data.
[0258] 16 , an embodiment of the present application provides a computing device 1600. For example, the computing device 1600 may be a device in the computing end of the system shown in FIG1 , or a device in the method 500 shown in FIG5 , the method 800 shown in FIG8 , the method 1100 shown in FIG11 , or the method 1400 shown in FIG14 .
[0259] As shown in Figure 16 , computing device 1600 includes a bus 1602, a processor 1604, a memory 1606, and a communication interface 1608. Processor 1604, memory 1606, and communication interface 1608 communicate with each other via bus 1602. Computing device 1600 may be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in computing device 1600.
[0260] Bus 1602 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, among others. Buses may be classified as address buses, data buses, control buses, and the like. For ease of illustration, FIG16 shows only one line, but this does not imply a single bus or type of bus. Bus 1604 may include a path for transmitting information between various components of computing device 1600 (e.g., processor 1604, memory 1606, and communication interface 1608).
[0261] The processor 1604 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0262] Memory 1606 may include volatile memory, such as random access memory (RAM). Memory 1606 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0263] Referring to FIG16 , the memory 1606 stores executable program code, and the processor 1604 executes the executable program code to respectively implement the functions of the processing unit 1501 and the storage unit 1502 in the apparatus 1500 shown in the figure, thereby implementing the method provided by any of the above embodiments. In other words, the memory 1606 stores instructions for executing the method provided by any of the above embodiments. Alternatively,
[0264] The communication interface 1608 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 1600 and other devices or a communication network.
[0265] Embodiments of the present application also provide a data processing cluster. The data processing cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.
[0266] As shown in Figure 17, the data processing cluster includes at least one computing device 1600. The memory 1606 in one or more computing devices 1600 in the data processing cluster may store the same instructions for executing the method provided in any of the above embodiments.
[0267] In some possible implementations, the memory 1606 of one or more computing devices 1600 in the data processing cluster may also store partial instructions for executing the above-described data management method. In other words, a combination of one or more computing devices 1600 can jointly execute instructions for executing the method provided in any of the above-described embodiments.
[0268] In some possible implementations, one or more computing devices in a data processing cluster can be connected via a network. The network can be a wide area network (WAN) or a local area network (LAN), among others. FIG. 18 illustrates one possible implementation. As shown in FIG. 18 , two computing devices 1600A and 1600B are connected via a network. Specifically, each computing device is connected to the network via a communication interface within the computing device.
[0269] In this type of possible implementation, the memory 1606 in the computing device 1600A stores instructions for executing the functions of the processing unit 1501 in the embodiment shown in Figure 15. Simultaneously, the memory 1606 in the computing device 1600B stores instructions for executing the functions of the storage unit 1502 in the embodiment shown in Figure 15.
[0270] It should be understood that the functionality of the computing device 1600A shown in FIG18 may also be implemented by multiple computing devices 1600. Similarly, the functionality of the computing device 1600B may also be implemented by multiple computing devices 1600.
[0271] The present application also provides another data processing cluster. The connection relationship between the computing devices in this data processing cluster can be similar to the connection method of the data processing cluster described in Figure 18. The difference is that the memory 1606 of one or more computing devices 1600 in this data processing cluster can store the same instructions for executing the method provided in any of the above embodiments.
[0272] In some possible implementations, the memory 1606 of one or more computing devices 1600 in the data processing cluster may also store partial instructions for executing the method provided in any of the above embodiments. In other words, the combination of one or more computing devices 1600 can jointly execute instructions for executing the method provided in any of the above embodiments.
[0273] The present application also provides a computer program product comprising instructions. The computer program product may be software or a program product comprising instructions that can be run on a computing device or stored on any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the method provided in any of the above embodiments.
[0274] The present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center that contains one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to execute the method provided in any of the above embodiments.
[0275] Those skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware, or by a program to instruct the relevant hardware, and the program may be stored in a computer-readable storage medium, which may be a read-only memory, a disk, or an optical disk, etc.
[0276] The above description is merely an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for data processing, characterized in that: The method is applied to a key-value storage system under a memory separation architecture, wherein the key-value storage system stores data in the form of key-value pairs, wherein the key-value storage system includes a computing end and a memory end, wherein the computing end indexes the stored key-value pairs through a radix tree, and wherein the method includes: Obtain a first key-value pair to be saved, the first key-value pair comprising a first key key and a first value value, the first key comprising a plurality of fragment keys; Determine a first node, the first node is a non-leaf node in the radix tree, each node passed by a path from a root node of the radix tree to a parent node of the first node includes at least one fragment key in the first key, the at least one fragment key in the first key is located before the first fragment key, and a content portion of the first node does not include the first fragment key; The first fragment key and the first pointer information are saved in the first slot of one or more slots in the content part of the first node, the first pointer information is used to point to the first leaf node, the first leaf node stores the first key-value pair, the first slot is a free slot in the content part, and the address of the first slot is used to indicate the storage location of the first fragment key and the first pointer information at the memory end.
2. The method according to claim 1, characterized in that The method further comprises: The following one or more information is saved in the first slot: first indication information or the data volume of the first leaf node, where the first indication information is used to indicate that the node pointed to by the first pointer information is a leaf node.
3. The method according to claim 1 or 2, characterized in that The size of the first slot is equal to 8 bytes.
4. The method according to any one of claims 1 to 3, characterized in that: The content part of the first node stores fragment keys of multiple keys, and the header of the first node includes at least one consecutive common fragment key, and the at least one common fragment key is the common fragment key of the multiple keys. The multiple keys include the first key, and the previous fragment key before the first fragment key in the first key is the last common fragment key in the at least one common fragment key.
5. The method according to claim 4, characterized in that The size of the header of the first node is equal to 8 bytes.
6. The method according to claim 4 or 5, characterized in that The header of the first node further includes a first type of the first node, where the first type is used to indicate that the number of slots included in the first node is N, where N is an integer greater than 1, and the first node does not include an idle slot. The method further includes: M slots are added to the first node, and the first type included in the header of the first node is updated to a second type, where the second type indicates that the number of slots included in the first node is M+N, where M is an integer greater than 0.
7. The method according to any one of claims 1 to 6, characterized in that: The first key also includes a second fragment key, and the second fragment key is a next fragment key after the first fragment key in the first key, and the method further includes: Get a second key-value pair to be saved, the second key-value pair includes a second key and a second value, the second key includes the first fragment key and a third fragment key, the third fragment key in the second key is the next fragment key after the first fragment key, each fragment key in the first key before the second fragment key is the same as each fragment key in the second key before the third fragment key, and the second fragment key is different from the third fragment key; Determine a second node, wherein a content portion of the second node includes a second slot and a third slot, the second slot includes the second fragment key and second pointer information, the third slot includes the third fragment key and third pointer information, the second pointer information points to the first leaf node, the third pointer information points to the second leaf node, and the second leaf node stores the second key-value pair; Set the first pointer information to point to the second node.
8. The method according to any one of claims 4 to 6, characterized in that: The parent node of the first node includes fourth pointer information, the fourth pointer information points to the first node, the at least one common fragment key includes a fourth fragment key, the fourth fragment key is not the first fragment key in the at least one common fragment key, and the method further includes: Obtain a third key-value pair to be saved, the third key-value pair comprising a third key and a third value, the third key comprising a fifth fragment key, each fragment key of the first key before the fourth fragment key and each fragment key of the third key before the fifth fragment key are the same, and the fourth fragment key is different from the fifth fragment key; Determine a third node and a fourth node, the header of the third node includes each public fragment key in the at least one public fragment key that is located before the fourth fragment key, the content portion of the third node includes a fourth slot and a fifth slot, the fourth slot includes the fourth fragment key and fifth pointer information, the fifth pointer information points to the fourth node, the fifth slot includes the fifth fragment key and sixth pointer information, the sixth pointer information points to a third leaf node, the third leaf node stores the third key-value pair, and the content portion of the fourth node includes each slot in the first node; The fourth pointer information is set to point to the third node.
9. The method according to claim 8, characterized in that The fourth slot also includes one or more of the following information: second indication information or the node type of the fourth node, the second indication information is used to indicate that the fourth node pointed to by the fifth pointer information is a non-leaf node, and the node type of the fourth node is used to indicate the number of slots included in the fourth node.
10. The method according to any one of claims 1 to 9, characterized in that: The first leaf node further includes a first check code, the first check code is stored before the first key-value pair, and the first check code is obtained based on the first key-value pair. The method further includes: Obtain a fourth key-value pair to be saved and a second verification code, the fourth key-value pair including the first key and a fourth value, the first value and the fourth value are different, and the second verification code is obtained based on the fourth key-value pair; The first check code and the first key-value pair included in the first leaf node are updated to the second check code and the fourth key-value pair respectively.
11. The method according to claim 10, characterized in that The first leaf node also includes a write operation lock, and the updating of the first check code and the first key-value pair included in the first leaf node to the second check code and the fourth key-value pair respectively includes: When the write operation lock is occupied, the first check code and the first key-value pair included in the first leaf node are updated to the second check code and the fourth key-value pair respectively.
12. A data processing device, characterized in that: The device is applied to a key-value storage system under a memory separation architecture, the key-value storage system stores data in the form of key-value pairs, the key-value storage system includes the device and a memory end, the device indexes the stored key-value pairs through a radix tree, and the device includes: A processing unit, configured to obtain a first key-value pair to be saved, wherein the first key-value pair includes a first key and a first value, and the first key includes a plurality of fragment keys; The processing unit is further configured to determine a first node, the first node being a non-leaf node in the radix tree, each node passed by a path from a root node of the radix tree to a parent node of the first node includes at least one fragment key in the first key, the at least one fragment key in the first key is located before the first fragment key, and a content portion of the first node does not include the first fragment key; A saving unit is used to save the first fragment key and the first pointer information in a first slot among one or more slots in the content part of the first node, the first pointer information is used to point to a first leaf node, the first leaf node stores the first key-value pair, the first slot is a free slot in the content part, and the address of the first slot is used to indicate the storage location of the first fragment key and the first pointer information at the memory end.
13. The device according to claim 12, characterized in that The storage unit is also used to store one or more of the following information in the first slot: first indication information or the data volume of the first leaf node, where the first indication information is used to indicate that the node pointed to by the first pointer information is a leaf node.
14. The device according to claim 12 or 13, characterized in that The size of the first slot is equal to 8 bytes.
15. The device according to any one of claims 12 to 14, characterized in that: The content part of the first node stores fragment keys of multiple keys, and the header of the first node includes at least one consecutive common fragment key, and the at least one common fragment key is the common fragment key of the multiple keys. The multiple keys include the first key, and the previous fragment key before the first fragment key in the first key is the last common fragment key in the at least one common fragment key.
16. The device according to claim 15, characterized in that The size of the header of the first node is equal to 8 bytes.
17. The device according to claim 15 or 16, characterized in that The header of the first node further includes a first type of the first node, where the first type is used to indicate that the number of slots included in the first node is N, where N is an integer greater than 1, and the first node does not include an idle slot. The processing unit is further used to add M slots in the first node, and update the first type included in the header of the first node to a second type, where the second type indicates that the number of slots included in the first node is M+N, where M is an integer greater than 0.
18. The device according to any one of claims 12 to 17, characterized in that The first key also includes a second fragment key, and the second fragment key is a next fragment key after the first fragment key in the first key. The processing unit is further used to: Get a second key-value pair to be saved, the second key-value pair includes a second key and a second value, the second key includes the first fragment key and a third fragment key, the third fragment key in the second key is the next fragment key after the first fragment key, each fragment key in the first key before the second fragment key is the same as each fragment key in the second key before the third fragment key, and the second fragment key is different from the third fragment key; Determine a second node, wherein a content portion of the second node includes a second slot and a third slot, the second slot includes the second fragment key and second pointer information, the third slot includes the third fragment key and third pointer information, the second pointer information points to the first leaf node, the third pointer information points to the second leaf node, and the second leaf node stores the second key-value pair; Set the first pointer information to point to the second node.
19. The device according to any one of claims 15 to 17, characterized in that: The parent node of the first node includes fourth pointer information, the fourth pointer information points to the first node, the at least one common fragment key includes a fourth fragment key, the fourth fragment key is not the first fragment key in the at least one common fragment key, and the processing unit is further used to: Obtain a third key-value pair to be saved, the third key-value pair comprising a third key and a third value, the third key comprising a fifth fragment key, each fragment key of the first key before the fourth fragment key and each fragment key of the third key before the fifth fragment key are the same, and the fourth fragment key is different from the fifth fragment key; Determine a third node and a fourth node, the header of the third node includes each public fragment key in the at least one public fragment key that is located before the fourth fragment key, the content portion of the third node includes a fourth slot and a fifth slot, the fourth slot includes the fourth fragment key and fifth pointer information, the fifth pointer information points to the fourth node, the fifth slot includes the fifth fragment key and sixth pointer information, the sixth pointer information points to a third leaf node, the third leaf node stores the third key-value pair, and the content portion of the fourth node includes each slot in the first node; The fourth pointer information is set to point to the third node.
20. The device according to claim 19, characterized in that The fourth slot also includes one or more of the following information: second indication information or the node type of the fourth node, the second indication information is used to indicate that the fourth node pointed to by the fifth pointer information is a non-leaf node, and the node type of the fourth node is used to indicate the number of slots included in the fourth node.
21. The method according to any one of claims 12 to 20, characterized in that: The first leaf node further includes a first check code, the first check code is stored before the first key-value pair, and the first check code is obtained based on the first key-value pair. The processing unit is further used for: Obtain a fourth key-value pair to be saved and a second verification code, the fourth key-value pair including the first key and a fourth value, the first value and the fourth value are different, and the second verification code is obtained based on the fourth key-value pair; The first check code and the first key-value pair included in the first leaf node are updated to the second check code and the fourth key-value pair respectively.
22. The device according to claim 21, characterized in that The first leaf node also includes a write operation lock, and the processing unit is used to update the first check code and the first key-value pair included in the first leaf node to the second check code and the fourth key-value pair respectively when occupying the write operation lock.
23. A data processing cluster, characterized in that: The cluster includes at least one computing device, each of the at least one computing device includes at least one processor and at least one memory, and the at least one memory stores computer-readable instructions; the at least one processor executes the computer-readable instructions so that the cluster executes the method according to any one of claims 1-11.
24. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 11 is implemented.
25. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 11 is implemented.
Citation Information
Patent Citations
An unbalanced binary tree construction method based on binary boundary value computation
CN109445763A
Block chain data storage method and device and electronic equipment
CN112905607A
Tree deduplication
US20200387484A1
Key-value store tree with selective use of key portion
WO2020123632A1
