Learning index method and system based on time series data features

By employing a learning-based indexing method based on the characteristics of time-series data, and utilizing B+ index trees and memory buffers to manage time-series data, this approach solves the problems of large memory consumption and long processing times in time-series database indexing methods, achieving high-efficiency query performance and efficient storage space utilization.

CN116881243BActive Publication Date: 2026-05-19BEIJING NOSI SPACETIME TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING NOSI SPACETIME TECH CO LTD
Filing Date
2023-05-31
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

Existing time-series database indexing methods consume a lot of memory and take a long time to index, which cannot meet the query needs of large-scale time-series data.

Method used

A learning-based indexing method based on the characteristics of time-series data is adopted. By dividing the time-series data into multiple data segments according to timestamps, a linear model is constructed, and data insertion, deletion and query operations are performed using B+ index trees and memory buffers, thereby reducing index storage space and time overhead.

Benefits of technology

It improves query performance, reduces index storage space usage, and lowers indexing time, making it suitable for querying large-scale time-series data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116881243B_ABST
    Figure CN116881243B_ABST
Patent Text Reader

Abstract

The application relates to a learning type index method and system based on time sequence data characteristics, and relates to the field of database indexing.The application is used to solve the problems of large memory occupation and long indexing time of the existing time sequence data indexing method.The application comprises the following steps: step one, obtaining time sequence data, dividing the time sequence data into multiple data segments according to time stamps, and constructing a linear model for each data segment;step two, training the linear model obtained in step one by using the time stamp data and offset of the time sequence data, and obtaining a trained linear model;step three, establishing a B+ index tree by using the trained linear model obtained in step two; and step four, based on the B+ index tree obtained in step three, performing time sequence data insertion, time sequence data deletion and index query operations.The application is used for establishing database indexes and performing data insertion, deletion and index operations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of database indexing, and in particular to a learning-based indexing method and system based on the characteristics of time-series data. Background Technology

[0002] With the development of industrialization and informatization, the scale of data stored in databases will shift from the current GB level to the TB level or even the PB level. Such massive amounts of data are time-consuming and labor-intensive to store and retrieve. Therefore, time-series databases have emerged, storing data according to time tags. Time-series data typically has two characteristics: firstly, the data volume is extremely large and the generation speed is fast; secondly, the data query frequency and update frequency are low. Therefore, how to index time-series data has become a key research focus in this field.

[0003] Existing time-series databases still use traditional index structures, which are complex and massive. The traditional index implementation method used in time-series databases currently involves determining which shards the corresponding time-series data is logically stored on using the `seriesKey` of the query, then creating an iterator to read data sequentially from different shards. Data is read in blocks, and within each block, the data is arranged in timestamp order. A binary search is then performed to find the location of the data at the corresponding timestamp. However, with massive amounts of time-series data, traditional index building methods consume enormous amounts of memory, and inserting new data incurs additional index maintenance operations. With the development of big data, traditional index structures can no longer meet the query requirements of time-series workloads in terms of memory usage and time overhead. Summary of the Invention

[0004] The purpose of this invention is to address the problems of large memory consumption and long indexing time in existing time series data indexing methods, and to propose a learning-based indexing method and system based on the characteristics of time series data.

[0005] The specific process of the learning-based indexing method based on time series data features is as follows:

[0006] Step 1: Obtain time series data and divide the time series data into multiple data segments according to timestamps, and build a linear model for each data segment;

[0007] Step 2: Use the timestamp data and data offset of the time series data to train the linear model obtained in Step 1, and obtain the trained linear model.

[0008] Step 3: Build a B+ index tree using the trained linear model obtained in Step 2;

[0009] Step 4: Based on the B+ index tree and memory buffer obtained in Step 3, perform time-series data insertion, time-series data deletion, and index query operations.

[0010] Furthermore, in the linear model of step one, the independent variable is the timestamp data of the time series data, and the dependent variable is the data offset.

[0011] Furthermore, the B+ index tree in step three includes: leaf nodes, root nodes, and internal nodes;

[0012] The leaf nodes are used to store the linear model trained in step two and the block ID;

[0013] The block ID is obtained as follows: First, obtain the data segment corresponding to the trained linear model, then obtain the block that stores the data segment on the disk, and the ID of the current block is the block ID;

[0014] The logical time sequence between leaf nodes is connected by a doubly linked list.

