Range query method and device for repeated index data in skip table
By assigning modification sequence number seq to multiple modification operations of the same Key value in the jump table, and generating the start pointer first and end pointer last, the time-consuming problem of repeated index data range query in the LSM tree storage engine is solved, and complexity reduction and performance improvement are achieved.
Patent Information
- Application Number
- CN202211422686.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2042-11-15
AI Technical Summary
In the prior art, when the jump table of the LSM tree storage engine faces a large number of repeated index data, the range query takes a long time, which affects the retrieval performance.
The jump table assigns a modification sequence number seq to multiple modification operations of the same Key value, and generates the start pointer first and end pointer last for quickly positioning the query range.
Through the introduction of the start pointer first and end pointer last, the query complexity is reduced from O(N) to O(1), greatly optimizing the range query performance of the repeated index key values.
Smart Images

Figure CN116049230B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of storage technology, and more particularly to a range query method and device for repeated index data in a skip table. Background Art
[0002] In the storage field, LSM trees are a storage engine technology. LSM trees, short for Log Structured Merge Tree, are hierarchical, ordered, disk-oriented data structures. LSM trees record all incremental modification operations and, when they reach a certain size, apply these modifications in batches to disk. These incremental modification operations are first recorded in memory and then applied to disk after they grow to a certain set value. Skip tables are a commonly used in-memory index in LSM trees. These incremental modification operations are populated in skip tables, providing key-based queries and range operations. In real-world applications, a large number of set / incr operations on the same key value are all recorded in memory. When a range query is called, the forward / backward pointers are traversed at the L0 layer. When there are many records with the same key value, traversing these record entries is quite time-consuming.
[0003] Specifically, the LSM tree storage engine assigns a modification sequence number seq to each modification operation to distinguish multiple operations on the same key value. The allocation strategy is to increase sequentially from 1, and each modification operation will use a new modification sequence number seq. The LSM tree storage engine will first record these modification operations in memory, usually using a skip table. The record format is as follows: Figure 1 As shown in the figure, the basic data structure of the jump table is: {prev, next}, which stores the forward pointer / backward pointer.
[0004] a. Write process: When writing, apply these modification operations (key, seq) to the skip list in sequence, find the node (the node is smaller than the key + seq, and the next node of the node is larger than the key + seq), add the modification operation (key, seq) to the found node, modify the back pointer of the forward node and the forward pointer of the backward node, and modify the forward pointer and back pointer of the current node;
[0005] b. Range query process: specify the query key value, find the node corresponding to the key value through binary search in the skip table, and use the forward pointer or backward pointer to traverse all nodes in sequence until a node that does not meet the query conditions is found, and then stop the query.
[0006] In a range query, the same key value may have many different modification sequence numbers (seq), resulting in tens of thousands or even more nodes with the same key value. In this scenario, sequential traversal is a very time-consuming operation.
[0007] Therefore, the present invention solves the problem that a large amount of repeated index data is stored in the skip table, which causes a long time to query the range and has a serious impact on the retrieval performance.
[0008] In view of this, the present invention patent is proposed. Summary of the Invention
[0009] To address the above-mentioned issues, the present invention proposes a range query method for duplicate index data in a skip table, which has better performance when there are many duplicate keys. Specifically, the following technical solutions are adopted:
[0010] Range query methods applied to skip table duplicate index data include:
[0011] When multiple modification operations are performed on the same key value in the stored data, a modification sequence number seq is assigned in sequence for each modification operation, and an operation record (key, seq) is generated;
[0012] Write the operation record (key, seq) into the skip table. When generating a node, assign a start pointer first and an end pointer last to the operation record with the same key value. The start pointer first points to the node with the smallest modification sequence number seq among the operation records with the same key value (key, seq). The end pointer last points to the node with the largest modification sequence number seq among the operation records with the same key value (key, seq).
[0013] When performing a range query, the corresponding node is searched in the skip table according to the query key value, and the query range of the query key value is located based on the start pointer first and the end pointer last.
[0014] As an optional embodiment of the present invention, in the range query method applied to the skip table duplicate index data of the present invention, the operation record (key, seq) is written into the skip table. When generating a node, the start pointer first and the end pointer last are assigned to the operation record with the same key value, including:
[0015] Write the operation record (key, seq) into the jump table according to the modification sequence seq, and generate a new node;
[0016] Check whether the key value of the newly generated node is the same as the key value of the forward node;
[0017] If they are not the same, the assignment of the starting pointer first and the ending pointer last is ignored;
[0018] If they are the same, get the starting pointer first of the forward node, assign it to the starting pointer first of the current newly generated node, get the starting node pointed to by the starting pointer first, and modify the ending pointer last of the starting node to the current newly generated node.
[0019] As an optional embodiment of the present invention, the range query method applied to the repeated index data of the skip table of the present invention includes:
[0020] When the starting node (key, seq1) is newly generated, the jump table does not assign the starting pointer first and the ending pointer last;
[0021] When the key value of the newly generated node (key, seq2) is the same as the key value of the starting node, and the forward pointer of the newly generated node (key, seq2) points to the starting node (key, seq1);
[0022] Then assign a starting pointer first to the newly generated node (key, seq2), the starting pointer first points to the starting node (key, seq1), and assign an ending pointer last to the starting node (key, seq1), the ending pointer last points to the newly generated node (key, seq2).
[0023] As an optional embodiment of the present invention, the range query method applied to the repeated index data of the skip table of the present invention includes:
[0024] When the key value of the newly generated node (key, seqn) is the same as the key value of the starting node, there are intermediate nodes (key, seq2), ..., (key, seqn-1) between the newly generated node (key, seqn) and the starting node (key, seq1), and the forward pointer of the newly generated node (key, seqn) points to the intermediate node (key, seqn-1), and the forward pointer of the next intermediate node points to the previous intermediate node;
[0025] Then assign a starting pointer first to the newly generated node (key, seqn), the starting pointer first points to the starting node (key, seq1), and modify the ending pointer last of the starting node (key, seq1) to point to the newly generated node (key, seqn).
[0026] As an optional embodiment of the present invention, in the range query method applied to repeated index data in a skip table of the present invention, when performing a range query, searching for a corresponding node in the skip table according to a query key value, and locating the query range of the query key value based on a start pointer first and an end pointer last includes:
[0027] When performing range queries from small to large based on the query key value;
[0028] In the skip table, according to the query key value, search for the node (key, seqmin) with the same key value and the smallest modified sequence number seq, and determine the node (key, seqmax) with the same key value and the largest modified sequence number seq according to the end pointer last of the node;
[0029] The minimum boundary node and the maximum boundary node for querying the key value from small to large range are determined according to the node (key, seqmin) with the smallest modification sequence number seq and the node (key, seqmax) with the largest modification sequence number seq.
[0030] As an optional embodiment of the present invention, in the range query method applied to repeated index data in a skip table of the present invention, when performing a range query, searching for a corresponding node in the skip table according to a query key value, and locating the query range of the query key value based on a start pointer first and an end pointer last includes:
[0031] When performing a range query from largest to smallest based on the query key value;
[0032] In the skip table, according to the query key value, search for the node (key, seqmax) with the same key value and the largest modified sequence number seq, and determine the node (key, seqmin) with the same key value and the smallest modified sequence number seq according to the end pointer last of the node;
[0033] The maximum boundary node and the minimum boundary node of the query key value range from large to small are determined according to the node (key, seqmax) with the largest modification sequence number seq and the node (key, seqmin) with the smallest modification sequence number seq.
[0034] As an optional embodiment of the present invention, in the range query method applied to the skip table repeated index data of the present invention, when the same key value in the stored data is modified multiple times, a modification sequence number seq is sequentially assigned for each modification operation, and the generated operation record (key, seq) includes:
[0035] The LSM tree storage engine assigns a modification sequence number seq to each modification operation of the stored data;
[0036] When multiple consecutive modification operations are performed on the same key value, a set of operation records (key, seq) with the same key value and consecutive modification sequence numbers seq will be generated;
[0037] When the operation record (key, seq) is written into the jump table, the starting pointer first and the ending pointer last are assigned.
[0038] The present invention also provides a range query device for repeated index data in a skip table, comprising:
[0039] The operation record generation module, when multiple modification operations are performed on the same key value in the stored data, assigns a modification sequence number seq in sequence for each modification operation and generates an operation record (key, seq);
[0040] An operation record writing module writes the operation record (key, seq) into a skip list. When generating a node, a start pointer first and an end pointer last are assigned to the operation record with the same key value. The start pointer first points to the node with the smallest modification sequence number seq among the operation records with the same key value (key, seq), and the end pointer last points to the node with the largest modification sequence number seq among the operation records with the same key value (key, seq).
[0041] The range query module searches for the corresponding node in the skip table according to the query key value when performing a range query, and locates the query range of the query key value based on the start pointer first and the end pointer last.
[0042] The present invention also provides an electronic device, comprising a processor and a memory, wherein the memory is used to store a computer executable program. When the computer program is executed by the processor, the processor executes the range query method applied to the repeated index data of the jump table.
[0043] The present invention also provides a computer-readable storage medium storing a computer-executable program. When the computer-executable program is executed, the range query method applied to the repeated index data of the skip list is implemented.
[0044] Compared with the prior art, the present invention has the following beneficial effects:
[0045] For the skip list of the LSM tree storage engine, there is a scenario where a large number of set / incr operations for the same key value will form a huge number of nodes with the same key value in the skip list. The time complexity of the range query for this key value is equivalent to the total number of operations. The range query method for repeated index data in the skip list of the present invention is applied to this scenario. It adds a starting pointer first and an ending pointer last index between consecutive nodes with the same key value. When performing a range query, the head and tail nodes can be located with a single query. Compared with the solution of traversing all key value nodes one by one in the background technology, the query complexity is reduced from O(N) to O(1), greatly optimizing the performance of the traditional skip list for range queries on a large number of repeated index key values.
[0046] Furthermore, according to the principle of the range query method applied to the skip table repeated index data of the present invention, the more times the same key value is operated, the more significant the performance improvement.
[0047] Therefore, the range query method applied to the repeated index data of the skip table of the present invention innovatively proposes a starting pointer first and an ending pointer last to solve the internal management scheme of the repeated index key value, reducing the range query complexity of the repeated index key value from O(N) in the prior art to O(1), greatly optimizing the performance of the traditional skip table in the range query of a large number of repeated index key values. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 A schematic diagram of the format of existing skip table records in the background art;
[0049] Figure 2 A flow chart of a range query method for repeated index data in a skip list according to an embodiment of the present invention;
[0050] Figure 3 Schematic diagram of the format of a jump table for recording multiple consecutive modifications of the same key value according to an embodiment of the present invention. DETAILED DESCRIPTION
[0051] To make the purpose, technical solutions and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them.
[0052] Therefore, the following detailed description of the embodiments of the present invention is not intended to limit the scope of the claimed invention, but merely represents some embodiments of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without creative effort shall fall within the scope of protection of the present invention.
[0053] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features and technical solutions therein may be combined with each other.
[0054] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not require further definition or explanation in subsequent drawings.
[0055] In the description of the present invention, it should be noted that the terms "upper" and "lower" and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, or the orientations or positional relationships in which the inventive product is typically placed when in use, or the orientations or positional relationships commonly understood by those skilled in the art. Such terms are intended solely to facilitate the description of the present invention and simplify the description, and are not intended to indicate or imply that the device or element referred to must have a specific orientation, be constructed, or operate in a specific orientation. Therefore, they should not be construed as limitations on the present invention. Furthermore, the terms "first" and "second" and the like are used solely for distinction and should not be construed as indicating or implying relative importance.
[0056] See also Figure 2 As shown, the range query method applied to the skip table repeated index data of this embodiment includes:
[0057] When multiple modification operations are performed on the same key value in the stored data, a modification sequence number seq is assigned in sequence for each modification operation, and an operation record (key, seq) is generated;
[0058] Write the operation record (key, seq) into the skip table. When generating a node, assign a start pointer first and an end pointer last to the operation record with the same key value. The start pointer first points to the node with the smallest modification sequence number seq among the operation records with the same key value (key, seq). The end pointer last points to the node with the largest modification sequence number seq among the operation records with the same key value (key, seq).
[0059] When performing a range query, the corresponding node is searched in the skip table according to the query key value, and the query range of the query key value is located based on the start pointer first and the end pointer last.
[0060] For the skip list of the LSM tree storage engine, there is a scenario where a large number of set / incr operations for the same key value will form a huge number of nodes with the same key value in the skip list. The time complexity of the range query for this key value is equal to the total number of operations. The range query method applied to the repeated index data of the skip list of this embodiment targets this scenario. It adds the starting pointer first and the ending pointer last index between consecutive nodes with the same key value. During the range query, the head and tail nodes can be located with a single query. Compared with the solution of traversing all key value nodes one by one in the background technology, the query complexity is reduced from O(N) to O(1), greatly improving the performance of the traditional skip list for range queries on a large number of repeated index key values.
[0061] Furthermore, according to the principle of the range query method applied to the skip list repeated index data in this embodiment, the more times the same key value is operated, the more significant the performance improvement.
[0062] Therefore, the range query method applied to the repeated index data of the skip table in this embodiment innovatively proposes a starting pointer first and an ending pointer last to solve the internal management scheme of the repeated index key value, reducing the range query complexity of the repeated index key value from O(N) in the existing technology to O(1), greatly optimizing the performance of the traditional skip table in the range query of a large number of repeated index key values.
[0063] Specifically, in the range query method applied to the skip table duplicate index data of this embodiment, the operation record (key, seq) is written into the skip table. When generating a node, the start pointer first and the end pointer last are assigned to the operation record with the same key value, including:
[0064] Write the operation record (key, seq) into the jump table according to the modification sequence seq, and generate a new node;
[0065] Check whether the key value of the newly generated node is the same as the key value of the forward node;
[0066] If they are not the same, the assignment of the starting pointer first and the ending pointer last is ignored;
[0067] If they are the same, get the starting pointer first of the forward node, assign it to the starting pointer first of the current newly generated node, get the starting node pointed to by the starting pointer first, and modify the ending pointer last of the starting node to the current newly generated node.
[0068] The range query method applied to the repeated index data of the skip table in this embodiment is aimed at the situation where consecutive nodes with the same key value appear when the operation record (key, seq) is written into the skip table. At this time, the starting pointer first and the ending pointer last are assigned to the consecutive nodes with the same key value, thereby improving the range query performance of the repeated key value index. When the key value of the newly generated node when the operation record (key, seq) is written into the skip table is different from the key value of the previous node, there is no need to assign the starting pointer first and the ending pointer last.
[0069] In the range query method for duplicate index data in a skip list of this embodiment, when an operation record (key, seq) is written into the skip list, a process of generating a starting node (key, seq1) and a starting pointer first and an ending pointer last includes the following steps:
[0070] When the starting node (key, seq1) is newly generated, the jump table does not assign the starting pointer first and the ending pointer last;
[0071] When the key value of the newly generated node (key, seq2) is the same as the key value of the starting node, and the forward pointer of the newly generated node (key, seq2) points to the starting node (key, seq1);
[0072] Then assign a starting pointer first to the newly generated node (key, seq2), the starting pointer first points to the starting node (key, seq1), and assign an ending pointer last to the starting node (key, seq1), the ending pointer last points to the newly generated node (key, seq2).
[0073] Furthermore, the range query method applied to the skip table duplicate index data of this embodiment includes:
[0074] When the key value of the newly generated node (key, seqn) is the same as the key value of the starting node, there are intermediate nodes (key, seq2), ..., (key, seqn-1) between the newly generated node (key, seqn) and the starting node (key, seq1), and the forward pointer of the newly generated node (key, seqn) points to the intermediate node (key, seqn-1), and the forward pointer of the next intermediate node points to the previous intermediate node;
[0075] Then assign a starting pointer first to the newly generated node (key, seqn), the starting pointer first points to the starting node (key, seq1), and modify the ending pointer last of the starting node (key, seq1) to point to the newly generated node (key, seqn).
[0076] See also Figure 3 As shown, in this embodiment, for multiple consecutive modification records of the same key value (key:demo seq:1), (key:demo seq:2), (key:demo seq:3), ..., (key:demo seq:10000), the storage form of the L0 layer of the jump table is written. The modification record (key:demo seq:1) is the starting node pointed to by the start pointer first of other modification records (key:demo seq:2), (key:demoseq:3), ..., (key:demo seq:10000), and the end pointer last of the modification record (key:demo seq:1) points to (key:demo seq:10000).
[0077] In the range query method applied to duplicate index data in a skip table of this embodiment, when performing a range query, the corresponding node is searched in the skip table according to the query key value, and the query range of the query key value is located based on the start pointer first and the end pointer last.
[0078] When performing range queries from small to large based on the query key value;
[0079] In the skip table, according to the query key value, search for the node (key, seqmin) with the same key value and the smallest modified sequence number seq, and determine the node (key, seqmax) with the same key value and the largest modified sequence number seq according to the end pointer last of the node;
[0080] The minimum boundary node and the maximum boundary node for querying the key value from small to large range are determined according to the node (key, seqmin) with the smallest modification sequence number seq and the node (key, seqmax) with the largest modification sequence number seq.
[0081] In the range query method applied to duplicate index data in a skip table of this embodiment, when performing a range query, the corresponding node is searched in the skip table according to the query key value, and the query range of the query key value is located based on the start pointer first and the end pointer last.
[0082] When performing a range query from largest to smallest based on the query key value;
[0083] In the skip table, according to the query key value, search for the node (key, seqmax) with the same key value and the largest modified sequence number seq, and determine the node (key, seqmin) with the same key value and the smallest modified sequence number seq according to the end pointer last of the node;
[0084] The maximum boundary node and the minimum boundary node of the query key value range from large to small are determined according to the node (key, seqmax) with the largest modification sequence number seq and the node (key, seqmin) with the smallest modification sequence number seq.
[0085] It can be seen from this that the range query method of this embodiment applied to the repeated index data of the skip table, when performing a range query, when there are a large number of nodes with the same key value, the endpoint boundary of the key can be quickly located through the starting pointer first and the ending pointer last, thereby accelerating the speed of the range query, and there is no need to traverse all the modification record nodes with the same key value according to the forward pointer and backward pointer of each node in the skip table.
[0086] In the range query method applied to the skip table duplicate index data of this embodiment, when the same key value in the stored data is modified multiple times, a modification sequence number seq is sequentially assigned to each modification operation, and the generated operation record (key, seq) includes:
[0087] The LSM tree storage engine assigns a modification sequence number seq to each modification operation of the stored data. The key values of two adjacent modification operations corresponding to the sequentially assigned modification sequence numbers seq may be the same or different.
[0088] When multiple consecutive modification operations are performed on the same key value, a set of operation records (key, seq) with the same key value and consecutive modification sequence numbers seq will be generated;
[0089] When the operation record (key, seq) is written into the jump table, the starting pointer first and the ending pointer last are assigned.
[0090] This embodiment also provides a range query device for repeated index data in a skip table, comprising:
[0091] The operation record generation module, when multiple modification operations are performed on the same key value in the stored data, assigns a modification sequence number seq in sequence for each modification operation and generates an operation record (key, seq);
[0092] An operation record writing module writes the operation record (key, seq) into a skip list. When generating a node, a start pointer first and an end pointer last are assigned to the operation record with the same key value. The start pointer first points to the node with the smallest modification sequence number seq among the operation records with the same key value (key, seq), and the end pointer last points to the node with the largest modification sequence number seq among the operation records with the same key value (key, seq).
[0093] The range query module searches for the corresponding node in the skip table according to the query key value when performing a range query, and locates the query range of the query key value based on the start pointer first and the end pointer last.
[0094] For the skip list of the LSM tree storage engine, there is a scenario where a large number of set / incr operations for the same key value will form a huge number of nodes with the same key value in the skip list. The time complexity of the range query for this key value is equal to the total number of operations. In this embodiment, the range query device for repeated index data in the skip list is applied to this scenario. The operation record writing module adds a starting pointer first and an ending pointer last index between consecutive nodes with the same key value. The range query module can locate the head and tail nodes with a single query during the range query. Compared with the solution of traversing all key value nodes one by one in the background technology, the query complexity is reduced from O(N) to O(1), greatly optimizing the performance of the traditional skip list for range queries on a large number of repeated index key values.
[0095] Moreover, the range query device of this embodiment applied to the skip table repeated index data improves performance more significantly as the number of operations on the same key value increases.
[0096] Therefore, the range query device applied to the repeated index data of the skip table in this embodiment innovatively proposes a starting pointer first and an ending pointer last to solve the internal management scheme of the repeated index key value, reducing the range query complexity of the repeated index key value from O(N) in the prior art to O(1), greatly optimizing the performance of the traditional skip table in the range query of a large number of repeated index key values.
[0097] Specifically, in the range query device for repeated index data in a skip table of this embodiment, the operation record writing module writes the operation record (key, seq) into the skip table. When generating a node, the operation record with the same key value is assigned a start pointer first and an end pointer last, including:
[0098] Write the operation record (key, seq) into the jump table according to the modification sequence seq, and generate a new node;
[0099] Check whether the key value of the newly generated node is the same as the key value of the forward node;
[0100] If they are not the same, the assignment of the starting pointer first and the ending pointer last is ignored;
[0101] If they are the same, get the starting pointer first of the forward node, assign it to the starting pointer first of the current newly generated node, get the starting node pointed to by the starting pointer first, and modify the ending pointer last of the starting node to the current newly generated node.
[0102] In the range query device for duplicate index data of a skip table of this embodiment, the operation record writing module assigns a starting pointer first and an ending pointer last to the consecutive nodes with the same key value when the operation record (key, seq) is written into the skip table, thereby improving the range query performance of the duplicate key value index. When the key value of the newly generated node is different from the key value of the forward node when the operation record (key, seq) is written into the skip table, there is no need to assign the starting pointer first and the ending pointer last.
[0103] In the range query device for duplicate index data in a skip list of this embodiment, when the operation record writing module writes the operation record (key, seq) into the skip list, the process of generating the starting node (key, seq1), the starting pointer first, and the ending pointer last includes:
[0104] When the starting node (key, seq1) is newly generated, the jump table does not assign the starting pointer first and the ending pointer last;
[0105] When the key value of the newly generated node (key, seq2) is the same as the key value of the starting node, and the forward pointer of the newly generated node (key, seq2) points to the starting node (key, seq1);
[0106] Then assign a starting pointer first to the newly generated node (key, seq2), the starting pointer first points to the starting node (key, seq1), and assign an ending pointer last to the starting node (key, seq1), the ending pointer last points to the newly generated node (key, seq2).
[0107] Furthermore, in the range query device for duplicate index data in a skip list of this embodiment, when the operation record writing module writes the operation record (key, seq) into the skip list, the process of generating the starting node (key, seq1) and the starting pointer first and the ending pointer last includes:
[0108] When the key value of the newly generated node (key, seqn) is the same as the key value of the starting node, there are intermediate nodes (key, seq2), ..., (key, seqn-1) between the newly generated node (key, seqn) and the starting node (key, seq1), and the forward pointer of the newly generated node (key, seqn) points to the intermediate node (key, seqn-1), and the forward pointer of the next intermediate node points to the previous intermediate node;
[0109] Then assign a starting pointer first to the newly generated node (key, seqn), the starting pointer first points to the starting node (key, seq1), and modify the ending pointer last of the starting node (key, seq1) to point to the newly generated node (key, seqn).
[0110] See also Figure 3 As shown, in this embodiment, for multiple consecutive modification records of the same key value (key:demo seq:1), (key:demo seq:2), (key:demo seq:3), ..., (key:demo seq:10000), the storage form of the L0 layer of the jump table is written. The modification record (key:demo seq:1) is the starting node pointed to by the start pointer first of other modification records (key:demo seq:2), (key:demoseq:3), ..., (key:demo seq:10000), and the end pointer last of the modification record (key:demo seq:1) points to (key:demo seq:10000).
[0111] In the range query device for repeated index data in a skip table of this embodiment, the range query module searches for a corresponding node in the skip table according to a query key value when performing a range query. The query range of the query key value is located based on the start pointer first and the end pointer last.
[0112] When performing range queries from small to large based on the query key value;
[0113] In the skip table, according to the query key value, search for the node (key, seqmin) with the same key value and the smallest modified sequence number seq, and determine the node (key, seqmax) with the same key value and the largest modified sequence number seq according to the end pointer last of the node;
[0114] The minimum boundary node and the maximum boundary node for querying the key value from small to large range are determined according to the node (key, seqmin) with the smallest modification sequence number seq and the node (key, seqmax) with the largest modification sequence number seq.
[0115] In the range query device for repeated index data in a skip table of this embodiment, the range query module searches for a corresponding node in the skip table according to a query key value when performing a range query. The query range of the query key value is located based on the start pointer first and the end pointer last.
[0116] When performing a range query from largest to smallest based on the query key value;
[0117] In the skip table, according to the query key value, search for the node (key, seqmax) with the same key value and the largest modified sequence number seq, and determine the node (key, seqmin) with the same key value and the smallest modified sequence number seq according to the end pointer last of the node;
[0118] The maximum boundary node and the minimum boundary node of the query key value range from large to small are determined according to the node (key, seqmax) with the largest modification sequence number seq and the node (key, seqmin) with the smallest modification sequence number seq.
[0119] It can be seen from this that in the range query device of this embodiment applied to the repeated index data of the skip list, when the range query module performs a range query, when there are a large number of nodes with the same key value, the endpoint boundary of the key can be quickly located through the start pointer first and the end pointer last, thereby accelerating the speed of the range query, and there is no need to traverse all the modification record nodes with the same key value according to the forward pointer and the backward pointer of each node in the skip list.
[0120] In the range query device for repeated index data in a skip table of this embodiment, when the same key value in the stored data is modified multiple times, the operation record generation module sequentially assigns a modification sequence number seq to each modification operation, and generates an operation record (key, seq) including:
[0121] The LSM tree storage engine assigns a modification sequence number seq to each modification operation of the stored data. The key values of two adjacent modification operations corresponding to the sequentially assigned modification sequence numbers seq may be the same or different.
[0122] When multiple consecutive modification operations are performed on the same key value, a set of operation records (key, seq) with the same key value and consecutive modification sequence numbers seq will be generated;
[0123] When the operation record (key, seq) is written into the jump table, the starting pointer first and the ending pointer last are assigned.
[0124] This embodiment also provides a computer-readable storage medium storing a computer-executable program. When the computer-executable program is executed, the range query method applied to the repeated index data of the skip list is implemented.
[0125] The computer-readable storage medium described in this embodiment may include a data signal propagated in baseband or as part of a carrier wave, which carries a readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or component. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.
[0126] This embodiment further provides an electronic device, including a processor and a memory, wherein the memory is used to store a computer executable program. When the computer program is executed by the processor, the processor executes the range query method applied to the skip list duplicate index data.
[0127] The electronic device is implemented as a general-purpose computing device. The processor may be one or multiple processors operating in concert. The present invention also does not exclude distributed processing, meaning the processors may be dispersed across different physical devices. The electronic device of the present invention is not limited to a single entity but may also be the sum of multiple physical devices.
[0128] The memory stores a computer executable program, typically a machine-readable code, which can be executed by the processor to enable the electronic device to perform the method of the present invention, or at least some of the steps in the method.
[0129] The memory includes a volatile memory, such as a random access memory unit (RAM) and / or a cache memory unit, and may also be a non-volatile memory, such as a read-only memory unit (ROM).
[0130] It should be understood that the electronic devices of the present invention may also include elements or components not shown in the above examples. For example, some electronic devices also include display units such as screens, and some electronic devices also include human-computer interaction elements such as buttons and keyboards. As long as the electronic device can execute a computer-readable program stored in its memory to implement the method of the present invention or at least some of the steps of the method, it can be considered an electronic device covered by the present invention.
[0131] Through the above description of the implementation mode, it is easy for those skilled in the art to understand that the present invention can be implemented by hardware capable of executing a specific computer program, such as the system of the present invention, and the electronic processing unit, server, client, mobile phone, control unit, processor, etc. contained in the system. The present invention can also be implemented by computer software that executes the method of the present invention, such as control software executed by a microprocessor, an electronic control unit, a client, a server, etc. However, it should be noted that the computer software that executes the method of the present invention is not limited to being executed by one or a specific hardware entity, and it can also be implemented in a distributed manner by unspecified specific hardware. For computer software, the software product can be stored in a computer-readable storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), or it can be distributed and stored on a network, as long as it enables an electronic device to execute the method according to the present invention.
[0132] The above embodiments are only used to illustrate the present invention and are not intended to limit the technical solutions described in the present invention. Although this specification has described the present invention in detail with reference to the above embodiments, the present invention is not limited to the above specific implementation methods. Therefore, any modification or equivalent replacement of the present invention; and all technical solutions and improvements thereof that do not depart from the spirit and scope of the invention are included in the scope of the claims of the present invention.
Claims
1. A range query method applied to repeated index data in a skip table, characterized in that: include: When multiple modification operations are performed on the same key value in the stored data, a modification sequence number seq is assigned in sequence for each modification operation, and an operation record (key, seq) is generated; Write the operation record (key, seq) into the skip table. When generating a node, assign a start pointer first and an end pointer last to the operation record with the same key value. The start pointer first points to the node with the smallest modification sequence number seq among the operation records with the same key value (key, seq). The end pointer last points to the node with the largest modification sequence number seq among the operation records with the same key value (key, seq). When performing a range query, the corresponding node is found in the skip table according to the query key value, and the query range of the query key value is located based on the start pointer first and the end pointer last; The operation record (key, seq) is written into the skip table. When generating a node, the start pointer first and the end pointer last are assigned to the operation record with the same key value. Write the operation record (key, seq) into the jump table according to the modification sequence seq, and generate a new node; Check whether the key value of the newly generated node is the same as the key value of the forward node; If they are not the same, the assignment of the starting pointer first and the ending pointer last is ignored; If they are the same, get the starting pointer first of the forward node, assign it to the starting pointer first of the current newly generated node, get the starting node pointed to by the starting pointer first, and modify the ending pointer last of the starting node to the current newly generated node; The range query method applied to the skip table repeated index data includes: When the starting node (key, seq1) is newly generated, the jump table does not assign the starting pointer first and the ending pointer last; When the key value of the newly generated node (key, seq2) is the same as the key value of the starting node, and the forward pointer of the newly generated node (key, seq2) points to the starting node (key, seq1); Then assign a starting pointer first to the newly generated node (key, seq2), the starting pointer first points to the starting node (key, seq1), and assign an ending pointer last to the starting node (key, seq1), the ending pointer last points to the newly generated node (key, seq2); When multiple modification operations are performed on the same key value in the stored data, a modification sequence number seq is assigned in sequence for each modification operation, and the generated operation record (key, seq) includes: The LSM tree storage engine assigns a modification sequence number seq to each modification operation of the stored data; When multiple consecutive modification operations are performed on the same key value, a set of operation records (key, seq) with the same key value and consecutive modification sequence numbers seq will be generated; When writing the operation record (key, seq) into the jump table, the starting pointer first and the ending pointer last are assigned.
2. The range query method for repeated index data in a skip list according to claim 1, characterized in that: include: When the key value of the newly generated node (key, seqn) is the same as the key value of the starting node, there are intermediate nodes (key, seq2), ..., (key, seqn-1) between the newly generated node (key, seqn) and the starting node (key, seq1), and the forward pointer of the newly generated node (key, seqn) points to the intermediate node (key, seqn-1), and the forward pointer of the latter intermediate node points to the previous intermediate node; Then assign a starting pointer first to the newly generated node (key, seqn), the starting pointer first points to the starting node (key, seq1), and modify the ending pointer last of the starting node (key, seq1) to point to the newly generated node (key, seqn).
3. The range query method for repeated index data in a skip list according to claim 1, characterized in that: When performing a range query, searching for a corresponding node in the skip list according to the query key value, and locating the query range of the query key value based on the start pointer first and the end pointer last includes: When performing range queries from small to large based on the query key value; In the skip table, according to the query key value, search for the node with the same key value and the smallest modified sequence number seq (key, seqmin), and determine the node with the same key value and the largest modified sequence number seq (key, seqmax) according to the end pointer last of the node. The minimum boundary node and the maximum boundary node for querying the key value from small to large range are determined according to the node with the smallest modification sequence number seq (key, seqmin) and the node with the largest modification sequence number seq (key, seqmax).
4. The range query method for repeated index data in a skip list according to claim 1, characterized in that: When performing a range query, searching for a corresponding node in the skip list according to the query key value, and locating the query range of the query key value based on the start pointer first and the end pointer last includes: When performing a range query from largest to smallest based on the query key value; In the skip table, find the node with the same key value and the largest modified sequence number seq (key, seqmax) according to the query key value, and determine the node with the same key value and the smallest modified sequence number seq (key, seqmin) according to the end pointer last of the node; The maximum boundary node and the minimum boundary node of the query key value range from large to small are determined according to the node (key, seqmax) with the largest modified sequence number seq and the node (key, seqmin) with the smallest modified sequence number seq.
5. A range query device for repeated index data in a skip list, characterized by comprising: The operation record generation module, when multiple modification operations are performed on the same key value in the stored data, assigns a modification sequence number seq to each modification operation in sequence and generates an operation record (key, seq); The operation record writing module writes the operation record (key, seq) into the skip list. When generating a node, the starting pointer first and the ending pointer last are assigned to the operation record with the same key value. The starting pointer first points to the node with the smallest modification sequence number seq among the operation records with the same key value (key, seq), and the ending pointer last points to the node with the largest modification sequence number seq among the operation records with the same key value (key, seq); Range query module, when performing range query, searches for the corresponding node in the skip table according to the query key value, and locates the query range of the query key value based on the start pointer first and the end pointer last; The operation record (key, seq) is written into the skip table. When generating a node, the start pointer first and the end pointer last are assigned to the operation record with the same key value. Write the operation record (key, seq) into the jump table according to the modification sequence seq, and generate a new node; Check whether the key value of the newly generated node is the same as the key value of the forward node; If they are not the same, the assignment of the starting pointer first and the ending pointer last is ignored; If they are the same, get the starting pointer first of the forward node, assign it to the starting pointer first of the current newly generated node, get the starting node pointed to by the starting pointer first, and modify the ending pointer last of the starting node to the current newly generated node; The range query method applied to the skip table repeated index data includes: When the starting node (key, seq1) is newly generated, the jump table does not assign the starting pointer first and the ending pointer last; When the key value of the newly generated node (key, seq2) is the same as the key value of the starting node, and the forward pointer of the newly generated node (key, seq2) points to the starting node (key, seq1); Then assign a starting pointer first to the newly generated node (key, seq2), the starting pointer first points to the starting node (key, seq1), and assign an ending pointer last to the starting node (key, seq1), the ending pointer last points to the newly generated node (key, seq2); When multiple modification operations are performed on the same key value in the stored data, a modification sequence number seq is assigned in sequence for each modification operation, and the generated operation record (key, seq) includes: The LSM tree storage engine assigns a modification sequence number seq to each modification operation of the stored data; When multiple consecutive modification operations are performed on the same key value, a set of operation records (key, seq) with the same key value and consecutive modification sequence numbers seq will be generated; When writing the operation record (key, seq) into the jump table, the starting pointer first and the ending pointer last are assigned.
6. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory is used to store a computer executable program. When the computer executable program is executed by the processor, the processor executes the range query method applied to the skip list duplicate index data according to any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that A computer executable program is stored, and when the computer executable program is executed, the range query method applied to the repeated index data of the skip list according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Systems and methods for performing a range query on a skiplist data structure
CN109643309A
Indexing method and indexing device for time series data with characteristics based on skip list
CN112597152A