Skiplist-based data read-write method, system, device and storage medium
By introducing feature values into the skip list to record the branching position of the node and the partial values after the branching, the comparison overhead problem when the key is long is solved, and more efficient data read and write performance is achieved.
Patent Information
- Application Number
- PCT/CN2024/099648
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-06-25
- Filing Date
- 2024-06-17
- Publication Date
- 2025-01-02
AI Technical Summary
When the key is long, the comparison operation in skip list-based data read/write methods incurs significant runtime resource overhead, affecting search efficiency.
By introducing feature values into the skip list, each node's fork position relative to its predecessor node and at least some of the values after the fork are recorded, omitting the repeated comparison process of common parts and optimizing the comparison operation.
It effectively saves comparison overhead, improves data read and write performance, and reduces the resource consumption of comparison operations.
Smart Images

Figure CN2024099648_02012025_PF_FP_ABST
Abstract
Description
Data reading and writing method, system, device and storage medium based on jump table
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on June 25, 2023, with application number 202310755146.6 and application name “Data reading and writing method, system, device and storage medium based on jump table”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] One or more embodiments of the present specification relate to the field of data reading and writing technology, and in particular, to a data reading and writing method based on a jump table, a storage system, an electronic device, and a computer-readable storage medium. Background Art
[0003] A skip list (SkipList) is a randomized data structure, essentially an ordered linked list capable of binary search. It adds multiple levels of indexing to the existing ordered linked list, enabling fast search. Skip lists not only improve search performance but also the performance of insertion and deletion operations. During the data addition, deletion, query, and modification process, an inevitable step is to compare the key of the tuple to be added, deleted, or modified (also known as the key in key-value storage) with the key stored in the skip list node to locate the location of the addition, deletion, query, or modification.
[0004] For example, during the search process, the key of the element to be searched needs to be compared with the key in the node of the jump list to locate the node to be searched, so as to read the specific content of the element to be searched using the key of the node to be searched as the index; however, when the key is long, the running resource overhead required for the comparison operation is large.
[0005] Summary of the Invention
[0006] In view of this, one or more embodiments of this specification provide a data reading and writing method based on a skip table, a storage system, an electronic device, and a computer-readable storage medium.
[0007] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:
[0008] According to a first aspect of one or more embodiments of this specification, a data reading and writing method based on a skip table is provided. The skip table includes multiple index levels, and nodes in the skip table are used to store keys and first characteristic values. The first characteristic value is used to record the bifurcation position of the key of the current node relative to the key of the predecessor node, and at least a partial value of the key of the current node after the bifurcation position. The method includes:
[0009] Get the target key of the element to be read or written;
[0010] If the target key is different from the key of the first node of the skip list, the next node pointed to by the first node at the highest index level is determined as the node to be compared, and the following process is performed repeatedly until the preset condition is met:
[0011] Compare the second eigenvalue of the target key with the first eigenvalue of the node to be compared; wherein the second eigenvalue is used to record the fork position of the target key relative to the key of the predecessor node of the node to be compared, and at least a portion of the value of the target key after the fork position;
[0012] If the two are different, the node to be compared in the next cycle is determined according to the size relationship indicated by the comparison result;
[0013] If the preset conditions are met, the read and write operations of the element to be read and written are performed according to the node to be compared in the last cycle.
[0014] According to a second aspect of one or more embodiments of the present specification, a storage system is provided, including a data reading and writing device and a skip table; the skip table includes multiple index levels, and nodes in the skip table are used to store keys and a first characteristic value of the node relative to a predecessor node, the first characteristic value being used to record a bifurcation position between the key of the node and the key of the predecessor node, as well as at least a portion of a value subsequent to the bifurcation position;
[0015] The data reading and writing device is used to execute the method described in any one of the first aspects.
[0016] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0017] processor;
[0018] a memory for storing processor-executable instructions;
[0019] Wherein, when the processor executes the executable instructions, it is used to implement the method described in the first aspect.
[0020] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the steps of any of the above methods are implemented.
[0021] The technical solutions provided by the embodiments of the present disclosure may have the following beneficial effects:
[0022] In the disclosed embodiment, by obtaining the first eigenvalue of the node in the jump table and the second eigenvalue of the target key, the second eigenvalue of the target key is compared with the first eigenvalue of the node to be compared, thereby omitting the repeated comparison process of the common part, effectively saving comparison overhead, and optimizing read and write performance.
[0023] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] FIG1 is a schematic diagram of an ordered linked list and characteristic values provided by an exemplary embodiment.
[0025] FIG2 is a schematic diagram of a skip table and a first eigenvalue provided by an exemplary embodiment.
[0026] FIG3 is a schematic diagram of a data reading and writing method based on a skip table provided by an exemplary embodiment.
[0027] FIG4 is a schematic diagram of a first characteristic value of a composite key provided by an exemplary embodiment.
[0028] FIG5 is a schematic diagram of a first characteristic value of another composite key provided by an exemplary embodiment.
[0029] FIG6 is a schematic diagram of a storage system provided by an exemplary embodiment.
[0030] FIG7 is a schematic structural diagram of a device provided by an exemplary embodiment. DETAILED DESCRIPTION
[0031] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The implementations described in the following exemplary embodiments are not intended to represent all implementations consistent with one or more embodiments of this specification. Rather, they are merely examples of apparatuses and methods consistent with certain aspects of one or more embodiments of this specification, as detailed in the appended claims.
[0032] It should be noted that in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the method may include more or fewer steps than those described in this specification. In addition, a single step described in this specification may be broken down into multiple steps for description in other embodiments, and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0033] A database is a warehouse that organizes, stores, and manages data according to its structure. It is a collection of large amounts of data that is stored in a computer for a long time and is organized, shareable, and uniformly managed.
[0034] Key-value storage, also known as KV storage, is a NoSQL (Not Only SQL) storage method. It organizes, indexes, and stores data as key-value pairs. KV storage is well-suited for data storage that doesn't involve excessive data relationships and offers better read and write performance than database storage.
[0035] Databases and key-value stores typically require a large amount of storage space, so they must be stored according to a specific design. Otherwise, data searches, deletions, and insertions will be inefficient. One data structure used for storing data is the LSM-Tree (Log Structured Merge Tree). The LSM-Tree is a hierarchical, ordered, disk-oriented data structure whose core concept is to improve write performance by converting all random writes into sequential writes. Its main process involves appending all write requests to a log file (WAL file) and then inserting them into the in-memory MemTable. When memory reaches a certain limit, the data files are sequentially written to disk, forming an internally ordered disk file. When reading data, a multi-way merge method is used to read from both the in-memory file and the disk file.
[0036] WAL, or Write Ahead Log, is a common method in KV storage / database systems to ensure the atomicity and durability of data operations. Disk I / O operations are often a major bottleneck in KV storage / database efficiency. Given the same data volume, using WAL can reduce I / O volume during transaction commits and convert random writes to sequential writes, thereby improving system performance.
[0037] MemTable (memory table) is the storage structure of the WAL file content in memory, usually implemented using a skip list (SkipList), which provides an operation interface for writing, deleting, and reading key-value pairs.
[0038] A skip list (SkipList) is a randomized data structure, essentially an ordered linked list capable of binary search. It adds multiple levels of indexing to the existing ordered linked list, enabling fast search. Skip lists not only improve search performance but also the performance of insertion and deletion operations. During the data addition, deletion, query, and modification process, an inevitable step is to compare the key of the tuple to be added, deleted, or modified (also known as the key in key-value storage) with the key stored in the skip list node to locate the location of the addition, deletion, query, or modification.
[0039] For example, during the search process, it is necessary to compare the key of the element to be searched with the key in the node of the jump list to locate the node to be searched, so as to read the specific content of the element to be searched with the key of the node to be searched as the index; however, in the case of long keys, the running resource overhead required for the comparison operation is large. For example, please refer to the sorted linked list shown in Figure 1 (taking a single-level index as an example for explanation), the sorted list includes 5 nodes {a, b, c, d, e}, assuming that the key is stored in the linked list (the gray part in Figure 1), and the data type of the key is a string type. If you want to locate whether there is a node in the linked list whose string is equal to the string S to be searched, the practice in the related art is to compare the entire string one by one until it is located that the string of a node is greater than or equal to the string S. In the case of long strings, the comparison operation overhead is large.
[0040] To address the problems in the related art, the embodiments of this specification introduce the concept of eigenvalues, which are used to reduce comparison overhead through eigenvalue comparison. Here, an example of eigenvalues is provided, with reference to Figure 1. Considering that sorted linked lists have certain common prefixes, the inventors additionally record the end position of the common prefix between each node and its predecessor node to reduce repeated and inefficient operations. Furthermore, to more efficiently utilize memory, they also record at least some of the node-specific data after each node and its predecessor node forks.
[0041] Please refer to Figure 1. (1) Node a has no predecessor node, and the subscript of the preset bifurcation position is 0, which constitutes the eigenvalue (0, ABC); (2) The predecessor node a of node b has a common prefix of ABCD, which constitutes the eigenvalue (4, XYZ); (3) The predecessor node b of node c has a common prefix of ABCDX, which constitutes the eigenvalue (5, ZZZ); (4) The predecessor node c of node d has a common prefix of ABC, which constitutes the eigenvalue (3, OXY); (5) The predecessor node d of node e has a common prefix of ABCOX, which constitutes the eigenvalue (5, ZMN).
[0042] In response to the problems in the related art, the embodiments of this specification realize the generation of the first characteristic value of each node relative to the predecessor node during the creation of the skip table, and record it in the node of the skip table. The skip table includes multiple index layers, and the nodes in the skip table are used to store keys and first characteristic values. The first characteristic value is used to record the bifurcation position of the key of this node relative to the key of the predecessor node, and at least part of the value of the key of this node after the bifurcation position. Among them, the bifurcation position refers to the position where the value of the key of this node starts to differentiate with respect to the value of the key of the predecessor node.
[0043] For example, referring to the skip list shown in FIG2 , the data type of the key stored in the node is a string type, and each node includes at least one first eigenvalue. Exemplarily, the number of first eigenvalues of each node is equal to the number of index levels corresponding to the node. In other words, each node except the first node in the skip list corresponds to N index levels, and thus has N predecessor nodes, and thus has N first eigenvalues, where N is an integer greater than 0. The first node in the skip list has no predecessor node, and the bifurcation position can be assumed to be 0.
[0044] Refer to Figure 2. Assuming that we record the length of the common prefix of the node relative to the predecessor node and the 3 characters after the fork, we have:
[0045] (1) Node a has no predecessor node, and the subscript of the preset bifurcation position is 0, corresponding to the highest, second highest, and lowest index levels, there are three first eigenvalues, all of which are (0, ABC);
[0046] (2) Node b corresponds to the lowest index level. The predecessor node in the lowest index level is a. The common prefix of nodes a and b is ABCD, which constitutes the first eigenvalue (4, XYZ).
[0047] (3) Node c corresponds to the second highest and lowest index levels. The predecessor node in the second highest index level is a. The common prefix of nodes a and c is ABCD, which constitutes the first eigenvalue (4, XZZ). The predecessor node in the lowest index level is b. The common prefix of nodes b and c is ABCDX, which constitutes the first eigenvalue (5, ZZZ).
[0048] (4) Node d corresponds to the lowest index level. Its predecessor node in the lowest index level is c. Their common prefix is ABC, which constitutes the first eigenvalue (3,OXY).
[0049] (5) Node e corresponds to the highest, second highest, and lowest index layers. The predecessor node in the highest index layer is a, and the common prefix of the two is ABC, which constitutes the first eigenvalue (3, OXZ); the predecessor node in the second highest index layer is c, and the common prefix of the two is ABC, which constitutes the first eigenvalue (3, OXZ); the predecessor node in the lowest index layer is d, and the common prefix of the two is ABCOX, which constitutes the first eigenvalue (5, ZMN).
[0050] In response to the problems in the related art, referring to FIG3 , an embodiment of this specification provides a data reading and writing method based on a jump table. The method can be executed by a data reading and writing device, and the method includes:
[0051] In S101 , the target key of the element to be read or written is obtained.
[0052] In S102, if the target key is different from the key of the first node of the jump table, the next node pointed to by the first node in the highest index layer is determined to be the node to be compared, and the following process is executed in a loop until the preset condition is met: the second eigenvalue of the target key is compared with the first eigenvalue of the node to be compared; wherein the second eigenvalue is used to record the bifurcation position of the target key relative to the key of the predecessor node of the node to be compared, and at least part of the value of the target key after the bifurcation position; if the two are different, the node to be compared in the next loop process is determined according to the size relationship indicated by the comparison result.
[0053] In S103 , if the preset conditions are met, the read and write operations of the element to be read and written are performed according to the node to be compared in the last loop process.
[0054] This embodiment converts the comparison process between the target key of the element to be read or written and the key of the node in the jump table into a comparison process between the second eigenvalue of the target key and the first eigenvalue of the node to be compared, thereby omitting the repeated comparison process of the common part, effectively saving comparison overhead, and achieving performance optimization.
[0055] In some embodiments, the elements to be read and written include elements to be read and elements to be written.
[0056] If it is an element to be read, the preset condition includes: the target key is the same as the key of the node to be compared. If the preset condition is met, the node to be compared in the last loop process can be determined as the read node corresponding to the target key in the jump table, and the specific content of the element to be read can be read from the corresponding storage location using the key in the read node as an index. In one possible scenario, if it is determined that the keys of all nodes in the jump table are different from the target key of the element to be read, a prompt message indicating that the content of the element to be read is not stored can be output.
[0057] If it is an element to be written, there are two cases: one is to modify the content of the stored element, and the other is to write a new element.
[0058] For the first case, the preset conditions include: the target key is the same as the key of the node to be compared; when the preset conditions are met, the node to be compared in the last loop process can be used to determine the write node corresponding to the target key in the jump table, and the key in the write node is used as the index to modify the specific content of the element to be written in the corresponding storage location.
[0059] For the second case, the preset conditions include: there is no next node to be compared; that is, the size relationship between the keys of all nodes in the jump list and the key of the element to be written has been determined through the comparison process, and no further comparison is required. Then, if the preset conditions are met, the insertion position of the node corresponding to the element to be written can be determined based on the node to be compared in the last loop process to implement the write operation of the element to be written. For example, assuming that the jump list is sorted from small to large, if the node to be compared in the last loop process is larger than the target key of the element to be written, the previous position of the node to be compared in the last loop process is determined as the insertion position; if the node to be compared in the last loop process is smaller than the target key of the element to be written, the next position of the node to be compared in the last loop process is determined as the insertion position.
[0060] In some embodiments, if the target key is the same as the key of the first node in the skip list, the subsequent comparison process is not required. If it is an element to be read, the specific content of the element to be read is read from the corresponding storage location using the key in the first node as the index. If it is an element to be written, and the first case is the case, the specific content of the element to be written in the corresponding storage location is modified using the key in the first node as the index.
[0061] In some embodiments, the nodes in the skip list can be sorted from small to large according to the key, or can be sorted from large to small according to the key. Different sorting relationships will result in different comparison results.
[0062] If the nodes in the skip list are sorted from small to large according to the key, then when the target key is greater than the key of the first node in the skip list, the next node pointed to by the first node in the highest index layer is determined as the node to be compared, and the following process is executed in a loop until the preset condition is met: the second eigenvalue of the target key is compared with the first eigenvalue of the node to be compared; wherein the second eigenvalue is used to record the bifurcation position of the target key relative to the key of the predecessor node of the node to be compared, and at least part of the value of the target key after the bifurcation position; if the comparison result indicates that the target key is smaller than the key of the node to be compared, the next node pointed to by the predecessor node of the node to be compared in the next index layer is determined as the node to be compared in the next loop process; if the comparison result indicates that the target key is greater than the key of the node to be compared, the next node pointed to by the node to be compared in this index layer is determined as the node to be compared in the next loop process.
[0063] If the nodes in the skip list are sorted from large to small according to the key, then when the target key is smaller than the key of the first node in the skip list, the next node pointed to by the first node in the highest index layer is determined as the node to be compared, and the following process is executed in a loop until the preset condition is met: the second eigenvalue of the target key is compared with the first eigenvalue of the node to be compared; wherein the second eigenvalue is used to record the bifurcation position of the target key relative to the key of the predecessor node of the node to be compared, and at least part of the value of the target key after the bifurcation position; if the comparison result indicates that the target key is greater than the key of the node to be compared, the next node pointed to by the predecessor node of the node to be compared in the next index layer is determined as the node to be compared in the next loop process; if the comparison result indicates that the target key is smaller than the key of the node to be compared, the next node pointed to by the node to be compared in this index layer is determined as the node to be compared in the next loop process.
[0064] In some embodiments, the data type of the key stored in any node in the skip list can be a string type. Referring to FIG2 , the first characteristic value of any node includes: the first length of the common prefix between the key of the node and the key of the predecessor node, and at least some of the characters of the key of the node after the common prefix. The second characteristic value of the target key includes: the second length of the common prefix between the target key and the key of the predecessor node of the node to be compared, and at least some of the characters of the target key after the common prefix.
[0065] It is understandable that the number of at least some of the characters after the common prefix in the first eigenvalue and the second eigenvalue can be specifically set according to the actual application scenario. For example, the first eigenvalue in Figure 2 includes 3 characters of the key of the node relative to the key of the predecessor node after the common prefix, or it can be 2, 4 or all the remaining characters. This embodiment does not impose any restrictions on this. The size comparison process of the character string is to compare each character according to the ASCII code value corresponding to the character. For example, for the character strings ABC and ACD, first, the first characters are the same, and the second character B is smaller than C, then the character string ABC is smaller than the character string ACD.
[0066] Due to the multi-level index characteristics of the skip list, any node except the first node corresponds to at least one index layer, and has at least one predecessor node. Any node except the first node corresponds to N index layers, and has N predecessor nodes, and corresponds to N first eigenvalues, where N is an integer greater than 0.
[0067] Next, we take the example of the nodes in the skip list being sorted from small to large by key to illustrate the comparison process:
[0068] First, the target key is compared with the key of the first node of the skip list. If the target key is the same as the key of the first node of the skip list, the matching node is determined, and there is no need to perform the following operations. The subsequent read and write operations are performed according to the matching node. If the target key is different from the key of the first node of the skip list, specifically, (1) if the target key is smaller than the key of the first node of the skip list, it means that the target key does not exist in the skip list. For the case where the element to be written is a new element, the insertion position can be determined before the first node to realize the write operation of the element to be written. For other cases, if the target key does not exist in the skip list, an error message can be output.
[0069] (2) If the target key is greater than the key of the first node of the jump table, it is necessary to continue the comparison and generate a second characteristic value of the target key relative to the first node. The second characteristic value is used for the bifurcation position of the target key relative to the key of the first node, and at least part of the value of the target key after the bifurcation position, and the next node pointed to by the first node in the highest index layer is determined as the node to be compared. The following process is executed in a loop until the preset condition is met: the second characteristic value of the target key is compared with the first characteristic value of the node to be compared; if the two are different, the node to be compared in the next loop process is determined according to the size relationship indicated by the comparison result.
[0070] It is understood that the second eigenvalue of the target key being compared and the first eigenvalue of the node to be compared are generated relative to the same predecessor node. In the first case, if the second length is greater than the first length, indicating that the target key is smaller than the key of the node to be compared, the next node pointed to by the predecessor node of the node to be compared at the next index level is determined as the node to be compared in the next loop process.
[0071] In the second case, if the second length is less than the first length, indicating that the target key is greater than the key of the node to be compared, a second characteristic value of the target key relative to the node to be compared is generated, and the next node pointed to by the node to be compared in this index layer is determined as the node to be compared in the next loop process.
[0072] In the third case, if the second length is equal to the first length and the characters in the second eigenvalue are smaller than the characters in the first eigenvalue, indicating that the target key is smaller than the key of the node to be compared, the next node pointed to by the predecessor node of the node to be compared in the next index layer is determined as the node to be compared in the next loop.
[0073] In the fourth case, if the second length is equal to the first length and the characters in the second eigenvalue are greater than the characters in the first eigenvalue, indicating that the target key is greater than the key of the node to be compared, the second eigenvalue of the target key relative to the node to be compared is generated, and the next node pointed to by the node to be compared in this index layer is determined as the node to be compared in the next loop.
[0074] For example, please refer to Figure 2. Assume that there is a target key S (assumed to be ******). In order to save comparison steps, in the absence of a predecessor node, assuming that the bifurcation position is 0, the eigenvalue (0, ***) of the target key S can be generated and first compared with the first eigenvalue (0, ABC) of the highest index layer of the head node a. At the same time, the second eigenvalue of the target key S relative to the head node a is generated, assuming it is (α, β).
[0075] If the target key S is smaller than the head node a, the target key S does not exist in the skip list and the search is exited. For example, assuming the target key S is ABADAB, the head node has no predecessor node, and the fork position is 0, the eigenvalue (0, ABA) of the target key S can be generated and compared with the first eigenvalue (0, ABC) of the highest index layer of the head node a. If ABA is smaller than ABC, the target key S is smaller than the head node a.
[0076] If the target key S is greater than the head node a, the next node e pointed to by the head node a at the highest index layer is determined to be the node to be compared; for example, assuming the target key S is ABDDAB, the head node has no predecessor node, and assuming the fork position is 0, the eigenvalue (0, ABD) of the target key S can be generated and compared with the first eigenvalue (0, ABC) of the highest index layer of the head node a. If ABD is greater than ABC, then the target key S is greater than the head node a.
[0077] The second eigenvalue of the target key S (assuming it is (α, β)) is compared with the first eigenvalue (3, OXZ) of the highest index level of the node to be compared e. There are the following situations:
[0078] (1) α>3, indicating that the target key S and node a have a longer common prefix, node e is larger than the target key S, and there is no need to compare the content. The next node to be compared is the next node c pointed to by node a in the second highest index layer. For example, assuming that the target key S is ABCDABC, the second eigenvalue (α, β) of the target key S relative to the head node a is (4, ABC); the first length of the node e to be compared is 3, indicating that the character "O" at the 4th position of node e is larger than the character "D" at the 4th position of node a, and the first length of the target key is 4, indicating that the character "D" at the 4th position of the target key S is the same as the character "D" at the 4th position of node a. Obviously, the character "O" at the 4th position of node e is larger than the character "D" at the 4th position of target key S, and node e is larger than the target key S.
[0079] (2) α<3, indicating that the target key S and node a have a shorter common prefix. The target key S is larger than node a, which means that the target key S is also larger than node e. The second eigenvalue of the target key S relative to node e is generated, and the next node to be compared is the next node pointed to by node e at the highest index level. For example, assuming that the target key S is ABXXABC, the second eigenvalue (α, β) of the target key S relative to the head node a is (2, XXA); the first length of the node e to be compared is 3, indicating that the character at the third position of node e is the same as the character at the third position of node a, and the first length of the target key is 2, indicating that the character at the third position of the target key S is larger than the character at the third position of node a. Obviously, the character at the third position of the target key S is larger than the character at the third position of node e, that is, the target key S is larger than node e.
[0080] (3) α=3, indicating that the bifurcation positions are the same, and the next character comparison process is performed. If β in the target key S is less than OXZ in node e, it means that the target key S is less than node e, and the next node to be compared is the next node c pointed to by node a in the second highest index layer.
[0081] (4) α=3, indicating that the bifurcation positions are the same, and then the next character comparison process is performed. If β in the target key S is greater than OXZ in the node e, it means that the target key S is greater than the node e, and the second eigenvalue of the target key S relative to the node e is generated. The next node to be compared is the next node pointed to by the node e in the highest index layer.
[0082] In one possible implementation, if the characters in the first feature value and the characters in the second feature value are not all the remaining characters after the common prefix, and the second feature value is the same as the first feature value, the remaining characters of the target key after the common prefix and the remaining characters of the node to be compared after the common prefix can be compared.
[0083] For example, suppose there are keys A (ABCDEF), key B (ABCEDFJE) and key C (ABCEDFGF); relative to key A, key B has a common prefix of ABC, and the three characters after the bifurcation position are saved, that is, (3, EDF); relative to key A, key C has a common prefix of ABC, and the three characters after the bifurcation position are saved, also (3, EDF); the common prefix is the same, and the three characters saved are also the same, but the saved characters are not all the remaining characters after the bifurcation position, so the comparison of the last remaining part is also to compare "JE" in key B with "GF" in key C.
[0084] In the first case, if the former is greater than the latter, a second eigenvalue of the target key relative to the node to be compared is generated, and the next node pointed to by the node to be compared in this index layer is determined as the node to be compared in the next loop process.
[0085] In the second case, if the former is smaller than the latter, the next node pointed to by the predecessor node of the node to be compared in the next index layer is determined as the node to be compared in the next loop process.
[0086] In the third case, if the remaining value in the target key is equal to the remaining value in the key of the node to be compared, it indicates that the target key is the same as the key of the node to be compared, and the loop ends.
[0087] Continuing with the above example, please refer to Figure 2. In the process of comparing the second eigenvalue of the target key S (assuming it is (α, β)) with the first eigenvalue (3, OXZ) of the highest index layer of the node e to be compared, if the two are the same, that is, the bifurcation position is the same, and some of the characters after the bifurcation position are also the same, then compare the remaining characters after the bifurcation position, and compare the target key S and the string content of node e from the 6th character onwards. If the target key S is greater than node e, generate the second eigenvalue of the target key S relative to node e, and the next node to be compared is the next node pointed to by node e in the highest index layer. If the target key S is less than node e, the next node to be compared is the next node c pointed to by node a in the second highest index layer.
[0088] Those skilled in the art will appreciate that the above exemplary description is based on the arrangement of nodes in the skip list from small to large keys. The arrangement of nodes in the skip list from large to small keys is also applicable to this solution and will not be elaborated here.
[0089] In this embodiment, when the data type of the key is a string type, by generating the above-mentioned first eigenvalue and second eigenvalue and comparing them, the comparison process of the common prefix part is avoided, the comparison overhead is reduced, and the comparison efficiency is improved.
[0090] In other embodiments, the key stored in any node in the skip list is a composite key, which is a key composed of two or more attributes that uniquely identify any record in the table. The data types of different keys in the composite key can be string type or integer type.
[0091] Here is an example of the first and second eigenvalues corresponding to the composite key form:
[0092] Please refer to the data structure of the first eigenvalue shown in Figure 4. The first eigenvalue includes the index of the forked key. If the data type of the forked key is a string type, the first eigenvalue also includes the first length of the common prefix between the forked key of the node and the forked key of the predecessor node, and at least part of the characters of the forked key of the node relative to the forked key of the predecessor node after the common prefix. If the data type of the forked key is an integer type and the number of bits is N, the first eigenvalue also includes the high M bits of the N-bit integer of the forked key of the node, where M≤N.
[0093] In other words, if the data type of the forked key is a string type, the forked position information in the first eigenvalue includes the index and the first length of the forked key; if the data type of the forked key is an integer type, the forked position information in the second eigenvalue includes the index of the forked key.
[0094] Similarly, the second eigenvalue includes the index of the target key and the key forked from the predecessor node of the node to be compared. If the data type of the forked key is a string type, the second eigenvalue also includes the second length of the common prefix between the forked key in the target key and the forked key of the predecessor node of the node to be compared, and at least part of the characters of the forked key in the target key relative to the forked key of the predecessor node of the node to be compared after the common prefix. If the data type of the forked key is an integer type and the number of bits is N, the second eigenvalue also includes the high M bits of the N-bit integer of the forked key in the target key; M≤N.
[0095] In other words, if the data type of the forked key is a string type, the forked position information in the second eigenvalue includes the index and the second length of the forked key; if the data type of the forked key is an integer type, the forked position information in the second eigenvalue includes the index of the forked key.
[0096] For example, for the following Table 1, the composite key may include grade, class, and name, where the data types of grade and class are integer types, and the data type of name is string type.
[0097] Table 1
[0098] For example, the data type of the index of different keys in the composite key can be an integer type. For example, the index of the first key can be set to 0, the index of the second key to 1, the index of the third key to 2, the index of the fourth key to 3, and so on, in ascending order from left to right. Continuing with the above example, the index of the first key "grade" is 0, the index of the second key "class" is 1, and the index of the third key "name" is 2.
[0099] For example, the data type of the indexes of different keys in a composite key can also be a character type. For example, the index of the first key can be set to a, the index of the second key can be set to b, the index of the third key can be set to c, the index of the fourth key can be set to d, and so on, in ascending order from left to right of the different keys in the composite key.
[0100] Among them, if the data type of the forked key is an integer type and it is a signed integer, it is necessary to first convert the signed integer to an unsigned integer and then take the high M bits to avoid the influence of the sign and ensure the accuracy of the comparison result.
[0101] For example, assuming that M is 33, if the data type of the forked key is an integer type and a signed integer, preprocessing is required. If the forked key is a 64-bit signed integer, first add 0x8000000000000000 to convert it into a comparable 64-bit unsigned positive integer. If the forked key is a signed integer of 32 bits or less, first add 0x80000000 to convert it into a comparable 32-bit unsigned positive integer; after converting to an unsigned positive integer, select the high 33 bits and discard the low bits. If the data type of the forked key is an integer type and an unsigned integer, if the forked key is an unsigned integer of 32 bits or less, use the original value directly; otherwise, select the high 33 bits and discard the low bits.
[0102] Next, we take the example where the nodes in the skip list are sorted from small to large by key, and the indexes of different keys in the composite key are sorted in ascending order by the index values of different keys in the composite key from left to right to illustrate the comparison process:
[0103] First, the target key is compared with the key of the first node of the skip list. If the target key is greater than the key of the first node of the skip list, a second eigenvalue of the target key relative to the first node is generated, where the second eigenvalue includes the index of the key from which the target key is forked relative to the first node, and the next node pointed to by the first node at the highest index layer is determined as the node to be compared. The following process is looped until a preset condition is met: the second eigenvalue of the target key is compared with the first eigenvalue of the node to be compared; if the two are different, the node to be compared in the next loop is determined according to the size relationship indicated by the comparison result.
[0104] In the first case, if the index in the second eigenvalue is greater than the index in the first eigenvalue, indicating that the target key is smaller than the key of the node to be compared, the next node pointed to by the predecessor node of the node to be compared in the next index layer is determined as the node to be compared in the next loop process.
[0105] In the second case, if the index in the second eigenvalue is smaller than the index in the first eigenvalue, indicating that the target key is greater than the key of the node to be compared, a second eigenvalue of the target key relative to the node to be compared is generated, and the next node pointed to by the node to be compared in this index layer is determined as the node to be compared in the next loop process.
[0106] In the third case, if the index in the second eigenvalue is equal to the index in the first eigenvalue, indicating that the target key and the key of the fork of the node to be compared are the same, then the node to be compared in the next loop process is determined based on the size relationship between the target key and the key of the node to be compared indicated by the remaining content of the second eigenvalue and the remaining content of the first eigenvalue.
[0107] In one possible implementation, if the data type of the forked key is an integer, the second eigenvalue of the target key further includes the upper M bits of the N-bit integer of the forked key; M≤N. The first eigenvalue of the node to be compared further includes the upper M bits of the N-bit integer of the forked key; M≤N.
[0108] In the first case, if the integer in the second eigenvalue is smaller than the integer in the first eigenvalue, indicating that the target key is smaller than the key of the node to be compared, the next node pointed to by the predecessor node of the node to be compared in the next index layer is determined as the node to be compared in the next loop process.
[0109] In the second case, if the integer in the second eigenvalue is greater than the integer in the first eigenvalue, indicating that the target key is greater than the key of the node to be compared, a second eigenvalue of the target key relative to the node to be compared is generated, and the next node pointed to by the node to be compared in this index layer is determined as the node to be compared in the next loop process.
[0110] In the third case, if the integer in the second eigenvalue is equal to the integer in the first eigenvalue, then the remaining content in the target key and the remaining content in the node to be compared are continued to be compared.
[0111] In another possible implementation, if the data type of the forked key is a string type, the first characteristic value of the node to be compared also includes the first length of the common prefix between the forked key of the node and the forked key of the predecessor node, and at least part of the characters of the forked key of the node after the common prefix; the second characteristic value of the target key also includes the second length of the common prefix between the forked key in the target key and the forked key of the predecessor node of the node to be compared, and at least part of the characters of the forked key in the target key after the common prefix.
[0112] In the first case, if the second length is greater than the first length, indicating that the target key is smaller than the key of the node to be compared, the next node pointed to by the predecessor node of the node to be compared in the next index layer is determined as the node to be compared in the next loop process.
[0113] In the second case, if the second length is less than the first length, indicating that the target key is greater than the key of the node to be compared, a second characteristic value of the target key relative to the node to be compared is generated, and the next node pointed to by the node to be compared in this index layer is determined as the node to be compared in the next loop process.
[0114] In the third case, if the second length is equal to the first length and the characters in the second eigenvalue are smaller than the characters in the first eigenvalue, indicating that the target key is smaller than the key of the node to be compared, the next node pointed to by the predecessor node of the node to be compared in the next index layer is determined as the node to be compared in the next loop.
[0115] In the fourth case, if the second length is equal to the first length and the characters in the second eigenvalue are greater than the characters in the first eigenvalue, indicating that the target key is greater than the key of the node to be compared, the second eigenvalue of the target key relative to the node to be compared is generated, and the next node pointed to by the node to be compared in this index layer is determined as the node to be compared in the next loop.
[0116] For the case where the data type of the forked key is a string type, the relevant comparison process can be found in the description process of the key data type being a string type, which will not be repeated here.
[0117] Those skilled in the art will appreciate that the above exemplary description is based on the arrangement of nodes in the skip list from small to large keys. The arrangement of nodes in the skip list from large to small keys is also applicable to this solution and will not be elaborated here.
[0118] In this embodiment, for composite keys, by generating the above-mentioned first eigenvalue and second eigenvalue and comparing them, comparison of identical keys is skipped, and comparison is started from the forked keys, thereby reducing comparison overhead and improving comparison efficiency.
[0119] In some embodiments, considering the dynamic insertion / deletion scenario, it is possible to insert node M between adjacent nodes X and Y during the query. If the path search of X->M->Y is used, when comparing node Y, the characteristic value of the key to be checked relative to M is used, and the current node Y record may still be the first characteristic value of node Y relative to node X, which has not been updated. The mismatch comparison may cause the comparison result to be wrong. Therefore, please refer to Figure 5. The first characteristic value also includes the first identifier of the predecessor node. The second characteristic value also includes the second identifier of the predecessor node of the node to be compared. In the process of comparing the second characteristic value of the target key with the first characteristic value of the node to be compared, the first identifier in the first characteristic value of the node to be compared is first compared with the second identifier in the second characteristic value of the target key. If the two are the same, it means that the predecessor node of the node to be compared and the target key is the same, then the other contents in the second characteristic value of the target key can be compared with the other contents in the first characteristic value of the node to be compared. The relevant comparison process can be found in the above description and will not be repeated here.
[0120] If the first identifier in the first eigenvalue of the node to be compared is different from the second identifier in the second eigenvalue of the target key, the target key is compared with the key of the node to be compared, that is, the entire content of the target key is compared with the entire content of the key of the node to be compared, so as to avoid mismatched comparison that may lead to incorrect comparison results and ensure the accuracy of the comparison.
[0121] It is understood that this embodiment does not impose any restrictions on the number of bits of the first eigenvalue and the second eigenvalue, and can be specifically set according to the actual application scenario. In one example, the number of bits of the first eigenvalue and the second eigenvalue can be 64 bits. In another example, the number of bits of the first eigenvalue and the second eigenvalue can be 128 bits. This embodiment of the specification does not impose any restrictions on this.
[0122] For example, in combination with Figure 5, the number of bits of the first eigenvalue is 64 bits. Figure 5 shows the number of bits of different parts in the first eigenvalue, such as the number of bits of the first identifier of the predecessor node can be 28 bits, and the index of the forked key can be 3 bits; if the forked key is an integer type, M in Figure 5 is 33 bits; if the forked key is a string type, the first length is 9 bits, and the number of characters after the common prefix is 24 bits.
[0123] In some embodiments, the nodes in the jump table are used to store a key, a pointer to the next node, and a first characteristic value; wherein the first characteristic value and the pointer can be stored in the same cache line, thereby reducing the probability of cache misses during the comparison process. The various technical features of the above embodiments can be arbitrarily combined as long as there is no conflict or contradiction between the combinations of features. However, due to space limitations, they are not described one by one. Therefore, any combination of the various technical features in the above embodiments also falls within the scope of this specification.
[0124] In some embodiments, please refer to Figure 6. The embodiments of this specification also provide a storage system, including a data reading and writing device and a skip table; the skip table includes multiple index layers, and the nodes in the skip table are used to store keys and the first characteristic value of the current node relative to the predecessor node, and the first characteristic value is used to record the bifurcation position information of the key of the current node and the key of the predecessor node and at least part of the value after the bifurcation position; the data reading and writing device is used to execute any of the methods described above.
[0125] Exemplarily, the data reading and writing device includes a target key acquisition module, a comparison module and a reading and writing module.
[0126] The target key acquisition module is used to obtain the target key of the element to be read or written.
[0127] The comparison module is configured to, if the target key is different from the key of the first node of the skip list, determine the next node pointed to by the first node at the highest index level as the node to be compared, and cyclically execute the following process until a preset condition is satisfied: compare the second eigenvalue of the target key with the first eigenvalue of the node to be compared; wherein the second eigenvalue is used to record the bifurcation position of the target key relative to the key of the predecessor node of the node to be compared, and at least a portion of the value of the target key after the bifurcation position; if the two are different, determine the node to be compared in the next loop process according to the size relationship indicated by the comparison result;
[0128] The read / write module is configured to perform read / write operations on the element to be read / written according to the node to be compared in the last cycle if a preset condition is met.
[0129] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.
[0130] In some embodiments, FIG7 is a schematic structural diagram of a device provided by an exemplary embodiment. Referring to FIG7 , at the hardware level, the device includes a processor 702, an internal bus 704, a network interface 706, a memory 708, and a non-volatile memory 710, and may also include hardware required for other services. One or more embodiments of this specification may be implemented based on software, such as the processor 702 reading the corresponding computer program from the non-volatile memory 710 into the memory 708 and then running it. Of course, in addition to software implementation, one or more embodiments of this specification do not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but may also be hardware or logic devices.
[0131] The data reading and writing device shown in FIG6 can be applied to the device shown in FIG7 to implement the technical solution of this specification.
[0132] In some embodiments, an embodiment of this specification further provides an electronic device, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor implements any of the above methods by running the executable instructions.
[0133] In some embodiments, the embodiments of this specification further provide a computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of any of the methods described above.
[0134] In some embodiments, the electronic device integrates a computer program product, and when the electronic device executes the computer program product, the data reading and writing method provided in the embodiments of this specification is implemented.
[0135] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0136] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer, which may be in the form of a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email transceiver, game console, tablet computer, wearable device, or any combination of these devices.
[0137] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0138] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0139] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.
[0140] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0141] The foregoing description of this specification describes specific embodiments. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0142] The terms used in one or more embodiments of this specification are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of this specification. The singular forms "a," "an," "the," and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0143] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when..." or "when..." or "in response to determining."
[0144] The above description is merely a preferred embodiment of one or more embodiments of this specification and is not intended to limit one or more embodiments of this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of this specification shall be included in the scope of protection of one or more embodiments of this specification.
Claims
1. A data reading and writing method based on a jump table, characterized in that: The skip table includes a plurality of index layers, and the nodes in the skip table are used to store keys and first characteristic values, and the first characteristic value is used to record the fork position of the key of the current node relative to the key of the predecessor node, and at least a partial value of the key of the current node after the fork position; the method includes: Get the target key of the element to be read or written; If the target key is different from the key of the first node of the skip list, the next node pointed to by the first node at the highest index level is determined as the node to be compared, and the following process is executed repeatedly until the preset condition is met: Compare the second eigenvalue of the target key with the first eigenvalue of the node to be compared; wherein the second eigenvalue is used to record the fork position of the target key relative to the key of the predecessor node of the node to be compared, and at least a partial value of the target key after the fork position; If the two are different, the node to be compared in the next cycle is determined according to the size relationship indicated by the comparison result; If the preset conditions are met, the read and write operations of the elements to be read and written are performed according to the nodes to be compared in the last cycle.
2. The method according to claim 1, characterized in that The elements to be read and written include elements to be read and elements to be written; If it is an element to be read, the preset conditions include: the target key is the same as the key of the node to be compared; If it is an element to be written, the preset condition includes: the target key is the same as the key of the node to be compared or there is no next node to be compared.
3. The method according to claim 1, characterized in that Determining the nodes to be compared in the next cycle according to the size relationship indicated by the comparison result includes: If the nodes in the jump list are sorted from small to large keys, if the comparison result indicates that the target key is smaller than the key of the node to be compared, the next node pointed to by the predecessor node of the node to be compared in the next index layer is determined as the node to be compared in the next loop process; if the comparison result indicates that the target key is greater than the key of the node to be compared, the next node pointed to by the node to be compared in the current index layer is determined as the node to be compared in the next loop process; If the nodes in the jump list are sorted from large to small according to the key, if the comparison result indicates that the target key is greater than the key of the node to be compared, the next node pointed to by the predecessor node of the node to be compared in the next index layer is determined as the node to be compared in the next loop process; if the comparison result indicates that the target key is less than the key of the node to be compared, the next node pointed to by the node to be compared in this index layer is determined as the node to be compared in the next loop process.
4. The method according to any one of claims 1 to 3, characterized in that: The data type of the key stored in any node in the skip list is a string type; The first characteristic value of any node includes: the first length of the common prefix between the key of the node and the key of the predecessor node, and at least part of the characters of the key of the node after the common prefix; The second characteristic value of the target key includes: a second length of a common prefix between the target key and a key of a predecessor node of the node to be compared, and at least part of the characters of the target key after the common prefix.
5. The method according to claim 4, characterized in that The method further comprises: If the target key is different from the key of the first node of the skip list, generating a second characteristic value of the target key relative to the first node; If the nodes in the skip list are sorted from small to large according to the key, if the two are different, determining the node to be compared in the next cycle according to the size relationship indicated by the comparison result, including: If the second length is greater than the first length, indicating that the target key is less than the key of the node to be compared, the next node pointed to by the predecessor node of the node to be compared in the next index layer is determined as the node to be compared in the next loop process; If the second length is less than the first length, it indicates that the target key is greater than the key of the node to be compared, a second eigenvalue of the target key relative to the node to be compared is generated, and the next node pointed to by the node to be compared in the current index layer is determined as the node to be compared in the next loop process; If the second length is equal to the first length and the character in the second characteristic value is smaller than the character in the first characteristic value, it indicates that the target key is smaller than the key of the node to be compared, and the next node pointed to by the predecessor node of the node to be compared in the next index layer is determined as the node to be compared in the next loop process; If the second length is equal to the first length and the characters in the second eigenvalue are greater than the characters in the first eigenvalue, indicating that the target key is greater than the key of the node to be compared, a second eigenvalue of the target key relative to the node to be compared is generated, and the next node pointed to by the node to be compared in this index layer is determined as the node to be compared in the next loop.
6. The method according to claim 5, characterized in that In the case where the characters in the first feature value and the characters in the second feature value are not all the remaining characters after the common prefix, the method further includes: If the second characteristic value is the same as the first characteristic value, compare the remaining characters after the common prefix in the target key with the remaining characters after the common prefix in the node to be compared; If the former is greater than the latter, a second eigenvalue of the target key relative to the node to be compared is generated, and the next node pointed to by the node to be compared in the current index layer is determined as the node to be compared in the next cycle; If the former is smaller than the latter, determine the next node pointed to by the predecessor node of the node to be compared in the next index layer. It is the node to be compared in the next cycle; If the former is equal to the latter, it indicates that the target key is the same as the key of the node to be compared, and the loop ends.
7. The method according to any one of claims 1 to 3, characterized in that: The key stored in any node in the skip list is a composite key, and the data types of different keys in the composite key include a string type or an integer type; The first characteristic value of any node includes the index of the key forked from the node and the predecessor node; if the data type of the forked key is a string type, the first characteristic value also includes the first length of the common prefix between the forked key of the node and the forked key of the predecessor node, and at least part of the characters of the forked key of the node after the common prefix; if the data type of the forked key is an integer type and the number of bits is N, the first characteristic value also includes the high M bits of the N-bit integer of the forked key of the node, M≤N; The second eigenvalue includes the index of the key forked from the target key and the predecessor node of the node to be compared; if the data type of the forked key is a string type, the second eigenvalue also includes the second length of the common prefix between the forked key in the target key and the forked key of the predecessor node of the node to be compared, and at least part of the characters of the forked key in the target key after the common prefix; if the data type of the forked key is an integer type and the number of bits is N, the second eigenvalue also includes the high M bits of the N-bit integer of the forked key in the target key; M≤N.
8. The method according to claim 7, characterized in that The method further comprises: If the target key is different from the key of the first node of the skip list, generating a second characteristic value of the target key relative to the first node; If the nodes in the skip list are sorted from small to large according to the key, if the two are different, determining the node to be compared in the next cycle according to the size relationship indicated by the comparison result, including: If the index in the second eigenvalue is greater than the index in the first eigenvalue, indicating that the target key is less than the key of the node to be compared, the next node pointed to by the predecessor node of the node to be compared in the next index layer is determined as the node to be compared in the next loop process; If the index in the second eigenvalue is less than the index in the first eigenvalue, indicating that the target key is greater than the key of the node to be compared, a second eigenvalue of the target key relative to the node to be compared is generated, and the next node pointed to by the node to be compared in the current index layer is determined as the node to be compared in the next loop process; If the index in the second eigenvalue is equal to the index in the first eigenvalue, the node to be compared in the next loop is determined according to the size relationship between the target key and the key of the node to be compared indicated by the remaining content of the second eigenvalue and the remaining content of the first eigenvalue.
9. The method according to claim 8, characterized in that In the case where the data type of the forked key is an integer type, determining the node to be compared in the next loop process according to the size relationship between the target key indicated by the remaining content of the second eigenvalue and the remaining content of the first eigenvalue and the key of the node to be compared, comprises: If the integer in the second eigenvalue is smaller than the integer in the first eigenvalue, it indicates that the target key is smaller than the key of the node to be compared, and the next node pointed to by the predecessor node of the node to be compared in the next index layer is determined as the node to be compared in the next loop process; If the integer in the second eigenvalue is greater than the integer in the first eigenvalue, indicating that the target key is greater than the key of the node to be compared, a second eigenvalue of the target key relative to the node to be compared is generated, and the next node pointed to by the node to be compared in this index layer is determined as the node to be compared in the next loop.
10. The method according to claim 8, characterized in that In the case where the data type of the forked key is a string type, determining the node to be compared in the next loop process according to the size relationship between the target key indicated by the remaining content of the second eigenvalue and the remaining content of the first eigenvalue and the key of the node to be compared, comprises: If the second length is greater than the first length, indicating that the target key is less than the key of the node to be compared, the next node pointed to by the predecessor node of the node to be compared in the next index layer is determined as the node to be compared in the next loop process; If the second length is less than the first length, it indicates that the target key is greater than the key of the node to be compared, a second eigenvalue of the target key relative to the node to be compared is generated, and the next node pointed to by the node to be compared in the current index layer is determined as the node to be compared in the next loop process; If the second length is equal to the first length and the character in the second characteristic value is smaller than the character in the first characteristic value, it indicates that the target key is smaller than the key of the node to be compared, and the next node pointed to by the predecessor node of the node to be compared in the next index layer is determined as the node to be compared in the next loop process; If the second length is equal to the first length and the characters in the second eigenvalue are greater than the characters in the first eigenvalue, indicating that the target key is greater than the key of the node to be compared, a second eigenvalue of the target key relative to the node to be compared is generated, and the next node pointed to by the node to be compared in this index layer is determined as the node to be compared in the next loop.
11. The method according to claim 1, characterized in that The first characteristic value also includes a first identifier of a predecessor node; the second characteristic value also includes a second identifier of a predecessor node of the node to be compared; The comparing the second characteristic value of the target key with the first characteristic value of the node to be compared comprises: If the first identifier in the first eigenvalue of the node to be compared is equal to the second identifier in the second eigenvalue of the target key Similarly, compare other contents in the second eigenvalue of the target key with other contents in the first eigenvalue of the node to be compared; The method further comprises: If the first identifier in the first characteristic value of the node to be compared is different from the second identifier in the second characteristic value of the target key, the target key is compared with the key of the node to be compared.
12. A storage system, characterized in that: It includes a data reading and writing device and a skip table; the nodes in the skip table are used to store keys and the first characteristic value of the node relative to the predecessor node, and the first characteristic value is used to record the bifurcation position information of the key of the node and the key of the predecessor node and at least part of the value after the bifurcation position; The data reading and writing device is used to execute the method according to any one of claims 1 to 11.
13. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 11 by running the executable instructions.
14. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the instruction is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
Citation Information
Patent Citations
Method and apparatus for optimizing data storage
CN111274245A
Data writing and reading method and device and data reading and writing system
CN114816219A
Data read-write method, system and equipment based on skip list and storage medium
CN116680275A
Modified skip list database structure and method for access
US5664179A
Client terminal data collection method and apparatus
WO2016206605A1