[0015] The root node and the internal nodes are used to store index keys and pointers to the next level nodes;

[0016] The index key is a timestamp.

[0017] Furthermore, the number of memory buffers is one or more;

[0018] The memory buffer is used to store newly inserted timing data;

[0019] The capacity of each memory buffer is the same as the capacity of each leaf node.

[0020] Furthermore, step four, based on the B+ index tree and memory buffer obtained in step three, involves inserting time-series data, including the following steps:

[0021] Determine if the memory buffer is full. If not, store the new time-series data in the first, not-full memory buffer. Once the first, not-full memory buffer is full, construct a leaf node directly from the time-series data in the first memory buffer. Then, start the second, not-full memory buffer, until all memory buffers are full. If all memory buffers are full, create a new leaf node and update the B+ index tree with the new leaf node.

[0022] The new leaf node stores the following: the maximum value of the timestamp, the minimum value of the timestamp, and the linear model and offset corresponding to the new time series data.

[0023] Furthermore, updating the B+ index tree with the new leaf node specifically involves:

[0024] Determine if the root node of the B+ index tree is empty. If it is empty, directly insert the new leaf node as the root node of the B+ index tree. If the root node of the B+ index tree is not empty, check if there is an empty position in the parent node of the leaf node of the B+ index tree. If there is an empty position, insert the new leaf node into the empty position and then update the ancestor node information of the new leaf node. If there is no empty position in the parent node of the leaf node of the B+ index tree, create a new internal node as the parent node of the new leaf node and insert the new internal node into the higher level of the B+ index tree.

[0025] Furthermore, step four involves performing an index query operation based on the B+ index tree and memory buffer obtained in step three, including the following steps:

[0026] The system compares the timestamp of the time series data to be queried with the maxKey of the leaf node in the B+ index tree. If the timestamp is greater than the maxKey, the data is stored in a memory buffer. A binary search is then performed using the timestamp to find the storage location of the data. If the timestamp is less than or equal to the maxKey, a binary search is used to find a pointer to the next level node in the B+ index tree to locate the leaf node storing the data. If no leaf node is found, -1 is returned. If a leaf node is found, the data offset of the trained linear model is output.

[0027] The maxKey of the leaf node is the maximum key stored in the leaf node.

[0028] Furthermore, the deletion of time-series data in step four, based on the B+ index tree obtained in step three, is achieved in the following way:

[0029] First, delete all index structures in the B+ index tree before the preset timestamp; then, determine whether the preset timestamp is greater than all timestamps stored in the B+ index tree structure. If the preset timestamp is greater than all timestamps stored in the B+ index tree structure, delete the entire current B+ index tree; if the preset timestamp is not greater than all timestamps stored in the B+ index tree structure, proceed to the partial node deletion process.

[0030] Furthermore, the partial node deletion process is as follows:

[0031] The process involves invoking an index query to retrieve the leaf node containing the time-series data prior to the preset timestamp. If no leaf node is found, the deletion process ends. If a leaf node is found, all leaf nodes preceding the currently found leaf node are deleted from the doubly linked list, and the doubly linked list between the remaining leaf nodes and the parent node of the current remaining leaf node are updated. Then, a binary search is used to search for the timestamp prior to the preset timestamp in the updated parent node. If the internal node containing the timestamp prior to the preset timestamp is the root node, the current root node is deleted, reducing the height of the B+ index tree. If the internal node containing the timestamp prior to the preset timestamp is not the root node, all internal nodes containing the timestamp prior to the preset timestamp are deleted.

[0032] A learning indexing system based on time series data features, wherein the system is used to implement the learning indexing method based on time series data features.

[0033] The beneficial effects of this invention are as follows:

[0034] This invention designs a learning index based on time series features, which improves query performance and reduces the space occupied by index storage. This invention utilizes a B+ tree to manage multiple piecewise linear function models, storing data of the same format contiguously, which is suitable for the characteristics of B+ trees. Simultaneously, it extracts features from leaf nodes through internal nodes, reducing the space occupied by index storage, and centralizes permission management at the root node, reducing indexing time. Attached Figure Description

[0035] Figure 1 To learn the index model;

[0036] Figure 2 This describes part of the process involved in a single InfluxDB query. Detailed Implementation

