A time series data management method and system based on openGauss
By adopting a time-series data management method based on openGauss, the problem of incomplete functions in the time-series data management system is solved. It realizes the cleaning, quality assessment and similarity query of time-series data, which is applicable to a variety of application scenarios and improves data processing efficiency and system stability.
Patent Information
- Application Number
- CN202311414874.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-30
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-10-30
AI Technical Summary
Existing time series data management systems lack functions such as time series data similarity query, cleaning and quality assessment, and dimensionality reduction, and cannot effectively support data analysis and predictive modeling.
We adopt a time-series data management method based on OpenGauss, including time-series data cleaning, quality assessment, dimensionality reduction, and similarity query. We use techniques such as LSTM to fill missing values, Z-Order dimensionality reduction, and kd-tree index structure to achieve efficient processing and analysis of time-series data.
It expands openGauss's data management capabilities, enabling time-series data similarity query, cleaning, and quality assessment functions. It adapts to the domestic business environment, supports efficient processing of large-scale time-series data, and maintains system stability and reliability.
Smart Images

Figure CN117762910B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of data management and analysis, and relates to a time-series data management method and system based on openGauss. Background Technology
[0002] Databases, as foundational system software, primarily function to efficiently manage large-scale data. In technological fields such as power, transportation, and industrial manufacturing, there exists a large amount of time-series data of significant importance. The processing and storage of this time-series data requires high-performance, highly reliable industrial-grade time-series data management systems. Regarding time-series data management systems:
[0003] Existing typical systems abroad include TimescaleDB, InfluxDB, and OpenTSDB. TimescaleDB is developed based on PostgreSQL and uses a schema data management framework. InfluxDB is based on key-value data and primarily targets range, window, and numerical statistical queries. OpenTSDB is developed based on HBase and is designed for multi-dimensional queries.
[0004] In China, both Tencent and Alibaba have designed and developed related time-series database systems. Tencent's CTSD time-series database has good data cleaning and repair capabilities, while Alibaba Cloud's HiTSDB time-series database has multiple data models and learning indexes.
[0005] However, both domestic and international time-series data management systems primarily focus on time-series data cleaning and query processing, lacking comprehensive functionality. This is specifically reflected in the following aspects:
[0006] In terms of time series data query, existing time series data management systems lack functions such as time series data similarity query, which have a targeted analysis function for time series data.
[0007] The time series data query function is used to compare and find time series data similar to a given query sequence in order to discover trends, patterns or anomalous behaviors, thereby supporting applications such as data analysis and predictive modeling.
[0008] In terms of time series data processing, existing time series data management systems lack processing functions such as time series data cleaning and quality assessment, and time series data dimensionality reduction.
[0009] The role of time series data cleaning and quality assessment is to eliminate noise, outliers, and missing values in time series data through preprocessing and filtering, and to evaluate the accuracy, completeness, and consistency of the data, so as to ensure that the data quality meets the needs of analysis and application.
[0010] The purpose of time series data dimensionality reduction is to transform high-dimensional time series data into a low-dimensional representation through techniques such as aggregation, compression, or sampling, thereby reducing storage and computing costs and improving the efficiency of data processing and analysis.
[0011] It is evident that time series data query, time series data cleaning and quality assessment, and time series data dimensionality reduction are of great significance in time series data management and analysis, but existing time series data management systems do not possess these functions. Summary of the Invention
[0012] To address the shortcomings of existing time-series database management systems, this invention proposes a time-series data management method based on openGauss. This method includes efficient query processing and analysis such as time-series cleaning and quality assessment, time-series data dimensionality reduction and column splitting, and time-series data similarity query, which is beneficial for expanding the data management capabilities of openGauss.
[0013] To achieve the above objectives, the present invention adopts the following technical solution:
[0014] A time-series data management method based on openGauss includes the following steps:
[0015] Time series data cleaning steps;
[0016] By preprocessing and cleaning duplicate and erroneous data, filling missing values with LSTM-based time series prediction methods, and using normal distribution statistics to classify the confidence level of drift data, a confidence level indicator for drift data is obtained.
[0017] Steps for time series data quality assessment;
[0018] By statistically analyzing and calculating the number and frequency of data anomalies in both row and column formats, and outputting the results in a table, the changes in the anomaly situation over time and the number and frequency of different anomaly types in each column of data are expressed.
[0019] Steps for dimensionality reduction of time series data;
[0020] To address the issue of different dimensional values in time series data, the Z-Order dimensionality reduction method is used, selecting appropriate precision and data type for dimensionality reduction based on the specific characteristics of the time series data.
[0021] Steps for splitting time-series data;
[0022] Extract each non-time column attribute separately and combine it with the time column to form a new table;
[0023] And the steps for querying time-series data similarity;
[0024] By segmenting time-series data, representing trends, and establishing a kd-tree index structure, fast similarity query and pruning can be achieved.
[0025] Furthermore, this invention also proposes an openGauss-based time-series data management system corresponding to the aforementioned openGauss-based time-series data management method. This system adopts the following technical solution:
[0026] A time-series data management system based on openGauss includes:
[0027] Time-series data cleaning module;
[0028] By preprocessing and cleaning duplicate and erroneous data, filling missing values with LSTM-based time series prediction methods, and using normal distribution statistics to classify the confidence level of drift data, a confidence level indicator for drift data is obtained.
[0029] Time series data quality assessment module;
[0030] By statistically analyzing and calculating the number and frequency of data anomalies in both row and column formats, and outputting the results in a table, the changes in the anomaly situation over time and the number and frequency of different anomaly types in each column of data are expressed.
[0031] Time-series data dimensionality reduction module;
[0032] To address the issue of different dimensional values in time series data, the Z-Order dimensionality reduction method is used, selecting appropriate precision and data type for dimensionality reduction based on the specific characteristics of the time series data.
[0033] Time series data splitting module;
[0034] Extract each non-time column attribute separately and combine it with the time column to form a new table;
[0035] And a time-series data similarity query module;
[0036] By segmenting time-series data, representing trends, and establishing a kd-tree index structure, fast similarity query and pruning can be achieved.
[0037] The present invention has the following advantages:
[0038] As described above, this invention relates to a time-series data management method and system based on openGauss. Based on a domestically developed open-source database system, this invention is better adapted to the domestic business environment and has a wide range of application scenarios for time-series data, not limited to IoT or industrial applications. This invention possesses functions not found in existing time-series data management systems, such as time-series data similarity query, time-series data dimensionality reduction, and time-series data quality assessment, to help users perform data mining and trend analysis, better understand data, make decisions, and discover potential data significance. Furthermore, this invention ensures that the system can efficiently process large-scale time-series data and maintain stability and reliability under high loads, enabling users to handle more and more complex data. Attached Figure Description
[0039] Figure 1 This is a flowchart of the time-series data management method based on openGauss in Embodiment 1 of the present invention.
[0040] Figure 2 This is a schematic diagram illustrating the process in Embodiment 1 of the present invention where the values of subsequences are converted into binary according to the trend, and then converted into int type values.
[0041] Figure 3 This is a schematic diagram illustrating the method for calculating the trend range of a short sequence in Embodiment 1 of the present invention.
[0042] Figure 4 This is a structural block diagram of the openGauss-based time-series data management system in Embodiment 2 of the present invention. Detailed Implementation
[0043] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments:
[0044] Example 1
[0045] This embodiment 1 describes a time-series data management method based on openGauss to solve the problem of incomplete functionality in existing time-series database management systems.
[0046] The time-series data management method in this embodiment is mainly used to manage time-series data, including time-series data cleaning, time-series data quality assessment, time-series data dimensionality reduction and splitting, and time-series data similarity query.
[0047] like Figure 1 As shown, the time-series data management method based on openGauss in this embodiment includes the following steps:
[0048] I. Time-series data cleaning steps.
[0049] By preprocessing and cleaning duplicate and erroneous data, filling missing values with an LSTM-based time series prediction method, and using normal distribution statistics to classify the confidence level of drift data, a confidence level indicator for drift data is obtained.
[0050] Given a low-quality dataset D containing a large number of instance tuples of a relational schema R, and given the time series data collection frequency γ and the set of conditional functional dependencies Σ, cleaning the dataset D includes the following three tasks:
[0051] 1. Based on the timestamp in D and the time series data acquisition frequency γ, calculate whether the number of data exceeds the set number, expressed as M(D,t)>N(γ). If it exists, find completely identical duplicate data and mark the duplicate data.
[0052] 2. Check the satisfaction of D with respect to set Σ, and repair tuple records that violate Σ using a certain pattern & to make them satisfy Σ;
[0053] 3. Fill in missing values for attributes in tuples, and make the confidence of the filled values for attribute A greater than a given threshold σ(A).
[0054] To achieve the above functions, this invention employs preprocessing and an LSTM-based algorithm.
[0055] Step I.1. Processing duplicate values in time series data.
[0056] First, the number of data points N(γ) to be collected per unit time is determined based on the data collection frequency γ. Then, the number of data points M(D,t) per unit time is calculated based on the amount of data at each timestamp in the dataset.
[0057] If M(D,t)>N(γ), then search for completely identical duplicate data, and delete the duplicate data if they exist.
[0058] Step 1.2. Clean up erroneous data using prior knowledge.
[0059] The dataset is checked based on prior knowledge provided by the user or saved along with the data. Prior knowledge includes the set of conditional functional dependencies Σ. Functional dependency is a type of data dependency that reflects the interdependent and mutually restrictive relationship between attributes or groups of attributes, that is, it reflects the constraints in the real world. For example, in free fall, the change in velocity must be equal to the integral of acceleration over that time period. If they are not equal, there is erroneous data.
[0060] Prior knowledge can also be a single-dimensional upper or lower limit threshold or rate of change.
[0061] When reading data, the conditional functional dependency set Σ is used to determine whether there are any anomalies; if there are anomalies, the data is substituted into the conditional functional dependency set Σ, and the erroneous data is modified to make the data conform to the conditional functional dependency set Σ.
[0062] Step I.3. Use LSTM to fill in missing values.
[0063] 70% of the data that was not marked as anomalies after processing in steps I.1 and I.2 is used as the training set and 30% as the test set. If the amount of data exceeds 10,000, only 10,000 are selected for LSTM model training. After the model is trained, the LSTM model is used to predict the values of missing values and fill them in.
[0064] Step I.4. Use LSTM and normal distribution methods to label the confidence level of the data.
[0065] The residual dataset R is obtained by subtracting the predicted values from the actual values of the LSTM model. The mean μ and standard deviation σ of R are calculated, and its distribution is fitted to a normal distribution. The confidence level is graded according to the magnitude of the residual r of each data item.
[0066] The formula for grading credibility is as follows:
[0067]
[0068] Credibility information is stored in three new tables, which store the location information of data with credibility levels of 32%, 5%, and 0.3%, respectively.
[0069] Source data is a very important resource, and we must adhere to the principle of minimizing modifications. Moreover, anomalies are simply different from the norm and do not necessarily equate to errors. Therefore, drift anomaly detection only provides a hint for other applications to use as a reference when selecting data.
[0070] When selecting data for other applications, it can be categorized into two trends: "higher requirements for data credibility" and "higher requirements for data volume," and then the trust level of the drifting data to be removed during cleaning can be selected based on the category.
[0071] This invention cleans the data through preprocessing, LSTM-based time series prediction, and normal distribution statistics. In the preprocessing, the conditional functional dependency set Σ and the data acquisition frequency are used to clean up erroneous values, duplicate values, and format errors. The LSTM-based time series prediction method is used to fill in missing values. On this basis, the normal distribution statistics method is added to classify the credibility of drift data, thus obtaining a credibility indicator for drift data.
[0072] II. Steps for assessing the quality of time-series data.
[0073] By statistically analyzing and calculating the number and frequency of data anomalies in both row and column formats, and outputting the results in a table, the changes in anomalies over time and the number and frequency of different anomaly types in each column are presented.
[0074] Given a low-quality dataset D containing a large number of instance tuples of a relational schema R, and given the time series data collection frequency γ and the set of conditional functional dependencies Σ, quality assessment on data D includes the following two tasks:
[0075] 1. It displays how the number and frequency of anomalies change over time. By showing that the frequency of anomalies is higher than that of others during a certain period, it can be analyzed that an anomaly occurred during that period, or that there was a data transmission error.
[0076] 2. Provide an overall evaluation of the data, describing the quantity and frequency of different types of anomalies across different dimensions.
[0077] The types of anomalies include duplicate values, malformed formats, missing values, 32% confidence values, 5% confidence values, and 0.3% confidence values.
[0078] The identification methods for each anomaly are as follows:
[0079] Repeat value: The number of data points N(γ) to be collected per unit time is determined based on the data collection frequency γ. Then, the number of data points M(D,t) per unit time is calculated based on the amount of data at each timestamp in the dataset.
[0080] If M(D,t)>N(γ), then look for completely identical duplicate data; if such duplicates exist, then there is an anomaly in the duplicate value.
[0081] Format error: The data obtained when reading or storing data does not conform to the format of the data for this dimension.
[0082] Missing values: When reading or storing data, the positions in the table where data should be are empty.
[0083] 32% confidence level, 5% confidence level, and 0.3% confidence level:
[0084] Train an LSTM model with the correct data, calculate the difference between the model's predicted values and the true values to obtain the residual dataset R, and calculate the mean μ and standard deviation σ of R. Fit the distribution of R to a normal distribution.
[0085] The confidence level is graded according to the magnitude of the residual r of the individual data, as shown in the formula in step I.4.
[0086]
[0087] Among them, the 32% confidence value, 5% confidence value, and 0.3% confidence value are all considered drift anomalies. To achieve the above functions, this invention uses time (row) anomaly analysis tables and dimension (column) anomaly analysis tables to evaluate data quality.
[0088] II.1. Divide the data of the query column into time segments, and count the number of anomalies in each time segment, including duplicate values, format errors, missing values, 32% confidence values, 5% confidence values, and 0.3% confidence values. Divide the number of time anomalies in each time segment by the total number of data in that time segment to calculate the anomaly frequency for each time segment.
[0089] It should be noted that the number of segments in the data of the queried column can be customized by the user, with a default of 10 segments.
[0090] II.2. Use Table 1 to display the time and corresponding anomaly frequency of the data in step II.1.
[0091] Table 1 is a two-row multi-list. Each column in the first row outputs the time spans, and the second row outputs the frequency of anomalies in each time period, showing the changes in the abnormal conditions of the data of the query sequence over time, thus completing the time (row) anomaly analysis table.
[0092] II.3. Count the number of outlier types in each column, including missing values, 32% confidence values, 5% confidence values, and 0.3% confidence values. Divide the number of different types of outliers by the total number of data in that dimension to calculate the outlier frequency for each dimension.
[0093] This feature supports quality assessment of partial data. Users can select partial data according to their needs, while the default is all data.
[0094] II.4. Use Table 2 to display the types of anomalies, their corresponding number, and their frequencies from step II.3.
[0095] Table 2 is a three-row multi-column table, with each column representing a dimension of the source data.
[0096] The first row of each column outputs the dimension of the source data that the column represents, the second row outputs the number of anomalies in the source data for that column, and the third column outputs the anomaly frequency for that dimension, so as to show the occurrence of different anomalies in each dimension and complete the dimension anomaly analysis table.
[0097] Outputting the tables from II.2 and II.4 to the screen will display the quality assessment results of this function.
[0098] Table II.2 shows the frequency of anomalies in each segment after the query column is segmented. By analyzing Table II.2, it is possible to determine whether the data in this column is more reliable or more suspicious at certain times. Table II.4 shows the frequency of anomalies in the entire column of data. Users can use this frequency to determine whether the data set is worth continuing to use.
[0099] By statistically analyzing and calculating the number and frequency of data anomalies in both row and column formats and outputting the results in a table, the changes in anomalies over time and the number and frequency of different anomaly types in each column are clearly expressed.
[0100] III. Steps for dimensionality reduction of time-series data.
[0101] The Z-Order dimensionality reduction method is applied to time series data. Furthermore, when time series data may contain different dimensional values (e.g., precision, numerical range), the appropriate precision and data type can be selected for dimensionality reduction based on the specific characteristics of the time series data.
[0102] The time-series data dimensionality reduction function in the openGauss system is primarily based on the Z-Order curve algorithm. The dimensionality reduction function is defined as follows:
[0103] Let T be the time series data table that the user needs to reduce in dimensionality, and let d1, d2, ..., dn be the column names (dimension names).
[0104] Where n is the total number of dimensions of the table data. Given a correct array Array[d1,d2,…,dk] containing k dimensions, where k≤n, output the Z-Order codes of each tuple in table T.
[0105] The basic idea of Z-Order is to take a multi-dimensional array Array[d1,d2,…,dk] as input, where each element represents the column name of the table to be reduced in dimensionality. The algorithm will combine the binary representations of the elements in each column into a 32-bit integer, and finally return this one-dimensional integer encoding. The process is described in detail below:
[0106] Step III.1. First, the user inputs an array of any type, Array[d1,d2,…,dk], containing dimension names. The function zorder accepts the array and stores the address information in the pointer input_array, while also retrieving the array information.
[0107] The array information includes the number of dimensions n and the element type for each dimension. It then verifies the retrieved information, such as ensuring that the element type for each dimension is either INT or FLOAT, and that the number of dimensions n is at least 1 and no greater than 32.
[0108] Step III.2. Define a pointer array input_values. First, allocate memory space for input_values using the palloc function. The size of input_values is array_dims[0] multiplied by sizeof(int32*).
[0109] Where array_dims[0] represents the array dimension size, and sizeof(int32*) represents the number of bytes occupied by the pointer type int32*.
[0110] Then, by iterating through each element of the array in turn, the address of each element is assigned to input_values[i].
[0111] Wherein, input_values[i] represents the address of the i-th element.
[0112] The specific calculation method is to obtain the starting address of the array data through ARR_DATA_PTR(input_array), and then add i multiplied by array_dims[1] (the number of elements in the specific dimension) to get the address of the i-th element.
[0113] Following the above method, a two-dimensional int32 array input_values is obtained, where each element is the address of an element in a certain dimension of the input array.
[0114] The element values for each dimension are obtained by accessing the input_values array, which is then used for subsequent calculations and processing.
[0115] Step III.3. For the saved floating-point array input_array, obtain its element type through the statement Oid elem_type = ARR_ELEMTYPE(input_array), where Oid is an unsigned integer that identifies the data type, and ARR_ELEMTYPE is a macro used to obtain the element type of the array.
[0116] The outer loop i processes the number of bits (32 bits) in each uint32_t encoding, the middle loop j iterates through the number of columns (dimensions) of the array, and the inner loop k accesses the elements in the number of rows of the array, i.e., the j-th dimension.
[0117] In the inner loop, first define a variable val of type float4, and then convert the element of the k-th row in the j-th dimension to a floating-point number of type float4 using *((float4*)(&input_values[k][j])).
[0118] input_values[k][j] represents the address of the element at the k-th row and j-th column in the input array, that is, the address of the element at the k-th row in the j-th dimension; *((float4*)(&input_values[k][j])) represents converting the integer value in the input_values array to the float4 type.
[0119] The pow function in the math library of C++ is used to implement multiplying a floating-point number by 10 to the power of precision and converting it to an integer type.
[0120] Here, precision is a precision parameter used to control the precision when converting a floating-point number to an integer.
[0121] Step III.4. Invoke the float_to_uint32 function to convert a single-precision floating-point number, i.e., the float4 type, to a 32-bit unsigned integer, i.e., the uint32_t type, and store it in the new variable int_val.
[0122] First, define a union containing two members: one is a 32-bit unsigned integer uint32_t i, and the other is a single-precision floating-point number float4 f; the union allows these two members to share the same memory space.
[0123] Declare a local variable u in the function, which is an instance of this union, and assign the input floating-point number val to the floating-point member u.f of the union, so that the binary representation of the floating-point number is stored in the union.
[0124] Finally, by returning the integer member u.i of the union, the floating-point number is converted to a 32-bit unsigned integer.
[0125] Through the characteristics of the union, the present invention directly converts the binary representation of the floating-point number into an integer representation, realizing the operation of converting a single-precision floating-point number to a 32-bit unsigned integer.
[0126] Step III.5. Perform a bitwise AND operation int_val & (1 << i) between the unsigned integer int_val obtained in Step III.4 and (1 << i), which means retaining the bit value of the i-th bit in int_val and setting all other bits to 0. The result is shifted left by ((j * 32) + k) bits, and the obtained binary number is subjected to a bitwise OR operation | = with output_value32, and the result is stored back in output_value32.
[0127] Here, (1 << i) means shifting the binary number 1 left by i bits.
[0128] Assuming the binary representation of int_val is 00000000000000000000000000000101, the value of i is 0, the value of j is 1, the value of k is 2, and the cumulative binary value of output_value32 is 11111111111111111111111111111111, then the result of (1<<i) is 00000000000000000000000000000001, the result of int_val&(1<<i) is 00000000000000000000000000000001, the result of (int_val&(1<<i))<<((j*32)+k) is 00000000000000000000000000000100, and the result of (int_val&(1<<i))<<((j*32)+k) is 11111111111111111111111111110111. Afterwards, according to the changes of j and k in the next loop, similar operations are continued, and finally the encoding result of the entire dimension array is stored in output_value32.
[0129] Step III.6. Finally, the function zorder returns the generated Z-order code output_value32. Users can use this one-dimensional code for subsequent operations, such as building indexes to speed up queries.
[0130] The present invention implements and optimizes the Z-order dimensionality reduction function in the openGauss kernel. This function accepts an array of dimension names and returns a 32-bit integer representing the Z-order curve value. It is a dimensionality reduction function with certain versatility and extensibility, and has a good effect on indexing and querying multi-dimensional data in the database.
[0131] IV. Time-series data splitting steps.
[0132] Time-series data splitting refers to extracting each non-time column attribute separately and forming a new table with the time column respectively. Its purpose is to facilitate separate analysis of the change of an attribute over time. Splitting is implemented by calling the SPI of the openGauss kernel.
[0133] Step IV.1. First, obtain the structure information of the original table, including the attribute attrs and the number of attributes attr_count, to ensure that both time attributes and non-time attributes exist in the table. If not, an error message is thrown; if yes, record the column number ts_index of the time column, the column name ts_colname of the time column, and the column name colname of the non-time column respectively.
[0134] Step IV.2. Use the formatted output string snprintf function to construct an SQL query statement for i in a loop from 0 to attr_count. When using SPI, first use the SPI_connect interface to start an SPI manager to connect to the openGauss server.
[0135] Next, the SPI_exec interface executes the constructed SQL query to complete the extraction of time and non-time columns. After use, the SPI_finish interface is used to close the SPI manager.
[0136] Create a new table named attr_count-1, using the naming convention of the original table name tablename_non-time column attribute name colname.
[0137] Step IV.3. The names of the generated tables are stored in a linked list, and the newly generated table names are output as an array in the terminal, thus obtaining the partitioned tables.
[0138] Time-series data splitting is an operation that extracts non-time-related attributes and time-related attributes into separate tables, allowing for more focused analysis of the trends, patterns, and anomalies of a specific attribute over time. The process involves obtaining table structure information, constructing SQL queries, executing the extraction operation, and storing the generated table names in a linked list.
[0139] V. Steps for querying similarity in time-series data.
[0140] By segmenting time-series data, representing trends, and establishing a kd-tree index structure, fast similarity query and pruning are achieved. The results retain the trend information of the data, and the calculation process is highly efficient.
[0141] The similarity query method described in this invention achieves the goal of quickly locating subsequences with similar trends by segmenting the target sequence, representing its trend, and establishing a trend index. When a user uses a query sequence to perform a similarity search on subsequences within the target sequence, this invention expands the index of the target sequence using different search methods based on the length of the query sequence, thereby obtaining subsequences with trends similar to the query sequence and placing them into a candidate set. Finally, this invention selects the subsequence in the candidate set that has the closest numerical distance to the query sequence as the output result. The similarity query process is described in detail below.
[0142] The definition of a time series data similarity query function is as follows: A k-dimensional time series sequence is represented as:
[0143] TS=<(t1,x[1]),t2,x[2]),...(t n ,x[n])>.
[0144] Where x[1] = (x[1, 0], x[1, 1], ..., x[1, k-1]), and n is the length of the time series TS.
[0145] The purpose of this functional module added in this invention is:
[0146] Given a query sequence W, find a subsequence TS of TS. i [j: j+len(Q)-1], where 0<=j<=lem(TS) i )-len(Q) is used to make the subsequence similar to the undulation shape of Q and the distance between them minimized.
[0147] To achieve the above functional objectives, the specific technical steps of this invention are as follows:
[0148] Step V.1. Data partitioning;
[0149] A sliding window of size W×k is set, with a step size of 1, to divide the time series TS into (len(TS)-W) subsequences TS1, TS2, ..., TS len(TS)-W Where len(TS) represents the length of the time sequence TS; W represents the length of the subsequence TSi; and k represents the number of columns in the subsequence TSi.
[0150] The purpose of sequence partitioning is to enable more precise searching and prevent the optimal solution from spanning two sequences.
[0151] Step V.2. Segmented trend representation, such as Figure 2 As shown.
[0152] For the k-dimensional subsequence TS after partitioning in step V.1 i Divide it into w micro-sequences TS of equal length. i1 TS i2 ,...TS iw TS ij The length of (1≤j≤w) is W / w, and the overall trend of each dimension of each micro-sequence segment is symbolically represented.
[0153] Let the microsequence TS ij If a certain attribute column has a start point of startpoint and an end point of endpoint, then its slope is... If l > 0 in the microsequence, it is represented by 1; if l <= 0 in the microsequence, it is represented by 0.
[0154] Among them, startpoint(TS) ij ) indicates TS i The starting point, endpointt(TS) ij) indicates TS i The endpoint.
[0155] At this point, each attribute column of the subsequence forms a binary sequence of length w representing its data trend; by converting it vertically to decimal numbers, each subsequence can generate a one-dimensional trend vector containing trend information, with a length of k.
[0156] Step V.3. Index tree construction.
[0157] The one-dimensional trend vectors of all subsequences generated in step V.2 are used to construct a kd-tree index for finding sequences with the same data trend. The trend kd-tree is constructed based on the characteristics of the kd-tree, and the specific process is as follows:
[0158] For each trend vector generated in step V.2:
[0159] Step V.3.1. If the tree is empty, then use this trend vector as the root node.
[0160] Step V.3.2. If the tree is not empty, start comparing from the root node in turn. If the value of each dimension of a certain node in the tree is equal, then connect this trend vector to the linked list of this node; otherwise, compare according to the specified comparison dimension of each level.
[0161] If the value is less than the specified dimension of the current node, the process continues in the left subtree until the k-th level is found; if the value is greater than the specified dimension of the current node, the process continues in the right subtree until the k-th level is found.
[0162] Step V.3.3. If no node with the same dimensions is found at level k, then connect it to the left or right linked list of the leaf node according to the size of the last dimension.
[0163] This invention segments the target query time series using a sliding window, transforms it into a trend array, and creates all trend arrays into a kd-tree index structure for use in the following search steps.
[0164] This invention utilizes a constructed kd-tree index to search for similar subsequences of time-series data.
[0165] In order to make this index tree applicable to query sequences of all lengths without repeatedly building the index tree, this invention divides the query sequence Q into two types: long sequences and short sequences. By using different search methods on the kd-tree, the same search goal is achieved.
[0166] Step V.4. Determine the length of the query sequence.
[0167] For query sequences with a length less than W, they are defined as short sequences; for query sequences with a length greater than W, they are defined as long sequences. Query sequences of different lengths are defined, and index searches are performed on them separately.
[0168] The purpose of defining query sequences of different lengths is:
[0169] The query sequence can be divided into several segments with the same length as the subsequence in step V.1, so that each segment can be searched using a kd-tree, and the kd-tree will not become unusable due to changes in the length of the query sequence.
[0170] 1) Short query sequence index lookup.
[0171] For query sequences of length less than W, a special kd-tree range search method is used to search for sequences with the same trend, i.e.:
[0172] a) First, determine the range of symbols represented by each dimension (column) of the query sequence; such as Figure 2 As shown, the trend of the query sequence cannot be represented by w 0 / 1 characters.
[0173] b) If the value of a kd-tree node is within the range, add both the subtrees pointed to by the left and right pointers to the search sequence; otherwise, only query the left or right subtree. Finally, add the multiple subsequences of length W obtained from the query to candidate set 1.
[0174] 2) Long query sequence index lookup.
[0175] A long query sequence is divided into one or more subsequences of length W and zero or one short sequence of length less than W.
[0176] For short sequences of length W, the ordinary kd-tree exact search method is used to search for sequences with the same trend and the matching sequences are included in candidate set 1 (all sequences in candidate set 1 are subsequences of length W).
[0177] For subsequences of length less than W, the query method described in 1) is used to search, and the results are placed into candidate set 1.
[0178] Step V.5. Subsequence matching and connection.
[0179] The candidate set 1 obtained in step V.4 contains several subsequences TS of length W. i Connect the subsequences in the candidate set according to their order to form a sequence with a length greater than or equal to len(Q), and put it into candidate set 2.
[0180] Step V.6. Similarity Measurement and Search.
[0181] The similarity between the time series in the candidate set 2 generated in step V.5 and the query sequence is measured using the classic Euclidean distance, and the subsequence with the smallest Euclidean distance to the query sequence is output.
[0182] For time series X and Y of equal length, the Euclidean distance ED is calculated as follows:
[0183]
[0184] Where Len(X) represents the length of the time series X, X i and Y i These represent two time series from candidate set 2.
[0185] By following the steps above, we can obtain the subsequence that is most similar to the query sequence Q.
[0186] It should be noted here that, in addition to kd-tree, the index structure in similarity queries can also be implemented using R-tree.
[0187] The time-series data management method described in this invention is based on the time-series data management and functional optimization of the domestic data management system openGauss, and therefore has the characteristics of independent controllability.
[0188] In terms of data, the data processing objects of this invention are mainly high-dimensional, large-volume time-series data, not limited to a specific application field or dataset, which has higher application value than other domestic time-series databases.
[0189] Functionally, this invention possesses time-series data quality assessment, time-series data dimensionality reduction, and time-series data similarity query functions that other time-series data management systems do not have, specifically reflected in the following aspects:
[0190] 1) In terms of data cleaning, the classification of data drift does not simply divide data into two categories: abnormal and normal. Instead, it grades the data's credibility level, with a total of 4 levels: credible, 32% credible, 5% credible, and 0.3% credible. Users can customize the data to be removed according to their needs, which is different from the data cleaning of other time series data management systems.
[0191] 2) In terms of data quality assessment, in addition to assessment by time blocks, there is also an overall assessment of a column of data. The number of missing values, format errors, duplicate values, 32% confidence values, 5% confidence values and 0.3% confidence values in the entire column are counted and their proportions in the entire column of data are calculated. Alternatively, a portion of the data can be selected to obtain their individual assessments.
[0192] 3) Regarding data dimensionality reduction, this invention is applicable to dimensionality reduction operations on multidimensional arrays. By handling the dimension and size of the input array, the code can flexibly handle multidimensional arrays, not just two-dimensional data, demonstrating strong versatility. For high-precision floating-point numbers, a union is used to convert between floating-point and integer numbers, avoiding costly floating-point operations and improving code execution efficiency. Furthermore, floating-point precision adjustment is supported: the precision is adjusted by multiplying by 10 raised to the power of precision (the precision value is set in the code). Users can also reset the precision according to actual needs to achieve a balance between accuracy and efficiency in time-series data queries. In summary, the function expands and optimizes upon existing Z-order encoding algorithms, specifically for the characteristics of the openGauss database and multidimensional time-series data scenarios.
[0193] 4) Regarding time-series data similarity queries, this invention is suitable for processing high-dimensional, large-volume time-series data. By dividing the query sequence into long and short sequences according to its length, it achieves the goal of creating an index only once, without needing to rebuild the index regardless of changes in the query sequence. Furthermore, based on traditional similarity search, it considers trend representation, making the search results more consistent with the application requirements of similarity queries.
[0194] Example 2
[0195] This embodiment 2 proposes an intake duct auxiliary design system based on case knowledge graph, which corresponds to the intake duct auxiliary design method based on case knowledge graph in embodiment 1 above.
[0196] like Figure 4 As shown, the time-series data management system based on openGauss in this embodiment includes:
[0197] Time-series data cleaning module;
[0198] By preprocessing and cleaning duplicate and erroneous data, filling missing values with LSTM-based time series prediction methods, and using normal distribution statistics to classify the confidence level of drift data, a confidence level indicator for drift data is obtained.
[0199] Time series data quality assessment module;
[0200] By statistically analyzing and calculating the number and frequency of data anomalies in both row and column formats, and outputting the results in a table, the changes in the anomaly situation over time and the number and frequency of different anomaly types in each column of data are expressed.
[0201] Time-series data dimensionality reduction module;
[0202] To address the issue of different dimensional values in time series data, the Z-Order dimensionality reduction method is used, selecting appropriate precision and data type for dimensionality reduction based on the specific characteristics of the time series data.
[0203] Time series data splitting module;
[0204] Extract each non-time column attribute separately and combine it with the time column to form a new table;
[0205] And a time-series data similarity query module;
[0206] By segmenting time-series data, representing trends, and establishing a kd-tree index structure, fast similarity queries and pruning are achieved. The results retain the trend information of the data, and the computation process is highly efficient.
[0207] It should be noted that the implementation process of the functions and roles of each module in the case knowledge graph-based intake duct auxiliary design system is detailed in the corresponding steps of the above method, and will not be repeated here.
[0208] Of course, the above description is only a preferred embodiment of the present invention. The present invention is not limited to the above-described embodiments. It should be noted that any equivalent substitutions or obvious modifications made by those skilled in the art under the guidance of this specification fall within the scope of this specification and should be protected by the present invention.
Claims
1. A time-series data management method based on openGauss, characterized in that, Includes the following steps: Time series data cleaning steps; By preprocessing and cleaning duplicate and erroneous data, filling missing values with LSTM-based time series prediction methods, and using normal distribution statistics to classify the confidence level of drift data, a confidence level indicator for drift data is obtained. Steps for time series data quality assessment; By statistically analyzing and calculating the number and frequency of data anomalies in both row and column formats, and outputting the results in a table, the changes in the anomaly situation over time and the number and frequency of different anomaly types in each column of data are expressed. Steps for dimensionality reduction of time series data; To address the issue of different dimensional values in time series data, the Z-Order dimensionality reduction method is used to select appropriate precision and data type for dimensionality reduction based on the specific characteristics of the time series data. The specific steps for time-series data dimensionality reduction are as follows: Step III.
1. First, the user inputs an array of any type, Array[d1,d2,…,dk], containing dimension names. The function zorder accepts the array and stores its address information in the pointer input_array, while simultaneously retrieving the array information. Step III.
2. Define a pointer array input_values. First, allocate memory space for input_values using the palloc function, with a size of array_dims[0] multiplied by sizeof(int32 *); Where array_dims[0] represents the array dimension size, and sizeof(int32 *) represents the number of bytes occupied by the pointer type int32 *; Then, by iterating through each element of the array in turn, the address of each element is assigned to input_values[i]. Where, input_values[i] represents the address of the i-th element; Step III.
3. For the saved floating-point array input_array, obtain its element type using the statement Oid elem_type = ARR_ELEMTYPE(input_array). Where Oid is an unsigned integer that identifies the data type, and ARR_ELEMTYPE is a macro used to get the element type of the array; for float4, three nested loops are used to iterate through each element in the input array; The outer loop i processes the number of bits in each uint32_t encoding, the middle loop j iterates through the number of columns in the array, and the inner loop k accesses the elements in the number of rows, i.e., the j-th dimension. Step III.
4. Call the float_to_uint32 function to convert the single-precision floating-point number (float4 type) to a 32-bit unsigned integer (uint32_t type) and store it in the new variable int_val; Step III.
5. Perform a bitwise AND operation between the unsigned integer int_val obtained in Step III.4 and 1 << i: int_val & 1 << i. This means retaining the value of the i-th bit in int_val and setting the other bits to 0. Shift the result left by ((j * 32) + k) bits to obtain the binary number and perform a bitwise OR operation |= with output_value32. Store the result back in output_value32. Where 1 << i means shifting the binary number 1 to the left by i bits; Step III.
6. Finally, the zorder function returns the generated Z-order encoding output_value32; Steps for splitting time-series data; Extract each non-time column attribute separately and combine it with the time column to form a new table; And the steps for querying time-series data similarity; By segmenting time-series data, representing trends, and establishing a kd-tree index structure, fast similarity query and pruning can be achieved.
2. The time-series data management method based on openGauss according to claim 1, characterized in that, The time-series data cleaning steps are as follows: Step I.
1. Processing duplicate values in time-series data; First, the number of data points N(γ) to be collected per unit time is determined based on the data collection frequency γ. Then, the number of data points M(D,t) per unit time is calculated based on the amount of data at each timestamp in the dataset D. If M(D,t)>N(γ), then search for completely identical duplicate data, and delete the duplicate data if they exist. Step 1.
2. Clean up erroneous data using prior knowledge; When reading data, use the conditional functional dependency set Σ to determine if there are any anomalies; if there are anomalies, substitute the data into the conditional functional dependency set Σ, and modify the erroneous data to make the data conform to the conditional functional dependency set Σ. Step I.
3. Use LSTM to fill in missing values; 70% of the data that was not marked as anomalies after processing in steps I.1 and I.2 was used as the training set and 30% as the test set for training the LSTM model; after the model was trained, the LSTM model was used to predict the values of missing values and fill them in. Step I.
4. Use LSTM and normal distribution methods to label the confidence level of the data; The residual dataset R is obtained by subtracting the predicted values from the actual values of the LSTM model. The mean µ and standard deviation σ of R are calculated, and its distribution is fitted to a normal distribution. The confidence level is graded according to the magnitude of the residual r of each data item.
3. The time-series data management method based on openGauss according to claim 2, characterized in that, In step I.4, the formula for grading the level of credibility is as follows: ; Credibility information is stored in three new tables, which respectively store the location information of data with credibility levels of 32%, 5%, and 0.3%.
4. The time-series data management method based on openGauss according to claim 1, characterized in that, The specific steps for time-series data quality assessment are as follows: II.
1. Divide the data of the query column into time segments, and count the number of anomalies in each time segment, including duplicate values, format errors, missing values, 32% confidence values, 5% confidence values, and 0.3% confidence values. Divide the number of time anomalies in each time segment by the total number of data in that time segment to calculate the anomaly frequency of each time segment. II.
2. Use Table 1 to display the time and corresponding anomaly frequency of the data in step II.1; Table 1 is a two-row multi-list. Each column in the first row outputs the time spans, and the second row outputs the frequency of anomalies in each time period, showing the changes in the abnormal conditions of the data of the query sequence over time, thus completing the time anomaly analysis table. II.
3. Count the number of outlier types in each column, including missing values, 32% confidence values, 5% confidence values, and 0.3% confidence values. Divide the number of different types of outliers by the total number of data in that dimension to calculate the outlier frequency for each dimension. II.
4. Use Table 2 to display the types of anomalies, their corresponding number, and their frequencies from step II.3; Table 2 is a three-row multi-column table, with each column representing a dimension of the source data; The first row of each column outputs the dimension of the source data that the column represents, the second row outputs the number of anomalies in the source data for that column, and the third column outputs the anomaly frequency for that dimension, so as to show the occurrence of different anomalies in each dimension and complete the dimension anomaly analysis table.
5. The time-series data management method based on openGauss according to claim 1, characterized in that, In step III.3, the inner loop process is as follows: First, define a variable val of type float4, and then convert the element in the k-th row of the j-th dimension to a floating-point number of type float4 using *((float4 *) (&input_values[k][j])). Wherein, input_values[k][j] represents the address of the element in the k-th row and j-th column of the input array; *((float4 *) (&input_values[k][j])) represents converting the integer values in the input_values array to float4 type values; Use the pow function from the C++ math library to multiply a floating-point number by 10 to the power of precision and convert it to an integer type; Among them, precision is a precision parameter used to control the precision of converting floating-point numbers to integers.
6. The time-series data management method based on openGauss according to claim 1, characterized in that, Step III.4 specifically includes: First, define a union containing two members: a 32-bit unsigned integer uint32_t i and a single-precision floating-point number float4 f; the union allows these two members to share the same memory space; Declare a local variable u in the function. u is an instance of this union. Assign the input floating-point number val to the floating-point member uf of the union. In this way, the binary representation of the floating-point number is stored in the union. Finally, the floating-point number is converted to a 32-bit unsigned integer by returning the integer member ui of the union.
7. The time-series data management method based on openGauss according to claim 1, characterized in that, The time-series data similarity query steps are as follows: Step V.
1. Data partitioning; Set the window size to A sliding window with a step size of 1 is used to slide the time series. Divided into Subsequences ; Where len(TS) represents the length of the time sequence TS; W represents the subsequence TS i Length; k represents the subsequence TS i The number of columns; Step V.
2. Segmented trend representation; For the k-dimensional subsequences partitioned in step V.1 Divide it into equal lengths microsequences , The length is Symbolic representation of the overall trend in each dimension of each micro-sequence segment; Let microsequences If a certain attribute column has a start point of startpoint and an end point of endpoint, then its slope is... , if the micro-sequence Then it is represented by 1, if the microsequence If , then 0 is used to represent it; Among them, startpoint(TS) ij )express The starting point, endpointt(TS) ij )express The endpoint; At this point, each attribute column of the subsequence forms a sequence of length [length missing]. The binary sequence representing the data trend is converted vertically into decimal numbers, and each subsequence can generate a one-dimensional trend vector containing trend information. Step V.
3. Index tree construction; The one-dimensional trend vectors of all subsequences generated in step V.2 are used to construct a kd-tree index for finding sequences with the same data trend. A trend kd-tree is constructed based on the characteristics of the kd-tree. Step V.
4. Determine the length of the query sequence; For length less than The query sequence is defined as a short sequence with a length greater than [missing information]. The query sequence is defined as a long sequence, and query sequences of different lengths are defined and indexed separately. 1) Short query sequence index lookup; For insufficient length The query sequence uses a special kd-tree range search method to search for sequences with the same trend, that is: a) First, determine the range of symbols that each dimension of the query sequence represents; b) If the value of a kd-tree node is within the range of step a), then add both the subtrees pointed to by the left and right pointers to the search sequence; otherwise, only query the left or right subtree. Finally, the multiple nodes of length obtained from the query will be... Subsequences are added to candidate set 1; 2) Long query sequence index lookup; Long query sequences are divided into one or more sequences of length 1. Subsequences and zero or one subsequence of insufficient length short sequence; Among them, for length is For short sequences, use the ordinary kd-tree exact search method to search for sequences with the same trend and include the matching sequences in candidate set 1; For insufficient length The subsequences are searched using the query method described in 1), and the results are placed into candidate set 1; Step V.
5. Subsequence matching and connection; The candidate set 1 obtained in step V.4 contains several candidates of length equal to of subsequence of Connect the subsequences in the candidate set according to their order to form a sequence of length greater than or equal to 1. The sequence is then placed into candidate set 2; Step V.
6. Similarity Measurement and Search; The similarity between the time series in the candidate set 2 generated in step V.5 and the query sequence is measured using the classic Euclidean distance, and the subsequence with the smallest Euclidean distance to the query sequence is output. By following the steps above, we can obtain the subsequence that is most similar to the query sequence.
8. The time-series data management method based on openGauss according to claim 7, characterized in that, In step V.3, the process of constructing a trend kd-tree based on the characteristics of a kd-tree is as follows: For each trend vector generated in step V.2: Step V.3.
1. If the tree is empty, then use this trend vector as the root node; Step V.3.
2. If the tree is not empty, compare sequentially starting from the root node. If the value of each dimension of a certain node in the tree is equal, then connect this trend vector to the linked list of this node; otherwise, compare according to the specified comparison dimension of each level. If the value is less than the specified dimension of the current node, then enter the left subtree to loop through this construction step until the k-th level is found; if the value is greater than the specified dimension of the current node, then enter the right subtree to loop through this construction step until the k-th level is found. Step V.3.
3. If no node with the same dimensions is found at level k, then connect it to the left or right linked list of the leaf node according to the size of the last dimension.
9. A time-series data management system based on OpenGauss for implementing the time-series data management method based on OpenGauss as described in claim 1, characterized in that, The openGauss-based time-series data management system includes: Time-series data cleaning module; By preprocessing and cleaning duplicate and erroneous data, filling missing values with LSTM-based time series prediction methods, and using normal distribution statistics to classify the confidence level of drift data, a confidence level indicator for drift data is obtained. Time series data quality assessment module; By statistically analyzing and calculating the number and frequency of data anomalies in both row and column formats, and outputting the results in a table, the changes in the anomaly situation over time and the number and frequency of different anomaly types in each column of data are expressed. Time-series data dimensionality reduction module; To address the issue of different dimensional values in time series data, the Z-Order dimensionality reduction method is used, selecting appropriate precision and data type for dimensionality reduction based on the specific characteristics of the time series data. Time series data splitting module; Extract each non-time column attribute separately and combine it with the time column to form a new table; And a time-series data similarity query module; By segmenting time-series data, representing trends, and establishing a kd-tree index structure, fast similarity queries and pruning are achieved, and the results retain the trend information of the data.
Citation Information
Patent Citations
Data cleaning method and device based on time sequence similarity
CN111026741A
Meteorological data knowledge discovery method and system
CN116860824A
