Data processing method and device and storage medium
By saving free slots in the content part of non-leaf nodes of the radix tree, multiple processors are allowed to write in parallel, which solves the lock contention problem caused by competitive writing and improves the efficiency of writing data.
Patent Information
- Application Number
- CN202310432124.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-03-25
- Filing Date
- 2023-04-20
- Publication Date
- 2024-10-01
AI Technical Summary
In the key-value storage system under the memory separation architecture, when multiple processors compete to write non-leaf nodes of the radix tree, they need to occupy locks, resulting in reduced data writing efficiency.
By saving free slots in the content part of non-leaf nodes of the radix tree, multiple processors are allowed to write to different slots in parallel, avoiding lock competition and improving the efficiency of writing data.
It enables multiple processors to write non-leaf nodes of the radix tree in parallel, which improves the efficiency of writing data, avoids lock competition, and improves the overall performance of the system.
Smart Images

Figure CN118733244A_ABST
Abstract
Description
[0001] This application claims priority to Chinese patent application No. 202310308715.2, filed on March 25, 2023, and entitled “A method, device and other equipment for concurrent control”, the entire 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] The key-value storage system under the memory separation architecture includes a computing end and a memory end. The computing end includes multiple central processing units (CPUs), and the memory end includes multiple memories. The CPU in the computing end accesses the memory in the memory end through the network. The memory end uses a key-value storage method to store data, and the CPU in the computing end uses a radix tree to access the key-value pairs stored in the memory end.
[0004] For each leaf node of the radix tree, the leaf node 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 node 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 in the computing end 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 in the computing end 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 has been occupied, it is necessary 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. Summary of the invention
[0006] The present application provides a data processing method, device and storage medium to improve the efficiency of writing data. The technical solution is as follows:
[0007] In the 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, wherein the key-value storage system stores data in the form of key-value pairs, and the key-value storage system includes a computing end and a memory end, and 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, wherein the first key-value pair includes a first key and a first value, and the first key includes multiple fragment keys. A first node is determined, wherein the first node is a non-leaf node in a radix tree, 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 first key, wherein the at least one fragment key is located before the first fragment key in the first key, and the content part 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, wherein the first pointer information is used to point to the first leaf node, wherein the first leaf node stores the first key-value pair, and 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 in the memory end.
[0008] 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, and each processor does not occupy the lock of the first node when writing a key including a fragment key to the first node, so that multiple processors can write fragment keys to the first node in parallel, thereby improving the efficiency of writing data.
[0009] In a 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, and 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 leaf nodes based on the 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.
[0010] 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.
[0011] In another possible implementation, the content portion of the first node stores fragment keys of multiple keys, and the header of the first node includes at least one continuous common fragment key, which is the common fragment key of the multiple keys, and 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. In this way, by including the at least one common fragment key in the header, path compression is achieved, and the path length corresponding to the first key in the radix tree is reduced.
[0012] 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.
[0013] In another possible implementation, the header of the first node also includes the first type of the first node, the first type is used to indicate that the number of slots included in the first node is N, N is an integer greater than 1, and the first node does not include 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, the second type indicates that the number of slots included in the first node is M+N, M is an integer greater than 0. Adding slots to the first node ensures that there are enough slots to save the fragment key, and updating the first type of the header to the second type also avoids errors.
[0014] 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.
[0015] 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, the second fragment key and the third fragment key are different, that is, 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 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 and the third pointer information points to the second leaf node. Set the first pointer information to point to the second node. In this way, the first pointer information in the first slot points 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 the first key-value pair is read through the first key and the second key-value pair is read 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.
[0016] 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 common fragment key includes the fourth fragment key, and the fourth fragment key is not the first fragment key in the at least one common fragment key. Get the third key-value pair to be saved, the third key-value pair includes the third key and the third value, 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. Determine the third node and the fourth node, the header of the third node includes the public fragment keys in the at least one common fragment key before the fourth fragment key, the content part 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 third leaf node stores the third key-value pair, and the content part of the fourth node includes each slot in the first node. Set the fourth pointer information to point to the third node.
[0017] 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, that is, 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, it is necessary to split the head of the first node. That is, determine the third node, the fourth node and the third leaf node, the head of the third node includes the fragment keys before the fourth fragment key in at least one public fragment key, the content part 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 public fragment key, the content part of the fourth node includes each slot in the first node, and the third leaf node includes the third key-value pair. Set the fourth pointer information to point to the third node, so as to split the head of the first node. It is ensured that when the first key-value pair is read through the first key, and the third key-value pair is read 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.
[0018] In another possible implementation, 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. In this way, based on the key index leaf node, 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.
[0019] 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 and the second check code to be saved 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.
[0020] In another possible implementation, the first leaf node also includes a write operation lock, and 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, write-write conflicts can be avoided by occupying the write operation lock.
[0021] 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.
[0022] 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 manner of the first aspect.
[0023] 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.
[0024] 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 manner of the first aspect.
[0025] 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
[0026] Figure 1 It is a structural diagram of a key-value storage system involved in an embodiment of the present application;
[0027] Figure 2 is a structural diagram of a non-leaf node provided in an embodiment of the present application;
[0028] Figure 3 It is a structural diagram of a leaf node provided in an embodiment of the present application;
[0029] Figure 4 It is a structural diagram of a radix tree provided in an embodiment of the present application;
[0030] Figure 5 is a flow chart of a data processing method provided by an embodiment of the present application;
[0031] Figure 6 is a flow chart of a method for determining a first node provided in an embodiment of the present application;
[0032] Figure 7 is a schematic diagram of the structure of another radix tree provided in an embodiment of the present application;
[0033] Figure 8 is a flow chart of another data processing method provided by an embodiment of the present application;
[0034] Fig. 9 is a flow chart of another method for determining a first node provided in an embodiment of the present application;
[0035] Fig.10 It is a schematic diagram of the structure of another radix tree provided in an embodiment of the present application;
[0036] Fig.11 is a flow chart of another data processing method provided by an embodiment of the present application;
[0037] Fig.12 is a flow chart of another method for determining a first node provided in an embodiment of the present application;
[0038] Fig.13 is a schematic diagram of the structure of another radix tree provided in an embodiment of the present application;
[0039] Fig.14 is a flow chart of another data processing method provided by an embodiment of the present application;
[0040] Fig.15 It is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application;
[0041] Fig.16 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0042] Fig.17 It is a schematic diagram of the structure of a data processing cluster provided in an embodiment of the present application;
[0043] Fig.18 It is a schematic diagram of the structure of another data processing cluster provided in an embodiment of the present application. DETAILED DESCRIPTION
[0044] In the description of the present application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In the description of the present application, it should be noted that, unless otherwise clearly specified and limited, "including" and "having" and any of their variations 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 optionally also includes steps or units that are not listed, or optionally also includes 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 the present application can be understood in specific circumstances. In addition, in the description of the present application, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B, which 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 an "or" relationship.
[0045] To facilitate understanding of the solutions of the embodiments of the present application, the technical terms involved in this document are first explained below.
[0046] The 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.
[0047] A key-value storage system is a system that stores data in the form of key-value pairs.
[0048] 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.
[0049] A partial key is a component of a key. A key often includes multiple fragment keys.
[0050] A radix tree is a tree index structure that is indexed 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.
[0051] 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.
[0052] A non-leaf node, also known as an internal node of a radix tree, includes a header and a content part. A non-leaf node is also a storage space in the memory end. Optionally, the size of the header of a non-leaf node can be 8 bytes, and the size of the content part can be an integer multiple of 8 bytes.
[0053] A slot is an 8-byte storage space in the content part of a non-leaf node that can be read and written through atomic operations.
[0054] An atomic operation is a data writing operation. An atomic operation is indivisible and will not be interrupted by any other task or event before the data writing is completed. The amount of data that can be written by an atomic operation does not exceed 8 bytes.
[0055] The implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0056] See also Figure 1 The 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 .
[0057] 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.
[0058] See also Figure 1 The computing end 101 includes a plurality of processors 1011, and the memory end 102 includes a plurality of memories 1021. For each processor 1011 in the computing end 101, the processor 1011 can read and write one or more memories 1021 in the memory end 102.
[0059] In some embodiments, the memory end 102 uses a key-value pair storage method to store data. The processor 1011 in the computing end 101 uses a radix tree to read and write the key-value pairs stored in the memory end 102 , and the radix tree is stored on the memory end 102 .
[0060] 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).
[0061] The key-value pair includes a key and a value, and the key includes multiple fragment keys. For example, taking the key as hexadecimal data and each fragment key including two hexadecimal digits as an example, assuming that the key is 0012567843CC, the key includes six fragment keys, and the six fragment keys are 00, 12, 56, 78, 43 and CC.
[0062] The nodes in the radix tree include leaf nodes and non-leaf nodes. Leaf nodes are used to store key-value pairs. Non-leaf nodes include a header and a content part. The content part is used to store at least one fragment key. The at least one fragment key corresponds to 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 part includes a fragment key for each key in the at least one key.
[0063] 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.
[0064] 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.
[0065] In some embodiments, a leaf node includes a key and a value corresponding to the key, and for each non-leaf node passed 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.
[0066] 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, obtain the leaf node based on the path, and read the key-value pair included in the leaf node.
[0067] In some embodiments, see Figure 1 The computing end 101 also includes a plurality of caches 1012 , and the plurality of processors 1011 correspond to the plurality of caches 1012 one by one. Each processor 1011 can read and write the cache 1012 corresponding to each processor 1011 , respectively.
[0068] See also Figure 2 For each non-leaf node in the radix tree, the non-leaf node includes a header and a content part, 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.
[0069] The first storage space 11 is used to store the depth of the fragment key in the content part, and the second storage space 12 is used to store the node type of the non-leaf node. node), the third storage space 13 is used to store the number of public fragment keys (size array ), the fourth storage space 14 is used to store public fragment keys (arry of partial keys). If the number of public fragment keys stored in the third storage space 13 is 0, the fourth storage space 14 is empty.
[0070] See also Figure 2 , an example of the header structure is listed, the size of the header is 8 bytes, 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. Assuming that each public fragment key is two-bit hexadecimal data, the fourth storage space 14 can store no more than 6 public fragment keys.
[0071] If there are more common fragment keys between multiple keys, exceeding 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 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.
[0072] The content part of the non-leaf node is used to store at least one fragment key and at least one pointer information, and 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 part, the first storage space 11 at the head of the non-leaf node stores 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.
[0073] See also Figure 2, the content portion of the non-leaf node includes a plurality of slots, that is, 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.
[0074] In some embodiments, the number of slots included in the non-leaf node may be 4, 8, 16, 32, 64 or 128, etc. Assuming that the number of slots included in the non-leaf node is 4, a fragment key and pointer information corresponding to the fragment key may be saved 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.
[0075] In some embodiments, the node type of the non-leaf node is N4, N8, N16 or N32, etc. For example, the node type of the non-leaf node is N4, indicating that the number of slots included in the content part 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 part of the non-leaf node is 8; the node type of the non-leaf node is N16, indicating that the number of slots included in the content part of the non-leaf node is 16.
[0076] See also Figure 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.
[0077] 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.
[0078] The sixth storage space 22 is used to store indication information (leaf), which is used to indicate 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, indicated by leaf=0), which is used to indicate 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 (type node ). Optionally, the node type of the child node may be N4, N8, N16 or N32, etc.
[0079] If the child node is a leaf node, the indication information stored in the sixth storage space 22 is the second indication information (for example, leaf=1), and the second indication information is used to indicate that the child node pointed to by the pointer information is a leaf node. The seventh storage space 23 is used to store the data volume (lenleaf ).
[0080] For example, see Figure 3 The leaf node shown occupies a total of 80 bits, that is, the data volume of the leaf node is 10 bytes.
[0081] 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, so that the size of the header of the non-leaf node is 8 bytes.
[0082] 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.
[0083] 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. The size of the slot is 64 bits, which is equal to 8 bytes. In this case, the atomic operation implemented by the mask method writes data to the slot, and the amount of data written to the slot can be less than 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 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 the slot is 64 bits, which is equal to 8 bytes.
[0085] In some embodiments, when the size of the slot is 8 bytes, the fragment key and pointer information and other contents may 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.
[0086] 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. Figure 2 , the pointer information is located before the head of the non-leaf node.
[0087] See also Figure 3For each leaf node in the radix tree, the leaf node includes a checksum, a key-value pair, and a write operation lock. The checksum is obtained based on the key-value pair and is used to verify the key-value pair. The write operation 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 operation lock indicates that data has been written to the leaf node. If data is being written to the leaf node, the write operation lock indicates that data is being written to the leaf node.
[0088] In some embodiments, the check code is a parity check code or a cyclic redundancy check code (CRC).
[0089] 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.
[0090] In some embodiments, when the memory end 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.
[0091] In this way, before releasing the space occupied by the leaf node, if other processors 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.
[0092] In some embodiments, the write operation lock may be a single bit, and when the bit is a bit value of 1, it indicates that the write operation lock indicates that data has been written to the leaf node, and when the bit is a bit value of 0, it indicates that the write operation lock indicates that data is being written to the leaf node. Alternatively, when the bit is a bit value of 0, it indicates that the write operation lock indicates that data has been written to the leaf node, and when the bit is a bit value of 1, it indicates that the write operation lock indicates that data is being written to the leaf node.
[0093] In some embodiments, the valid information may be a bit, and when the bit is a bit value of 1, it indicates that the leaf node is valid, and when the bit is a bit value of 0, it indicates that the leaf node is invalid. Alternatively, when the bit is a bit value of 0, it indicates that the leaf node is valid, and when the bit is a bit value of 1, it indicates that the leaf node is invalid.
[0094] For example, see Figure 4In the radix tree shown, 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.
[0095] 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 public fragment keys. The content part of the root node includes four slots, and the first slot includes 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.
[0096] 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 the public fragment key. The content part of node A includes four slots, the first slot includes the fragment key 12 and the pointer information pointing to node B (not shown in the figure), and the second slot includes the fragment key 34 and the 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 of two keys, and the two keys are 0012567843CC and 00125678FF25.
[0097] 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.
[0098] Leaf node C includes a key-value pair, which includes key1 and value1, and key1 is "0012567843CC". Leaf node D includes a key-value pair, which includes key2 and value2, and key2 is "00125678FF25".
[0099] 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.
[0100] In some embodiments, the radix tree is stored in the memory end 102, and the radix tree includes many 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. The part of the leaf nodes includes the fragment key in the key that the processor 1011 needs to query.
[0101] For example, see 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.
[0102] See also Figure 5 The present application embodiment provides a data processing method 500, the method 500 is applied to Figure 1 The network architecture 100 is shown. The method 500 includes:
[0103] Step 501: Obtain a first key-value pair to be saved, the first key-value pair including a first key and a first value, and the first key including multiple fragment keys.
[0104] The first key-value pair to be saved is a key-value pair that the processor needs to save to the memory end.
[0105] 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.
[0106] Step 502: Determine the first node.
[0107] 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 in the first key is located before the first fragment 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.
[0108] In some embodiments, the head of the first node may also include at least one consecutive common fragment key, and 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.
[0109] For example, see 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 passed 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 first key, such as Figure 4 As shown, 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 of the head 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".
[0110] In step 502, see Figure 6 , determine the first node through the following operations.
[0111] 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.
[0112] 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, and 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.
[0113] 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.
[0114] In 5022, based on the size of the node, the node is obtained from the location indicated by the pointer information in the memory.
[0115] In some embodiments, the header 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 header of the node includes the public fragment keys. If the number of public fragment keys is equal to 0, it is determined that the header of the node does not include the public fragment keys.
[0116] In some embodiments, the node where the slot is located 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, the node is not in the cache corresponding to the processor, and the node pointed to by the pointer information included in the slot is obtained from the memory end.
[0117] In some embodiments, the header of the node includes the node type of the node. If the node type of the node included in the header of the node is different from the node type of the node included in the slot, it means that the parent node included in the cache is invalid. Therefore, the parent node is also obtained from the memory end, and the parent node included in the cache is updated to the parent node obtained from the memory end.
[0118] 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.
[0119] The initial value of i is 1.
[0120] 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 a slot including the i+x+1th fragment key is not matched, take the node as the first node and end.
[0121] 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, take the node as the first node and end.
[0122] For example, the first fragment key "00" in the first key "00125678441A" is combined with Figure 4 The fragment keys included in each slot in the root node shown are matched, and a slot including the fragment key "00" is matched, and the slot includes pointer information pointing to node A.
[0123] 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 first key with the fragment keys included in each slot in node A, and match the slot including the fragment key "12", which includes the pointer information pointing to node B.
[0124] Get the node B pointed to by the pointer information. The head of node B includes two public fragment keys. The third to fourth fragment keys "56" and "78" in the first key are respectively the same as the two public fragment keys "56" and "78" included in the head of node B. Match the fifth fragment key "44" in the first key with the fragment keys included in each slot in node B, match the slot that does not include the fragment key "44", and use node B as the first node.
[0125] In step 502, a first leaf node is also 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.
[0126] 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.
[0127] In some embodiments, the first leaf node also includes valid 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 prompt that data has been written to the first leaf node, and the valid 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.
[0128] For example, see Figure 7 , 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.
[0129] 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.
[0130] 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.
[0131] 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.
[0132] In some embodiments, the first pointer information includes the address of the first leaf node in the memory, etc.
[0133] In step 503, when the content portion of the first node includes an idle slot, an idle slot is selected as the first slot, and the first fragment key and the first pointer information are saved in the first slot. When the content portion of the first node does not include an idle slot, 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 the first pointer information are saved in the first slot. Optionally, the first indication information and / or the data volume of the first leaf node, etc. are also saved in the first slot.
[0134] 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 may be a remote direct memory access, compare and swap (RDMA CAS) operation.
[0135] For example, see Figure 7 , the third slot and the fourth slot of node B are both free slots, and the first fragment key "44", the first indication information, the data volume of node H and the first pointer information are saved in the third slot (that is, 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.
[0136] In some embodiments, for the first type of the first node included in the header of the first node, the number of slots included in the first node indicated by the first type 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, and the number of slots included in the first node is N+M, so the first type included in the header of the first node needs to be updated to the second type. The number of slots included in the first node indicated by the second type is M+N.
[0137] When generating the first node, the memory end 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 part of the first node includes N slots. When the processor adds M slots to the content part of the first node, it sends a request to the memory end. The memory end selects M slots from the remaining ZN slots and allocates them to the first node, so that the content part of the first node includes M+N slots.
[0138] 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 part of the first node before the increase is 4, and four slots are added to the content part of the first node. The number of slots included in the content part of the first node after the increase is 8. Then, the first type N4 included in the header of the first node is updated to the second type N8. The number of slots included in the content part of the first node indicated by the second type N8 is 8.
[0139] In the 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 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, 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.
[0140] See also Figure 8 The present application embodiment provides a data processing method 800, the method 800 is applied to Figure 1 The network architecture 100 is shown. The method 800 includes:
[0141] 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.
[0142] Assume that the first fragment key is not the last fragment key of the first key. For the sake of convenience, 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 of the first key before the second fragment key and the fragment keys of the second key before the third fragment key are the same, and the second fragment key and the third fragment key are different.
[0143] 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.
[0144] Step 802: Determine the first node.
[0145] The first node is a non-leaf node in the radix tree, the content portion of the first node includes a first fragment key, each node in 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 second key, and the at least one fragment key is located before the first fragment key. For the first slot in the first node including the first fragment key, the first pointer information included in the first slot points to the first leaf node.
[0146] In some embodiments, the head of the first node may also include at least one consecutive common fragment key, and 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.
[0147] For example, see 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 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, such as Figure 8As shown, 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 portion 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.
[0148] In step 802, see Fig. 9 , determine the first node through the following operations.
[0149] 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.
[0150] 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, and 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.
[0151] 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.
[0152] In 8022, based on the size of the node, the node is obtained from the location indicated by the pointer information in the memory.
[0153] In some embodiments, the header 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 header of the node includes the public fragment keys. If the number of public fragment keys is equal to 0, it is determined that the header of the node does not include the public fragment keys.
[0154] 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.
[0155] The initial value of i is 1.
[0156] 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.
[0157] 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.
[0158] 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.
[0159] 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.
[0160] 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.
[0161] 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.
[0162] 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.
[0163] For example, the first fragment key "00" in the second key "001256784498" is combined with Figure 7 The fragment keys included in each slot in the root node shown are matched, and a slot including the fragment key "00" is matched, and the slot includes pointer information pointing to node A.
[0164] 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 second key with the fragment keys included in each slot in node A, and match the slot including the fragment key "12", which includes the pointer information pointing to node B.
[0165] Get the node B pointed to by the pointer information. The head of node B includes 2 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 head of node B. Match the fifth fragment key "44" in the second key with the fragment keys included in each slot in node B, and 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.
[0166] Step 803: Create a second node and a second leaf node.
[0167] In step 803, a second node and a second leaf node are generated in the memory of the memory end. 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.
[0168] For the second fragment key, the first slot including the first fragment key is obtained from the content part of the first node, and the first leaf node is determined based on the first pointer information included in the first slot and the size of the first leaf node. The next fragment key located after the first fragment key is obtained from the first key included in the first leaf node as the second fragment key.
[0169] For example, see Fig.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. The next fragment key "1A" located after the first fragment key "44" is obtained from the first key "00125678441A" included in the first leaf node H as the second fragment key.
[0170] Generate the second node J and the second leaf node K in the memory of the memory end. The first slot in the content part of the second node J (the first slot in the second node J is the second slot) includes the second fragment key "1A" and the 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.
[0171] Step 804: Set the first pointer information to point to the second node.
[0172] For example, see Fig.10, the third slot in node B includes first pointer information, and the first pointer information points to the second node J.
[0173] 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. Get the second key-value pair to be saved, and determine the first node based on the second key included in the second key-value pair. The second key includes the first fragment key and the third fragment key, and 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. In other words, the first key-value pair and the second key-value pair should be saved in two leaf nodes under the first slot. So create a second node and a second leaf 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 and the third pointer information points to the second leaf node. Set the first pointer information to point to the second node. In this way, the first pointer information in the first slot points 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 the first key-value pair is read through the first key, and the second key-value pair is read 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.
[0174] See also Fig.11 , the present application embodiment provides a data processing method 1100, the method 1100 is applied to Figure 1 Network architecture 100 is shown. Figure 5 The parent node of the first node in the method includes fourth pointer information, the fourth pointer information points to the first node, and at least one continuous public fragment key in the head of the first node includes a fourth fragment key, and the fourth fragment key is not the first public fragment key. The method 1100 includes:
[0175] 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.
[0176] 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.
[0177] 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 Figure 7 The node B in the header of the 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".
[0178] Step 1102: Determine the first node.
[0179] 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.
[0180] In some embodiments, the third key also includes a fragment key of the public fragment key of the head of the first node that precedes the fourth fragment key.
[0181] For example, see 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 passed 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 third key, such as Figure 7 As shown, 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 of the head of node B includes fragment keys "56" and "78", and the third key "0012564644FF" also includes the public fragment key "56" before the fourth fragment key "78".
[0182] In step 1102, see Fig.12 , determine the first node through the following operations.
[0183] 1021: Match the first fragment key included in the third key with the fragment keys included in each slot in the root node, and match the slot including the first fragment key.
[0184] 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, and 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.
[0185] 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.
[0186] In 1022, based on the size of the node, the node is obtained from the location indicated by the pointer information in the memory.
[0187] In some embodiments, the header 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 header of the node includes the public fragment keys. If the number of public fragment keys is equal to 0, it is determined that the header of the node does not include the public fragment keys.
[0188] 1023: Compare the x fragment keys included in the head of the node with the i+1th to i+xth fragment keys included in the second key. If the x fragment keys included in the head of the node 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 head of the node 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.
[0189] The initial value of i is 1.
[0190] 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.
[0191] 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.
[0192] For example, the first fragment key "00" in the third key "0012564644FF" is combined with Figure 7 The fragment keys included in each slot in the root node shown are matched, and a slot including the fragment key "00" is matched, and the slot includes pointer information pointing to node A.
[0193] 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, and match the slot including the fragment key "12", which includes the pointer information pointing to node B.
[0194] Get the node B pointed to by the pointer information. The header 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 header 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 header of node B. Node B is taken as the first node.
[0195] Step 1103: Create the third node, the fourth node and the third leaf node.
[0196] In step 1103, a third node, a fourth node, and a third leaf node are created in the memory of the memory end. The header of the third node includes the fragment keys of the at least one common fragment key that are located before the fourth fragment key, the content portion 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 header of the fourth node includes the fragment keys of the at least one common fragment key that are located after the fourth fragment key, the fourth node includes each slot in the content portion of the first node, and the third leaf node stores the third key-value pair.
[0197] For example, see Fig.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.
[0198] Step 1104: Set the fourth pointer information to point to the third node.
[0199] For example, see Figure 7 The parent node of the first node B is node A. 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.
[0200] 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, create a third node, a fourth node and a third leaf node, the header of the third node includes each fragment key located before the fourth fragment key in at least one common fragment key, the content part 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 header of the fourth node includes each fragment key located after the fourth fragment key in the at least one common fragment key, the content part of the fourth node includes each slot in the first node, and the third leaf node includes the third key-value pair. Set the fourth pointer information to point to the third node, so as to split the header of the first node. Ensure 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 second key-value pair can be accurately read from the third leaf node.
[0201] See also Fig.14 , the present application embodiment provides a method 500 for processing a node, the method 500 is applied to Figure 1 Network architecture 100 is shown. Figure 5 The first leaf node in the method shown includes a first check code, and the first check code is obtained based on the first key-value pair in the first leaf node. The method 1400 includes:
[0202] Step 1401: Obtain a fourth key-value pair and a second verification code to be saved, 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.
[0203] Step 1402: Obtain the first leaf node based on the first key and the radix tree.
[0204] The first leaf node also includes a write operation lock, and the write operation lock is used to indicate that data has been written to the first leaf node.
[0205] 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.
[0206] 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.
[0207] After occupying the write operation lock, the write operation lock is used to indicate that data is being written to the first leaf node.
[0208] 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, so as to occupy 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, and determine that a processor is writing data to the first leaf node, and other processors will not write data to the first leaf node, thereby avoiding write-write conflicts.
[0209] In some embodiments, the write operation lock occupies one bit, and it is assumed 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, and at this time, the write operation lock indicates that data is being written to the first leaf node.
[0210] Step 1404: Update the first check code included in the first leaf node to the second check code.
[0211] Step 1405: Update the first key-value pair included in the first leaf node to a fourth key-value pair.
[0212] 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 the data has been written to the first leaf node.
[0213] 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 in the first leaf node that is located before the first key-value pair 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, the second check code is first read from the first leaf node, and then the key-value pair is read from the first leaf node, and the third check code is generated 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. In this way, read-write conflicts are avoided, ensuring that other processors can successfully read the key-value pair.
[0214] See also Fig.15 The 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 in Figure 1 On the computing end in the key-value storage system shown, or, the device 1500 is deployed on Figure 5 The method 500 shown, Figure 8 The method 800 shown, Fig.11 The method 1100 or Fig.14 On the computing side of method 1400 shown.
[0215] The device 1500 comprises:
[0216] The 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, 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 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 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 in the memory end.
[0219] Optionally, the detailed implementation process of the processing unit 1501 obtaining the first key-value pair can be found in Figure 5 Step 501 of the method 500 is not described in detail here.
[0220] Optionally, the detailed implementation process of the processing unit 1501 determining the first node is shown in Figure 5 Step 502 of the method 500 is not described in detail here.
[0221] Optionally, the detailed implementation process of the storage unit 1502 storing the first fragment key and the first pointer information in the first slot is shown in Figure 5 Step 503 of the method 500 is not described in detail here.
[0222] Optionally, the saving unit 1502 is also used to save 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 above one or more information in the first slot is shown in Figure 5 Step 503 of the method 500 is not 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 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.
[0229] Optionally, the detailed implementation process of the processing unit 1501 adding M slots in the first node can be found in Figure 5 Step 503 of the method 500 is not described in detail here.
[0230] Optionally, the first key further includes a second fragment key, and the second fragment key in the first key is the next fragment key after the first fragment key. The processing unit 1501 is further configured to:
[0231] 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 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 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;
[0232] Determine a second node, wherein 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, the third pointer information points to the second leaf node, and the second leaf node stores a second key-value pair;
[0233] The first pointer information is set to point to the second node.
[0234] Optionally, the detailed implementation process of the processing unit 1501 obtaining the second key-value pair can be found in Figure 8 Step 801 of the method 800 is not described in detail here.
[0235] Optionally, the detailed implementation process of the processing unit 1501 determining the second node is shown in Figure 8 Step 803 of the method 800 is not 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 Figure 8 Step 804 of the method 800 is not 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, and the processing unit 1501 is further configured to:
[0238] Get a third key-value pair to be saved, the third key-value pair includes a third key and a third value, the third key includes 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;
[0239] 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 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] The fourth pointer information is set to point to the third node.
[0241] Optionally, the detailed implementation process of the processing unit 1501 obtaining the third key-value pair can be found in Fig.11 Step 1101 of the method 1100 is not described in detail here.
[0242] Optionally, the detailed implementation process of the processing unit 1501 determining the third node and the fourth node can be found in Fig.11 Step 1103 of the method 1100 is not described in detail here.
[0243] Optionally, the processing unit 1501 sets the fourth pointer information to point to the third node. Fig.11 Step 1104 of the method 1100 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 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;
[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 Fig.14 Step 1401 of the method 1400 is not described in detail here.
[0249] Optionally, the processing unit 1501 updates 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. Fig.14 Steps 1403 and 1404 of the method 1400 are not 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 may be implemented by software or hardware. For example, the implementation of the processing unit 1501 is described below by taking the processing unit 1501 as an example. Similarly, the implementation of the storage unit 1502 may 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. Among them, the computing instance may include at least one of a physical host (computing device), a virtual machine, and a container. Further, the above-mentioned 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 (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 data centers with similar geographical locations. Among them, usually a region may include multiple AZs.
[0253] Similarly, multiple hosts / virtual machines / containers used to run the code can be distributed in the same virtual private cloud (VPC) or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
[0254] As an example of a hardware functional unit, the processing unit 1501 may include at least one computing device, such as a server, etc. Alternatively, the processing unit 1501 may also be a device 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 the processing unit 1501 can be distributed in the same region or in different regions. The multiple computing devices included in the processing unit 1501 can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the processing unit 1501 can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[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, and the processing unit 1501 and the storage unit 1505 respectively implement different steps of the method provided in any of the above embodiments to realize all functions of the data processing device 1500.
[0257] In the embodiment of the present application, since the storage unit saves the first fragment key and the first pointer information to a free slot in the content part of the first node, if a processor also needs to save other fragment keys and other pointer information to the first node, the processor also saves other fragment keys and other pointer information to other free slots in the content part of the first node in the above manner. Since writing data to two different free 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] See also Fig.16 , the present application embodiment provides a computing device 1600. For example, the computing device 1600 may be Figure 1 The device in the computing end of the system shown, or Figure 5 The method 500 shown, Figure 8 The method 800 shown, Fig.11 The method 1100 or Fig.14 The apparatus in method 1400 is shown.
[0259] like Fig.16 As shown, computing device 1600 includes: bus 1602, processor 1604, memory 1606 and communication interface 1608. Processor 1604, memory 1606 and communication interface 1608 communicate through bus 1602. Computing device 1600 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in computing device 1600.
[0260] The bus 1602 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.16 The bus 1604 is represented by only one line, but does not mean that there is only one bus or one type of bus. The bus 1604 may include a path for transmitting information between various components of the computing device 1600 (eg, the processor 1604, the memory 1606, and the communication interface 1608).
[0261] The processor 1604 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0262] The memory 1606 may include a volatile memory, such as a random access memory (RAM). The memory 1606 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0263] See also Fig.16 , the memory 1606 stores executable program codes, and the processor 1604 executes the executable program codes to respectively implement the functions of the processing unit 1501 and the storage unit 1502 in the device 1500 shown in the figure, thereby implementing the method provided by any of the above embodiments. That is, the memory 1606 stores instructions for executing the method provided by any of the above embodiments. Or,
[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 communication networks.
[0265] The embodiment of the present application also provides 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 smart phone.
[0266] like Fig.17 As shown, 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 data management method. 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.
[0268] In some possible implementations, one or more computing devices in a data processing cluster may be connected via a network, which may be a wide area network or a local area network. Fig.18 A possible implementation is shown. Fig.18 As shown, two computing devices 1600A and 1600B are connected via a network. Specifically, they are connected to the network via a communication interface in each computing device.
[0269] In this type of possible implementation, the memory 1606 in the computing device 1600A stores the execution Fig.15 Instructions for the functions of the processing unit 1501 in the illustrated embodiment. Meanwhile, the memory 1606 in the computing device 1600B stores instructions for executing the functions of the processing unit 1501 in the illustrated embodiment. Fig.15 Instructions for the functionality of the save unit 1502 in the illustrated embodiment.
[0270] It should be understood that Fig.18 The functions of the computing device 1600A shown in FIG. 1 may also be completed by multiple computing devices 1600. Similarly, the functions of the computing device 1600B may also be completed by multiple computing devices 1600.
[0271] The present application embodiment also provides another data processing cluster. The connection relationship between the computing devices in the data processing cluster can be similarly referred to as Fig.18 The connection mode of the data processing cluster is different in that 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.
[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 may jointly execute instructions for executing the method provided in any of the above embodiments.
[0273] The present application also provides a computer program product including instructions. The computer program product may be a software or program product including instructions that can be run on a computing device or stored in 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 embodiment of 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 containing one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to execute the method provided in any of the above embodiments.
[0275] A person 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 instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0276] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present application shall be included in the protection scope 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 device 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.