[0037] Currently, FITing-Tree divides the key space into multiple segments, fits a corresponding linear function to each segment, and provides an adjustable error threshold to ensure that the true position of the query key does not exceed this threshold. Its main idea is to leverage the characteristics of data distribution and use model learning to reduce the index size. ALEX addresses the problem of using a sorted array for learning the index, which leads to excessively high model update costs when inserting new data. It proposes a fully dynamic data structure that simultaneously supports insertion, update, and deletion operations, similar to a B+ tree. However, all of these indexing methods are research on one-dimensional learned indexes in traditional relational databases, and there are currently no specific indexing methods for time-series database scenarios.

[0038] This invention is based on the time-series database InfluxDB. InfluxDB uses an LSM-like storage engine, which significantly improves write performance but somewhat reduces read performance. Therefore, it automatically builds indexes for data during insertion and directly uses these indexes during queries to improve performance. Figure 2 This is part of the process involved in a query in InfluxDB. The diagram illustrates the structure of its index file. The trailer mainly records the offset and size of the measurement block and tag block, serving as a routing mechanism. The measurement block quickly routes the measurement name specified by the upper layer to the tag block. The measurement block structure is a hashtable, ensuring O(1) complexity. The tag block mainly stores the mapping relationship between tag_key->tag_value->seriesIDs. The upper-layer module can pass in tag_key + tag_value and then quickly obtain the seriesIDs. After obtaining the corresponding seriesIDs, it is also necessary to obtain the corresponding seriesKey and shards. In the specific shard, a binary search and comparison of timestamps is still required. In general, the currently implemented index is like a very large map with layer-by-layer mapping. This may bring a large number of disk I / O operations during the layer-by-layer mapping process, which will lead to a decrease in index performance. Therefore, based on this, we propose an efficient learning index that meets the search requirements of time series databases, starting from the unique properties and workload of time series databases. The final effect is as follows. Figure 1 As shown in the figure. The invention will now be described in conjunction with specific embodiments.

[0039] Specific Implementation Method 1: The specific process of this implementation method based on the learning indexing method of time series data features is as follows:

[0040] Step 1: Obtain time series data and divide the time series data into multiple data segments according to timestamps, and build a linear model for each data segment;

[0041] The independent variable of the linear model is the timestamp data of the time series data, and the dependent variable is the data offset;

[0042] The data offset is the location of the data on the disk.

[0043] Since real-world time-series data is not a strictly linear function, fitting all data with a single linear model would result in significant errors. Therefore, we employ a piecewise linear function to implement our learning model, which is trained based on data from a single node. In this invention, we set the node size to 65535. Although the data we need to index may reside on heterogeneous storage media such as memory or disk, the operating system helps us mask the differences in storage media. When searching for data, we only need to know its block ID and offset. If the block is not in memory, the operating system will generate a page fault. Furthermore, because the leaf node data is organized using a linked list, i.e., continuous and ordered data, the data in the leaf nodes must also be continuous data within the same block. The final effect is to store a linear function model in the leaf nodes.

[0044] Step 2: Use the timestamp data and offset of the time series data to train the linear model obtained in Step 1, and obtain the trained linear model.

[0045] Step 3: Use the trained linear model obtained in Step 2 to build an index tree and a memory buffer:

[0046] The index tree includes: leaf nodes, root node, and internal nodes;

[0047] The leaf nodes are used to store the linear model trained in step two and the block ID;

[0048] The block ID is obtained as follows: First, obtain the data segment corresponding to the trained linear model, then obtain the block that stores the data segment on the disk, and the ID of the current block is the block ID;

[0049] The leaf nodes are connected by a doubly linked list to maintain the logical time order between the leaf nodes.

[0050] The root node and the internal nodes are used to store index keys and pointers to the next level nodes;

[0051] The index key is a timestamp;

[0052] The memory buffer is used to temporarily store newly inserted time-series data;

[0053] The capacity of each memory buffer is the same as the capacity of the leaf node.

[0054] In this step, the original time-series data is divided into multiple data segments, each corresponding to a model. The model is trained using timestamp data as the independent variable and offset as the dependent variable. On one hand, we obtain multiple models. To further improve the efficiency of data querying, this invention uses a tree to manage the models. The query logic is that the index key is the timestamp, and the root node and internal nodes only store the index key and pointers to the next-level nodes, ultimately querying the corresponding leaf node. This step stores the block ID (block id) of the current data on the disk and the linear model trained in step two in the leaf nodes, using the timestamp as the index key, and storing the index key and pointers to the next-level nodes in the root node and internal nodes; simultaneously, two memory buffers of the same size are reserved; leaf nodes are managed using a doubly linked list, which connects the logical time order of the nodes. This is called a logical linked list to facilitate deletion operations. Therefore, after the leaf nodes are managed using a doubly linked list, the data in a leaf node must be continuous data. This means that the data in the leaf nodes must also be continuous within the same block. Therefore, the block ID can be determined and saved during insertion, requiring only one copy for each leaf node, avoiding redundant saving of large amounts of data. We can then focus on calculating the offset. The leaf node will store the model corresponding to the data within that range, along with the block IDs for all data within that leaf node. Therefore, the query logic for this index starts from the root node, determines the position of the timestamp key in the next level of the tree structure, and continues until the leaf node. The model can then be used to predict and obtain the final offset result (data offset) and the block ID corresponding to that node; if no data point corresponds to that timestamp, -1 is returned.

[0055] Step 4: Based on the tree obtained in Step 3, perform time-series data insertion, deletion, and index query operations, specifically as follows:

[0056] Step 41: Write the new time-series data into the B+ index tree using the following method:

[0057] First, determine if the memory buffer is full. If it is not full, store the new time-series data in the first unfilled memory buffer. When the first unfilled memory buffer is full, construct a leaf node directly from the time-series data in the first memory buffer. Then, start the second unfilled memory buffer until the memory buffer is full. If the memory buffer is completely full, create a new leaf node and update the index tree with the new leaf node.

[0058] The new leaf node stores the maximum and minimum timestamp values, as well as the linear model corresponding to the new time-series data.

[0059] The specific steps for updating the index tree with the new leaf node are as follows:

[0060] First, determine if the root node of the index tree is empty. If it is empty, directly insert the new leaf node into the index tree as the root node. If the root node of the index tree is not empty, check if the parent node of the last leaf node of the index tree has an empty position. If there is an empty position, insert the new leaf node into the empty position and then update the ancestor node information of the new leaf node. If the parent node of the last leaf node of the index tree does not have an empty position, create a new internal node as the parent node of the new leaf node and insert the new internal node into the higher level of the B+ index tree.

[0061] In this step, two memory buffers are established. When the memory buffers are not full, under normal working conditions, the first memory buffer is used to handle data writing, while the second memory buffer is idle. When the first memory buffer is full, the second memory buffer is activated, and the data in the first memory buffer is directly used to construct a leaf node. Then, the first memory buffer becomes idle, and this process repeats. Therefore, we set the size of the memory buffer to be the same as the capacity of the leaf node to make full use of memory space. In this way, multiple data insertion operations can be combined into a single node addition operation, greatly reducing the pressure of resource contention. At the same time, it can also solve the problem of how to construct leaf nodes in an environment of continuous data writing, as shown in Table 1.

[0062] Table 1

[0063]

[0064] If the newly inserted data causes the buffer to fill up, a new leaf node is created. This new leaf node stores the maximum and minimum timestamp values, as well as the corresponding learning model. Next, we need to update our tree structure with this new node. First, we define the following variables: root is the root node of the tree, DEFAULT_TREE is the out-degree of the tree node, lastLeaf is the last leaf node, and head and tail are the head and tail sentinel nodes maintaining the global doubly linked list of leaf nodes. When inserting a node into the tree, we first need to check if the root node is empty. If it is, we directly use the new leaf node as the root node of the tree; otherwise, we need to check if there is still space for the parent node of lastLeaf. If there is space, we can insert it directly and update the information of all ancestor nodes in a loop. If the parent node of lastLeaf is full, we need to create a new internal node as the parent node of the new leaf node and insert the new parent node into a higher level of the tree, following the same processing logic as above. If, after all traversals are completed, no new leaf node has been inserted, it means that all nodes in the original tree are full and no further insertions are possible. Therefore, a new internal node needs to be created as the parent node of the two subtrees, increasing the tree height by one level. Doing this ensures that the capacity of each node in the tree is 100% utilized and that all leaf nodes can be indexed, satisfying the tree structure requirements mentioned above, as shown in Table 2.

[0065] Table 2

[0066]

[0067] Step 42: Perform index queries on time series data using the following methods:

[0068] The system compares the timestamp of the time series data to be queried with the maxKey of the leaf node in the index tree. If the timestamp of the time series data to be queried is greater than the maxKey of the leaf node, it means that the data to be queried is stored in the memory buffer. Then, a binary search is performed using the timestamp of the time series data to obtain the storage location of the time series data to be queried. If the timestamp of the time series data to be queried is less than or equal to the maxKey of the leaf node, a binary search is used to search for a pointer to the next level node in the B+ index tree, thereby obtaining the leaf node storing the time series data to be queried. If the leaf node storing the time series data to be queried is not found, -1 is returned. If the leaf node storing the time series data to be queried is found, the predicted value of the trained linear model is output.

[0069] In this step, we first determine the relationship between the timestamp of the queried data and the maxKey of lastLeaf in the tree structure (the largest key stored on the leaf node): if the timestamp of the queried data is greater than the maxKey of lastLeaf, it means that the data is stored in the memory buffer. The data in the memory buffer is organized in an ordered manner, and we can use binary search to determine the specific storage location of the data.

[0070] If the timestamp of the query is less than or equal to the `maxKey` of `lastLeaf` in the tree structure, it means we need to search within the tree structure. However, this does not guarantee that the data corresponding to the queried timestamp exists in the tree structure. In non-leaf nodes (internal nodes), the index keys (timestamps) are stored in order. We can use binary search to determine the pointer to the next level of the tree node; each level of search narrows the search range. There are two cases for the result of searching for a leaf node: one is that no leaf node is found, indicating that the search range has already been narrowed down by the non-leaf nodes, and we can simply return -1; the other is that a leaf node is found. When searching within a leaf node, the trained linear model prediction value (data offset) is returned as the final result.

[0071] The query node process is shown in Table 3.

[0072] Table 3

[0073]

[0074] Step 43: Delete the time series data using the following methods:

[0075] First, delete all index structures in the B+ index tree that are before the preset timestamp;

[0076] Then, it is determined whether the preset timestamp is greater than all timestamps stored in the B+ index tree structure. If the preset timestamp is greater than all timestamps stored in the B+ index tree structure, the entire current B+ index tree is deleted. If the preset timestamp is not greater than all timestamps stored in the B+ index tree structure, an index query operation is called to obtain the leaf node where the time-series data is located. If no leaf node is found, the deletion process ends. If a leaf node is found, all leaf nodes before the currently found leaf node are deleted in the doubly linked list, and the doubly linked list between the remaining leaf nodes and the parent node of the current remaining leaf node are updated. Then, a binary search is used to search for the timestamp before the preset timestamp in the updated parent node. If the internal node containing the timestamp before the preset timestamp is the root node, the current root node is deleted, reducing the height of the B+ index tree. If the internal node containing the timestamp before the preset timestamp is not the root node, all internal nodes containing the timestamp before the preset timestamp are deleted.

[0077] In this step, the time-series data flow primarily describes the tree structure pruning process. First, we believe that efficient indexing is only necessary for data with particularly high-frequency queries. While efficient indexing can lead to faster query speeds, it often means consuming more system resources. Therefore, it's unnecessary to retain efficient indexing capabilities for historically low-frequency query data. The purpose of this process is to prune the index structure corresponding to historical data, maintaining the entire tree structure at a reasonable height. Based on the characteristics of time-series database workloads, if data at a certain point in time has become "cold" data with a very low query frequency, then data from earlier points in time will have an even lower query frequency, making that data even "colder."

[0078] Given a timestamp, delete all indexes preceding that timestamp. The following is a detailed breakdown of the deletion process. First, it checks if the given timestamp is greater than all timestamps stored in the tree structure. If so, the tree can be deleted directly and the result returned. Otherwise, a query process is needed to find the corresponding leaf node. If no leaf node is found, no further action is needed; if a leaf node is found, a logical linked list is used. This is because in the logical linked list, all nodes preceding the leaf node to be deleted have timestamps earlier than that leaf node, so they all need to be deleted. We directly update our logical linked list and iterate through the parent node of the current node. In the parent node, we still use a binary search to locate the key with the timestamp to be deleted, similarly deleting all keys with earlier timestamps. If the parent node is the root node of the entire tree, and after deletion, the root node will only have one valid key value, then we need to delete the root node to reduce the tree's height. This is because the root node's index is now invalid, and reducing the tree's height ensures that the tree remains within a manageable range. If the parent node is not the root node at this point, then keys with earlier timestamps need to be deleted sequentially. See Table 4;

[0079] Table 4

[0080]

[0081] Specific implementation method two: a learning indexing system based on time series data features, used to implement a learning indexing method based on time series data features.

[0082] The learning index proposed in this invention is more suitable for time series databases, specifically in the following aspects:

[0083] In terms of data storage structure, the data structure of time series databases is essentially an LSM tree (Log-Structured Merge Tree). Tree, or LSM tree, is an efficient data structure commonly used for persistent storage in distributed database systems. Its main idea is to append all write operations to a single log file and use in-memory indexes to accelerate read operations. Specifically, LSM trees employ a merging strategy to combine multiple different log files, reducing the cost of random reads. As the log file grows larger, the LSM tree automatically triggers a background merging process called a compaction operation. This merges smaller log files into larger ones, reducing disk space usage and improving data read efficiency. Therefore, the location of the data on disk often remains unchanged, only changing during compaction. Newly inserted data does not affect the location of existing data without compaction, which is highly beneficial for models, effectively reducing model retraining. Traditional databases use B+ tree storage structures, where each data insertion can lead to the splitting of leaf nodes. This means each insertion causes a change in data location, resulting in more frequent retraining of the learning index model. Therefore, model retraining in the context of time-series databases is more lightweight and less frequent.

[0084] In terms of data distribution, time-series databases organize data according to time and divide it into different shards for management. This ensures that the data in a single shard is not too large. This invention uses a relatively smaller and more accurate model to achieve learning indexing. In contrast, traditional databases manage data together in a unified manner. Although data can be manually partitioned according to different attributes, this is not flexible or standardized and is not as well supported as time-series databases.

[0085] In terms of data characteristics, the main feature of time-series data is that it does not modify historical data, thus avoiding the need to retrain the corresponding learning index model. This is precisely a problem that traditional database learning indexes cannot avoid. Furthermore, appending data reduces the pressure of model retraining.

[0086] In terms of data management, data on each timeline is managed by Series (a Series is a set of data points with the same Measurement and Tag Set. It represents a specific type of data and is uniquely identified by a Measurement and a set of Tag Key-Tag Value pairs). Each Series has a unique Series Key, and data in different Series are not related. In terms of storage, data from different Series are stored in different blocks on the disk, with each block storing only one Series. Therefore, a learning index can be built for the data corresponding to each Series. This ensures that changes in data from other Series will not affect the current Series, and thus the learning index. Furthermore, data within the same Series will better conform to the patterns of the recorded events, making the model easier to fit. Traditional databases do not have detailed partitioning, so changes in one Series often have far-reaching consequences, which is very unfavorable for learning indexes. This invention focuses on index storage overhead, maintenance costs, and query performance. Based on the characteristics of time-series loads, it studies a novel index structure on time-series databases to meet high-performance queries while reducing index overhead, thereby improving the load execution efficiency on large-scale time-series data.

[0087] A Series Key is a unique identifier composed of a Measurement, a Tag Key, and a Tag Value, used to identify different instances of Measurements. Specifically, a Series Key consists of the following parts: Measurement: Indicates the data type, such as CPU or Memory. Tag Key: Indicates a specific attribute of the Measurement, such as the CPU model or the server name of the Memory. Tag Value: Indicates the specific value corresponding to the Tag Key, such as the CPU model being Intel Xeon or the server name of the Memory being Server01. For example, if we want to record the CPU usage of a server, we can set the Measurement to "cpu_usage", the Tag Key to "server_name", and the Tag Value to "Server01". This way, each record will generate a data point with the same Series Key, thus forming a time-series data set. In short, the Series Key plays a very important role in InfluxDB, helping users quickly and accurately find data and perform aggregation, filtering, and other operations.

Claims

1. A learning-based indexing method based on time series data features, characterized in that... The specific process of the method is as follows: Step 1: Obtain time series data and divide the time series data into multiple data segments according to timestamps, and build a linear model for each data segment; Step 2: Use the timestamp data and data offset of the time series data to train the linear model obtained in Step 1, and obtain the trained linear model. Step 3: Use the trained linear model obtained in Step 2 to build a B+ index tree and a memory buffer; The B+ index tree in step three includes: leaf nodes, root nodes, and internal nodes; The leaf nodes are used to store the linear model trained in step two and the block ID; The block ID is obtained as follows: First, obtain the data segment corresponding to the trained linear model, then obtain the block that stores the data segment on the disk, and the ID of the current block is the block ID; The logical time sequence between leaf nodes is connected by a doubly linked list. The root node and the internal nodes are used to store index keys and pointers to the next level nodes; The index key is a timestamp; The number of memory buffers may be one or more; The memory buffer is used to store newly inserted timing data; The capacity of each memory buffer is the same as the capacity of each leaf node; Step 4: Based on the B+ index tree and memory buffer obtained in Step 3, perform time-series data insertion, time-series data deletion, and index query operations.

2. The learning-based indexing method based on time series data features according to claim 1, characterized in that: In the linear model of step one, the independent variable is the timestamp data of the time series data, and the dependent variable is the data offset.

3. The learning-based indexing method based on time series data features according to claim 2, characterized in that: Step four, based on the B+ index tree and memory buffer obtained in step three, involves inserting time-series data, including the following steps: Determine if the memory buffer is full. If not, store the new time-series data in the first, not-full memory buffer. Once the first, not-full memory buffer is full, construct a leaf node directly from the time-series data in the first memory buffer. Then, start the second, not-full memory buffer, until all memory buffers are full. If all memory buffers are full, create a new leaf node and update the B+ index tree with the new leaf node. The new leaf node stores the following: the maximum value of the timestamp, the minimum value of the timestamp, and the linear model and offset corresponding to the new time series data.

4. The learning-based indexing method based on time series data features according to claim 3, characterized in that: The specific steps for updating the B+ index tree with the new leaf node are as follows: Determine if the root node of the B+ index tree is empty. If it is empty, insert the new leaf node directly into the B+ index tree as the root node. If the root node of the B+ index tree is not empty, check if there is an empty position in the parent node of the leaf node of the B+ index tree. If there is an empty position, insert the new leaf node into the empty position and then update the ancestor node information of the new leaf node. If there is no empty position in the parent node of the leaf node of the B+ index tree, create a new internal node as the parent node of the new leaf node and insert the new internal node into the higher level of the B+ index tree.

5. The learning-based indexing method based on time series data features according to claim 1, characterized in that: Step four involves performing an index query operation based on the B+ index tree and memory buffer obtained in step three, including the following steps: The system compares the timestamp of the time series data to be queried with the maxKey of the leaf node in the B+ index tree. If the timestamp is greater than the maxKey, the data is stored in a memory buffer. A binary search is then performed using the timestamp to find the storage location of the data. If the timestamp is less than or equal to the maxKey, a binary search is used to find a pointer to the next level node in the B+ index tree to locate the leaf node storing the data. If no leaf node is found, -1 is returned. If a leaf node is found, the data offset of the trained linear model is output. The maxKey of the leaf node is the maximum key stored in the leaf node.

6. The learning-based indexing method based on time series data features according to claim 1, characterized in that: Step four, which involves deleting time-series data based on the B+ index tree obtained in step three, is implemented in the following way: First, delete all index structures in the B+ index tree before the preset timestamp; then, determine whether the preset timestamp is greater than all timestamps stored in the B+ index tree structure. If the preset timestamp is greater than all timestamps stored in the B+ index tree structure, then delete the entire current B+ index tree. If the preset timestamp is not greater than all the timestamps stored in the B+ index tree structure, then proceed with the partial node deletion process.

7. The learning-based indexing method based on time series data features according to claim 6, characterized in that: The process for deleting certain nodes is as follows: The process involves invoking an index query to retrieve the leaf nodes containing time-series data prior to a preset timestamp. If no leaf node is found, the deletion process ends. If a leaf node is found, all leaf nodes preceding the currently found leaf node are deleted from the doubly linked list, and the doubly linked list between the remaining leaf nodes and the parent node of the current remaining leaf node are updated. Then, a binary search is used to search for the timestamp prior to the preset timestamp in the updated parent node. If the internal node containing the timestamp prior to the preset timestamp is the root node, the current root node is deleted, reducing the height of the B+ index tree. If the internal node containing the timestamp prior to the preset timestamp is not the root node, all internal nodes containing the timestamp prior to the preset timestamp are deleted.

8. A learning-based indexing system based on time series data features, characterized in that: The system is used to implement the learning indexing method based on time series data features as described in any one of claims 1-7.