Method for data type change processing in time series database and related device

By updating metadata versions and establishing type barriers in the time-series database, the problems of reduced processing efficiency and increased resource consumption caused by data type adjustments were resolved, ensuring the stability of data writing and the reliability of queries, and achieving data processing consistency before and after data type changes.

CN123157731APending Publication Date: 2026-11-24TIANMOU TECH (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611378560.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-07
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

In time-series databases, adjusting data types can lead to reduced data processing efficiency and increased system resource consumption, especially in maintaining consistency between data storage and query processing.

Method used

By updating the metadata version of the target time series, a type barrier is established to prevent the active in-memory table from receiving newly written data and flushing it to the historical physical data file. At the same time, a new in-memory table is created to adapt to the data type change, and type adaptation is performed during queries to ensure that the query results are consistent before and after the data type change.

Benefits of technology

It ensures the stability of data writing and the reliability of queries during data type changes, reduces system resource overhead, and ensures data processing efficiency and consistency before and after data type changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123157731A_ABST
    Figure CN123157731A_ABST
Patent Text Reader

Abstract

This invention discloses a method and related apparatus for handling data type changes in a time-series database. The method includes: obtaining a data type change request; responding to the data type change request, updating the metadata version corresponding to the target time series; establishing a type barrier based on the updated metadata version, causing the active memory table to stop receiving new target time series data, and flushing existing data to form a historical physical data file that maintains the physical data type corresponding to a first logical data type; and creating a new memory table corresponding to a second logical data type; when querying the target time series, determining the second logical data type according to the updated metadata version, and performing type adaptation on the read data based on the type relationship between the physical data type of the historical physical data file and the second logical data type. This invention can reduce the impact of data type changes on the storage and querying of historical data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method and related apparatus for handling data type changes in a time-series database. Background Technology

[0002] Time series databases are a type of database system used for storing, managing, and querying time-series data. They are widely used in scenarios such as industrial monitoring, equipment operation monitoring, the Internet of Things (IoT), and data analysis. Time series databases typically use time series as the basic data organization object and set corresponding data types for each time series to enable data storage, retrieval, comparison, and calculation based on the data type.

[0003] As data acquisition equipment, business needs, and data processing methods change, the data types corresponding to established time series may need to be adjusted. For example, the value range of the original data type may not meet the needs of subsequent data acquisition, or subsequent data processing methods may require the use of other data types. Therefore, time series databases can provide corresponding data type adjustment functions to meet the data management needs during the continuous evolution of data.

[0004] In terms of data storage, time-series databases can organize data using a combination of in-memory data structures and persistent data files. Data being written can first be stored in an in-memory data structure and then converted into persistent data files upon meeting certain conditions; multiple existing data files can also be merged and organized. Regarding data querying, relevant data can be read based on the time series definition information, and filtering, calculations, and other query operations can be performed.

[0005] As the data type of time series changes, the database needs to maintain consistency in data storage, writing, and query processing before and after the data type change, while also taking into account system resource consumption and processing efficiency during the data processing process.

[0006] Therefore, how to ensure the normal writing and querying of time series data after data type adjustment, and reduce the impact of data type adjustment on data processing efficiency and system resource consumption, has become a technical problem to be solved. Summary of the Invention

[0007] To address the problems in the prior art, the present invention aims to provide a method and related apparatus for handling data type changes in a time-series database, so as to solve the problems of reduced data processing efficiency and increased system resource consumption during data type adjustment.

[0008] The first aspect of this disclosure provides a method for handling data type changes in a time-series database, comprising: The system retrieves a data type change request for the target time series, which changes the first logical data type of the target time series to a second logical data type. In response to the data type change request, it updates the metadata version corresponding to the target time series to make the second logical data type effective. Based on the updated metadata version, it establishes a type barrier for the target time series, causing the active memory table storing data corresponding to the first logical data type to stop receiving newly written data from the target time series. It also flushes the data of the target time series in the active memory table to form a historical physical data file with the corresponding physical data type of the first logical data type, and creates a new memory table corresponding to the second logical data type so that newly written data after the type change enters the new memory table. In response to a query request for the target time series, it determines the second logical data type based on the updated metadata version and performs type adaptation on the data read from the historical physical data file based on the type relationship between the physical data type corresponding to the historical physical data file and the second logical data type, so that the query results for the target time series conform to the second logical data type.

[0009] In some implementations, updating the metadata version corresponding to the target time series includes: After the data type change request is verified, the metadata version change corresponding to the target time series is submitted atomically, so that the metadata version is updated from the first metadata version corresponding to the first logical data type to the second metadata version corresponding to the second logical data type, so that the second metadata version becomes the updated metadata version.

[0010] In some implementations, a type barrier is established for the target time series, including: When it is detected that there is target time series data written in the first logical data type in the active memory table that has not yet been flushed to disk, the writing of target time series data to the active memory table in the first logical data type is prevented, and the flushing process of the corresponding data in the active memory table is triggered.

[0011] In some implementations, data read from the historical physical data file is type-adapted based on the type relationship between the physical data type corresponding to the historical physical data file and the second logical data type, including: Obtain the physical data type corresponding to the historical physical data file; compare the physical data type with the second logical data type; when the physical data type and the second logical data type are inconsistent and there is a corresponding type conversion relationship, insert type adaptation processing in the data reading path to convert the data read from the historical physical data file into the second logical data type.

[0012] In some implementations, type adaptation processing is performed by a type adaptation iterator set in the data read iteration path. The type adaptation iterator is used to convert data read from the historical physical data file into a second logical data type in memory without modifying the historical physical data file.

[0013] In some implementations, the data type change handling method further includes: In response to a query request for the target time series, obtain the filtering conditions for the target time series. The filtering conditions are constructed based on the second logical data type. Based on the type conversion relationship between the physical data type of the historical physical data file and the second logical data type corresponding to the filtering condition, determine whether the filtering condition can be pushed down to the data reading layer corresponding to the historical physical data file. When it is determined that the filter condition can be pushed down, the comparison operands in the filter condition are converted into a form compatible with the physical data type, and the converted filter condition is pushed down to the data reading layer so that the data reading layer can perform a comparison with the physical data in the historical physical data file based on the converted filter condition.

[0014] In some implementations, the data type change handling method further includes: In response to a query request for the target time series, obtain the data block statistics corresponding to the historical physical data file; based on the type relationship between the physical data type and the second logical data type of the historical physical data file, determine whether the statistical semantics represented by the data block statistics remain valid under the second logical data type; if it is determined that the statistical semantics remain valid, perform data block-level filtering and pruning using the data block statistics; if it is determined that the statistical semantics do not remain valid, prohibit the performance of data block-level filtering and pruning based on the data block statistics, and read the data details from the historical physical data file to perform filtering.

[0015] In some implementations, the data type change processing method further includes: performing a merge process on multiple data files, including historical physical data files; identifying a target historical file whose physical data type is a first logical data type; and in the merge process, converting the physical data in the target historical file into a second logical data type, and generating a target merged data file with the second logical data type based on the converted data.

[0016] In some implementations, generating a target merged data file with a second logical data type based on the transformed data includes: Regenerate the data block metadata corresponding to the target merged data file based on the data converted to the second logical data type, so that the data type represented by the data block metadata is consistent with the second logical data type. In some embodiments, regenerating the data block metadata corresponding to the target merged data file based on the data converted to the second logical data type includes: redetermining the corresponding data block statistics based on the data converted to the second logical data type, so that the data block statistics correspond to the second logical data type.

[0017] A second aspect of this disclosure provides a data type change processing apparatus in a time-series database, comprising: The module includes a change request receiving module, which receives data type change requests for the target time series, changing the first logical data type of the target time series to a second logical data type. A version update module, responding to the data type change request, updates the metadata version corresponding to the target time series to make the second logical data type effective. A write barrier establishment module, based on the updated metadata version, establishes a type barrier for the target time series, causing the active memory table storing data corresponding to the first logical data type to stop receiving new data written to the target time series. It also flushes the data in the active memory table to form a historical physical data file with the corresponding physical data type of the first logical data type, and creates a new memory table corresponding to the second logical data type, allowing the newly written data with the changed type to enter the new memory table. A data read adaptation module, responding to a query request for the target time series, determines the second logical data type based on the updated metadata version and adapts the data read from the historical physical data file according to the type relationship between the physical data type corresponding to the historical physical data file and the second logical data type, ensuring that the query results for the target time series conform to the second logical data type.

[0018] A third aspect of this disclosure provides a time-series database system, comprising: The data management node is configured to receive data type change requests for the target time series. These requests change the first logical data type of the target time series to a second logical data type. The node also updates the corresponding metadata version of the target time series in response to the data type change request, making the second logical data type effective. The data writing node is configured to establish a type barrier for the target time series based on the updated metadata version. This barrier causes the active memory table storing data corresponding to the first logical data type to stop receiving new data written to the target time series. The node then flushes the target time series data from the active memory table to form a historical physical data file with the corresponding physical data type of the first logical data type. Additionally, it creates a new memory table corresponding to the second logical data type, allowing the newly written data with the changed type to enter the new memory table. The data query node is configured to respond to query requests for the target time series, determine the second logical data type based on the updated metadata version, and perform type adaptation on the data read from the historical physical data file based on the type relationship between the physical data type corresponding to the historical physical data file and the second logical data type, ensuring that the query results for the target time series conform to the second logical data type.

[0019] This disclosure provides a fourth aspect of an electronic device, characterized in that it includes: a processor; and a memory storing executable instructions of the processor; wherein the processor is configured to execute a data type change processing method in a time-series database according to any of the above embodiments by executing the executable instructions.

[0020] The fifth aspect of this disclosure provides a computer-readable storage medium for storing a program that, when executed, implements the data type change processing method in a time-series database according to any of the above embodiments.

[0021] The sixth aspect of this disclosure provides a computer program product having a computer program stored thereon, characterized in that, when the computer program is executed by a processor, it implements the data type change processing method in the time-series database of any of the above embodiments.

[0022] The data type change processing method and related apparatus for time-series databases proposed in this disclosure have the following advantages: When the data type of the target time series changes from a first logical data type to a second logical data type, the corresponding metadata version of the target time series is updated to make the second logical data type effective. A type barrier is then established for the target time series based on the updated metadata version. This causes the active memory table storing data corresponding to the first logical data type to stop receiving new target time series data. Simultaneously, existing data is flushed to create a historical physical data file that retains the physical data type of the first logical data type, and a new memory table corresponding to the second logical data type is created to receive subsequent new data writes. This establishes a write boundary before and after the data type change, preventing data of different logical data types from being mixed and written to the same active memory table, thus ensuring the stability of data write processing during data type changes.

[0023] Furthermore, for existing historical physical data files, the currently effective second logical data type is determined based on the updated metadata version. Then, considering the type relationship between the physical data type corresponding to the historical physical data file and the second logical data type, data read from the historical physical data file is type-adapted, enabling historical data to participate in query processing according to the currently effective second logical data type. Therefore, it is not necessary to immediately modify the existing historical physical data files when data types change; data before and after the data type change can be queried according to a unified current logical data type, thereby reducing the impact of data type changes on historical data storage and query processing.

[0024] Therefore, this disclosure enables logical data type changes to be coordinated with the continuous data writing and query processing of the time-series database through the synergy between metadata version updates, type barrier establishment, historical physical data retention, and query type adaptation. This ensures that new data is written normally after a data type change, improves the queryability of historical data and the processing stability during the data type change process, and helps to reduce data rewriting and system resource overhead caused by data type changes.

[0025] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0026] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings.

[0027] Figure 1 This is a flowchart illustrating a method for handling data type changes in a time-series database according to one embodiment of the present disclosure. Figure 2 This is a schematic diagram of the hardware topology of a time-series database system according to one embodiment of the present disclosure; Figure 3 This is a schematic diagram illustrating the process of collaborative processing and lifecycle management of type change requests among distributed nodes in one embodiment of this disclosure; Figure 4 This is a schematic diagram illustrating the process of switching memory tables on the write path and merging and converging in the background in one embodiment of this disclosure. Figure 5 This is a schematic diagram of the dynamic type adaptation and filtering condition push-up process during data query in one embodiment of the present disclosure. Figure 6 This is a schematic diagram illustrating the process of local aggregation of statistical information and accumulator update during aggregation query in one embodiment of this disclosure; Figure 7 This is a structural block diagram of a data type change processing device according to one embodiment of the present disclosure; Figure 8 This is a schematic diagram of the electronic hardware structure of a computing device suitable for implementing a data type change processing method in one embodiment of this disclosure. Detailed Implementation

[0028] To make the technical solution, the technical problem solved, and the technical effects of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the described embodiments are merely exemplary embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Those skilled in the art can make various modifications and variations to the embodiments without departing from the spirit and scope of the present invention, and all such modifications and variations should be considered to fall within the scope of protection of the present invention.

[0029] Techniques, methods, and apparatus known to those skilled in the art are not discussed in detail where appropriate, but should be considered part of this specification. In all examples shown herein, any specific numerical values ​​or parameters should be interpreted as exemplary only and not as limiting the invention.

[0030] The embodiments of this disclosure are described below with reference to the accompanying drawings. It should be understood that the following embodiments are only for illustrating the technical solutions of this disclosure and are not intended to limit the scope of protection of this disclosure. Where there is no conflict, different embodiments of this disclosure and the technical features of different embodiments can be combined with each other.

[0031] This disclosure provides a method for handling data type changes in a time-series database. This method can be applied to a time-series database system that supports changes in time-series data types. It is used to process the writing of data after the data type change and the querying of existing data when the data type of the time series changes.

[0032] In one application scenario, a time-series database can continuously receive time-series data from data acquisition devices, sensors, or other data sources, and write the received data into the corresponding time series. As the data acquisition scope, data value range, or business processing requirements change, an established target time series may need to be changed from one data type to another. For example, the target time series may have used a first data type before the change, but after meeting the conditions for data type change, a second data type needs to be used to process subsequent data.

[0033] The logical data types in this disclosure are used to characterize the data types defined by the time series database for time series. The first logical data type represents the logical data type corresponding to the target time series before the data type change, and the second logical data type represents the logical data type corresponding to the target time series after the data type change.

[0034] The physical data type in this disclosure is used to characterize the data type that is actually stored in the data storage medium. Since data type changes can occur after the target time series already exists, the data in the already formed data file can have a physical data type different from the second logical data type.

[0035] The metadata version in this disclosure is used to characterize the version status of the metadata information corresponding to the target time series, and can at least be used to determine the currently effective logical data type of the target time series. The metadata version can be used to determine the logical data type status before and after a data type change.

[0036] The type barrier in this disclosure is used to isolate data writes before and after the data type of the target time series changes, so that the active memory table processed according to the first logical data type no longer receives new data written by the target time series according to the first logical data type, and the data after the data type change enters the new memory table corresponding to the second logical data type.

[0037] In this disclosure, the historical physical data file refers to a data file that was formed from the active memory table before the data type changed. The data in the historical physical data file can retain the physical data type corresponding to its formation, and it is not required that its physical data type be changed synchronously when the logical data type of the target time series changes.

[0038] like Figure 1 As shown, Figure 1 This invention demonstrates the overall process of performing data type change processing on a time-series database in one embodiment of the present disclosure. Figure 1The execution entity of the method shown can be one or more processing nodes in a time series database, or it can be jointly executed by data management nodes, data writing nodes, and data query nodes in the time series database. Specifically, the data management node is used to maintain the metadata information corresponding to the time series, the data writing node is used to receive and store the time series data, and the data query node is used to read and process the time series data.

[0039] like Figure 1 As shown, the data type change handling method may include the following steps: Step 110: Obtain a data type change request for the target time series. The data type change request is used to change the first logical data type of the target time series to the second logical data type.

[0040] Step 120: In response to the data type change request, update the metadata version corresponding to the target time series so that the second logical data type takes effect.

[0041] The updated metadata version indicates that the current logical data type of the target time series has changed from the first logical data type to the second logical data type, which is used for subsequent data writing and data query processing.

[0042] In this implementation, the metadata version is used to determine the currently active logical data type of the target time series, while the physical data type in the data file is used to characterize the actual data representation of the stored data. Therefore, when the logical data type of the target time series changes, the physical data type in the already formed data file can remain unchanged temporarily.

[0043] Step 130: Based on the updated metadata version, establish a type barrier for the target time series, causing the active memory table storing data corresponding to the first logical data type to stop receiving new data written to the target time series, and flushing the data of the target time series in the active memory table to form a historical physical data file with the physical data type corresponding to the first logical data type, and creating a new memory table corresponding to the second logical data type, so that the new data written after the type change enters the new memory table.

[0044] Type barriers are used to establish data write boundaries between the first logical data type and the second logical data type for the target time series. After the type barrier is established, the active memory table storing data corresponding to the first logical data type will no longer receive new data written to the target time series and will form a historical physical data file through flushing; subsequent new data will be written to a new memory table corresponding to the second logical data type.

[0045] In one implementation, the active memory table can be flushed as a whole. That is, when the data type of the target time series changes, the active memory table containing the target time series data is converted to an immutable state and flushed. Thus, the data before and after the data type change forms corresponding write boundaries, while the existing historical physical data files do not need to undergo immediate physical data type conversion when the data type changes.

[0046] Step 140: In response to the query request for the target time series, determine the second logical data type based on the updated metadata version, and perform type adaptation on the data read from the historical physical data file according to the type relationship between the physical data type corresponding to the historical physical data file and the second logical data type, so that the query results of the target time series conform to the second logical data type.

[0047] In one implementation, when a data query node reads a historical physical data file, it can obtain the sequence attributes corresponding to the historical physical data file and determine its actual physical data type based on the sequence attributes; further compare the physical data type with the currently effective second logical data type, and when there is a difference between the two and there is a corresponding type conversion relationship, perform type adaptation on the read data.

[0048] Through steps 110 to 140 above, after the data type of the target time series changes, the metadata version is used to determine the currently effective second logical data type, the type barrier is used to form the write boundary before and after the data type change, the historical physical data file retains its actual physical data type, and is adapted during the query process based on the type relationship between the actual physical data type and the second logical data type. Therefore, data changes do not require synchronous rewriting of the existing historical physical data file, allowing data before and after the change to participate in query processing according to the currently effective second logical data type.

[0049] In one embodiment, in step 110 above, the target time series can be a data object in a time series database used to store time series data with the same data attributes. It can be identified by a combination of sequence path, time series identifier, device identifier and measurement point identifier or other information that can uniquely identify the target time series. This disclosure does not make specific limitations in this regard.

[0050] A data type change request is used to request a change of the target time series' first logical data type to a second logical data type. The first and second logical data types represent the logical data types of the target time series before and after the data type change, respectively. For example, the first logical data type could be INT32, and the second logical data type could be INT64.

[0051] In one implementation, the data type change request can be implemented using a Structured Query Language (SQL) statement, an API call request, or other preset request formats. For example, the data type change request can be a data definition statement of type ALTER TIMESERIES, including the identification information of the target time series and a second logical data type.

[0052] In one implementation, in response to a data type change request, the data type change request can be validated for legality. Validation may include at least one of the following: the existence of the target time series, the requester's operating permissions, and the type conversion relationship between the first logical data type and the second logical data type.

[0053] For example, the first logical data type can be determined based on the metadata information of the target time series, and a preset type conversion matrix can be used to determine whether there is an allowed data type conversion relationship between the first and second logical data types. For data type change requests that satisfy the preset type conversion relationship, subsequent processing can continue; for data type change requests that do not satisfy the preset type conversion relationship, the corresponding data type change operation can be rejected.

[0054] In one implementation, the type conversion relationship is used to characterize whether data type conversion is allowed between different data types, and can further characterize the corresponding data conversion method. The type conversion relationship can be determined according to the value range, precision, or type compatibility rules of the data types, etc., and this disclosure does not impose specific limitations on it.

[0055] It should be noted that both the first and second logical data types are used to describe the logical data type of the target time series at the data model level, and are not necessarily consistent with the physical data type in the already formed data file.

[0056] For example, after the first logical data type of the target time series is changed from INT32 to INT64, the historical physical data files that were already formed before the data type change can still retain the physical data type corresponding to INT32, while the new data generated after the data type change is processed according to the data type corresponding to INT64.

[0057] By using the above method, we can determine the target time series for this data type change, the first logical data type before the change, and the second logical data type after the change, and perform a validity check on the data type change request before subsequent data type change processing.

[0058] In one implementation, in step 120 above, in response to the data type change request obtained in step 110, the metadata version corresponding to the target time series is updated so that the second logical data type takes effect.

[0059] Metadata describes the structure and attributes of the target time series, and may include at least its identifier, logical data type, and version information. Metadata can be maintained by the data management node in the time series database.

[0060] In one implementation, after verifying that the data type change request passes validation, the data management node generates a second metadata version corresponding to the second logical data type and atomically submits the metadata version change, updating the metadata of the target time series from the first metadata version corresponding to the first logical data type to the second metadata version corresponding to the second logical data type. Thus, the second logical data type becomes the currently effective logical data type for the target time series.

[0061] For example, before the data type changes, the metadata corresponding to the target time series may include a first metadata version and a first logical data type; after the data type changes, it can be updated to a second metadata version and a second logical data type. By submitting the above metadata changes atomically, the logical data type and its corresponding metadata version can be switched synchronously, avoiding the two being in an inconsistent effective state.

[0062] In one implementation, after completing the metadata version update, the data management node can provide the updated metadata version and the second logical data type to the data writing node and / or the data query node, so that the relevant nodes can determine the currently effective logical data type of the target time series based on the updated metadata.

[0063] It should be noted that this step updates the currently effective logical data type and its metadata version for the target time series. It does not require immediate modification of the physical data type in existing data files when the metadata version is updated. Existing data files can retain the physical data type they used at the time of creation. Subsequent data writing processes are performed based on the currently effective second logical data type, while the actual physical data type of historical data can be determined during reading based on the data type attributes of the corresponding data file and compared with the second logical data type to perform subsequent data read adaptation.

[0064] In one implementation, when the data type of the target time series changes again, a new metadata version can be generated based on the currently effective metadata version, and the currently effective logical data type can be updated. For example, after the target time series changes from a first logical data type to a second logical data type, the second logical data type can be further changed to a third logical data type, and a new metadata version corresponding to the third logical data type can be generated.

[0065] The above method can determine the currently effective logical data type of the target time series through metadata version updates, without requiring synchronous modification of the physical data type of the existing data files. This provides a basis for type status for subsequent differentiation of old and new data based on type barriers and for historical data reading and adaptation based on physical data types.

[0066] In one implementation, in step 130 above, the data writing node receives a data write request for the target time series and temporarily stores the received data in an active memory table (MemTable). The active memory table is used to temporarily store time series data that has not yet been converted into a persistent data file.

[0067] After the data write node receives the updated metadata version, it can compare the updated metadata version with the current metadata version corresponding to the target time series. When it is determined that the logical data type of the target time series has changed from the first logical data type to the second logical data type, a type barrier is established for the target time series.

[0068] Type barriers are used to establish write boundaries between a first logical data type and a second logical data type. Specifically, after determining that the data type of the target time series has changed from the first logical data type to the second logical data type based on the updated metadata version, the data write node can detect whether there is target time series data written in the first logical data type that has not yet been flushed to disk in the currently active memory table.

[0069] When the active memory table detects that target time series data has been written according to the first logical data type but has not yet been flushed to disk, the data writing node prevents the continued writing of target time series data to the active memory table according to the first logical data type, and triggers the flushing process of the corresponding data of the target time series to persist the data that has been written to the active memory table according to the first logical data type to form a historical physical data file.

[0070] In one implementation, the active memory table can be shared by multiple time series. When the data type of the target time series changes, the data writing node can only block further writing of the target time series data to the current active memory table according to the first logical data type, without blocking other time series that have not undergone data type changes from continuing to write data to that active memory table. For the data already written to the target time series, the corresponding disk flushing process can be triggered according to the organization of the active memory table.

[0071] In another implementation, when the active memory table is flushed as a whole, the data writing node can switch the active memory table containing the target time series to an immutable state and trigger the flushing process of the active memory table to form historical physical data files from the data that has not yet been persisted. After the flush is complete, a new active memory table can be created to receive subsequent data writes.

[0072] It should be noted that type barriers are used to define the boundary between data writes to the target time series under the first logical data type and data writes under the second logical data type. They do not require physical type conversion of data already written according to the first logical data type during the disk flushing process. Therefore, the historical physical data files generated during disk flushing can continue to be encoded and stored using the physical data type corresponding to the first logical data type.

[0073] In one implementation, after preventing further writing of the target time series data to the active memory table according to the first logical data type and completing the corresponding disk flushing process, the data writing node can receive the newly written data of the target time series according to the currently effective second logical data type, and write the newly written data to a new active memory table. The data in the new active memory table can be organized or encoded according to the physical data type corresponding to the second logical data type.

[0074] For example, when the data type of the target time series changes from INT32 to INT64, after detecting that there is target time series data written in INT32 that has not yet been flushed to disk in the original active memory table, the data writing node stops writing target time series data to the active memory table in INT32 and triggers the corresponding data flushing process; the historical physical data file formed by flushing can still be stored using the INT32 physical data type. Subsequently, the data writing node receives the newly written data of the target time series according to the currently effective INT64 logical data type and writes the newly written data to the new active memory table.

[0075] Furthermore, the flushing of active memory tables can be associated with the data time partition where the time series resides. An active memory table can correspond to one or more time partitions. Therefore, when the data type of the target time series changes, the data writing node can determine, based on the actual memory table organization, whether there is target time series data written according to the first logical data type that has not yet been flushed to disk, and perform flushing processing on the corresponding data.

[0076] By establishing a type barrier based on the updated metadata version, a clear boundary can be formed between the first logical data type and the second logical data type on the data writing path. This prevents data written according to the first logical data type and not yet flushed to disk from receiving new writes of the first logical data type. The data is then flushed to disk to form a historical physical data file. At the same time, subsequent new data is written according to the second logical data type and enters a new writing state. This avoids the target time series from continuing to mix data of different logical data types in the same writing state.

[0077] In one implementation, in step 140 above, the data query node responds to a query request for the target time series by determining the currently effective second logical data type based on the updated metadata version and obtaining the physical data type corresponding to the historical physical data file to be queried.

[0078] The historical physical data file is a data file formed by flushing the active memory table after terminating the reception of newly written data for the target time series in step 130. The data stored in it can continue to use the physical data type corresponding to the first logical data type. The physical data type corresponding to the historical physical data file can be obtained from the sequence attributes of the time series within it, or determined based on the data type information associated with the data file.

[0079] The data query node retrieves the physical data type corresponding to the historical physical data file and compares it with the currently effective second logical data type. When they match, the corresponding data can be directly read and processed according to the second logical data type; when they do not match, it further determines whether there is a corresponding type conversion relationship between them.

[0080] When a corresponding type conversion relationship exists, type adaptation is performed on the data read from the historical physical data file, and the data is converted into a second logical data type before participating in subsequent query processing.

[0081] For example, if the data type of the target time series is changed from INT32 to INT64, the data in the historical physical data file can still be physically stored using INT32. When the currently effective second logical data type is INT64, the data query node can adapt the INT32 data read from the historical physical data file to INT64 data without modifying the historical physical data file.

[0082] In one implementation, type adaptation processing is set up in the data read path. For example, a type adapter iterator can be set up in the data read iteration path. The type adapter iterator is used to receive data read from the historical physical data file and, based on the type conversion relationship between the physical data type and the second logical data type, convert the data into the second logical data type in memory before providing it to subsequent query processing.

[0083] Type adaptation is performed during data reading and does not change the physical storage type of the data in the historical physical data file. For different query processing paths, the corresponding type adaptation can be performed during data reading or subsequent query processing.

[0084] In one implementation, when executing a query containing filtering conditions in response to a query request for a target time series, the filtering conditions are constructed based on a currently effective second logical data type. The data query node can determine whether the filtering conditions can be pushed down to the data reading layer corresponding to the historical physical data file based on the type conversion relationship between the physical data type corresponding to the historical physical data file and the second logical data type corresponding to the filtering conditions.

[0085] When it is determined that the filtering condition can be pushed down, the comparison operands in the filtering condition can be converted into a form compatible with the physical data type of the historical physical data file, and the converted filtering condition can be pushed down to the data reading layer, so that the data reading layer performs a comparison with the physical data in the historical physical data file based on the converted filtering condition.

[0086] Furthermore, when it is determined that the filtering condition cannot be pushed down (for example, when there is a lack of lossless comparison conversion rules between the second logical data type and the physical data type, or when the filtering condition contains complex function operators that cannot be interpreted at the physical layer), the data query node does not perform the filtering condition pushdown; instead, the data reading layer reads the original data in the historical physical data file, converts it to the second logical data type via a type adaptation iterator, and then performs filtering processing based on the second logical data condition in the subsequent query operator layer.

[0087] Through the above processing, the filtering conditions can be executed during the physical data reading process, without having to convert all the read data into a second logical data type before performing the filtering.

[0088] For example, the second logical data type of the target time series is DOUBLE, while the target time series data in the historical physical data file is physically stored using INT32. For a filter condition `value>1` constructed based on the DOUBLE type, the data query node can convert the comparison operands in the filter condition into a form compatible with the INT32 physical data type according to the type conversion relationship between INT32 and DOUBLE, and push the converted filter condition to the data reading layer, so that the data reading layer can perform a comparison with the INT32 physical data in the historical physical data file based on the converted filter condition.

[0089] In the above manner, when the logical data type of the target time series changes while the historical physical data file is still stored using the original physical data type, the comparison operands in the filtering conditions can be adapted accordingly based on the type conversion relationship between the physical data type and the second logical data type, so that the filtering conditions can be executed at the data reading layer that matches the historical physical data type.

[0090] The purpose is to enable target time series whose logical data type has changed to still be able to perform filtering processing using the data reading capabilities corresponding to the historical physical data file, without having to immediately modify the physical storage type of the historical physical data file due to the change in logical data type.

[0091] When the filtering conditions can be pushed down, the data reading layer can directly perform filtering comparisons while reading historical physical data, providing only data that meets the filtering conditions to subsequent query processing. This reduces the transmission of data that does not meet the filtering conditions to subsequent processing paths and the corresponding type adaptation processing, thereby reducing the data processing overhead during query processing.

[0092] In one implementation, when performing query filtering on historical physical data files, data block statistics (such as minimum value MIN and maximum value MAX) corresponding to the historical physical data files can also be obtained. Based on the type relationship between the physical data type of the historical physical data files and the second logical data type, it can be evaluated whether the statistical semantics represented by the data block statistics remain valid under the second logical data type.

[0093] When it is determined that the statistical semantics remain valid under the second logical data type, data block-level filtering and pruning can be performed using data block statistics to skip data blocks that do not meet the query conditions; when it is determined that the statistical semantics do not remain valid, data block-level filtering and pruning based on data block statistics is prohibited, and necessary data details in historical physical data files are read to perform filtering.

[0094] For example, for the widening conversion of numeric types from INT32 to INT64, since the type conversion does not change the monotonic comparison relationship and algebraic addition semantics between numeric values, the statistical semantics represented by the minimum value MIN, maximum value MAX, and COUNT corresponding to the historical data blocks are still valid, and the minimum and maximum values ​​can continue to be used to perform data block-level filtering and pruning.

[0095] Conversely, when a type change involves a change in encoding rules or a reversal of comparison semantics (e.g., converting a numeric type to a string type TEXT, causing extreme value statistics based on numeric size to fail in lexicographical order; or a type conversion containing floating-point NaN values), if the data query node recognizes that the comparison or aggregation semantics represented by the original data block statistics cannot remain valid under the second logical data type, it will prohibit the use of the corresponding data block statistics to perform pruning. Instead, it will read the necessary data details to perform filtering to avoid incorrectly skipping the data that actually needs to be read based on inapplicable statistics.

[0096] Furthermore, when performing aggregation queries (such as COUNT, SUM, MIN, MAX, etc.) on a target time series, if the data query node determines that the statistical semantics of the historical data block statistics remain valid under the second logical data type, it can directly read the data block statistics and promote / convert the statistical values ​​to the second logical data type before directly participating in the calculation of the local aggregation results, without having to unpack and read the detailed data in the historical physical data file, thereby significantly reducing the disk I / O and CPU decoding overhead during aggregation queries.

[0097] In one implementation, when the query range covers data formed before and after the data type change, the data query node can read the historical physical data file and the new data formed according to the second logical data type (e.g., data in a new memory table or data in a new persistent data file), and perform type adaptation on the historical data whose physical data type is inconsistent with the second logical data type, so that the data before and after the change participate in the subsequent query processing according to the unified second logical data type.

[0098] For example, after the data type of the target time series is changed from INT32 to INT64, the data before the type change can continue to be physically stored using INT32, while the newly written data after the type change will be physically stored using INT64. When the query range covers both of these data, the new data stored using INT64 can be processed directly, and the INT32 data in the historical physical data file can be adapted to INT64 data to provide a unified second logical data type for subsequent query processing.

[0099] It should be noted that the type adaptation for historical data occurs during the query processing and does not require modification of the historical physical data file. The historical physical data file can retain the physical data type it used when it was created and can be gradually converted to the physical data type corresponding to the second logical data type through subsequent merging processing.

[0100] In this way, when the data type of the target time series changes but the historical physical data file retains its original physical data type, the decision to perform data block-level filtering and pruning can be made based on whether the statistical semantics represented by the data block statistics can remain valid under the second logical data type. For data blocks whose statistical semantics are no longer valid, filtering is performed by reading the data details, thereby avoiding pruning based on inapplicable statistical information.

[0101] Meanwhile, for queries that cover data before and after a data type change, type adaptation during the query process can be used to allow data of different physical data types to participate in subsequent query processing according to the second logical data type.

[0102] In one implementation, historical physical data files with changed data types can continue to participate in background compaction. The time-series database can perform compaction on multiple data files, including historical physical data files, and identify target historical files with physical data types of the first logical data type based on the physical data types of the data files participating in the compaction. The physical data in the target historical files is then converted to a second logical data type, and a target merged data file with the second logical data type is generated based on the converted data.

[0103] In one implementation, the time-series database can identify multiple data files to be merged and perform the merge process on these multiple data files. The multiple data files may include historical physical data files formed before the data type change, and data files formed after the data type change that use a second logical data type corresponding to the physical data type.

[0104] During the merge process, the time-series database can obtain the physical data type corresponding to the data files being merged, and identify the target historical file whose physical data type is the first logical data type based on the physical data type. The target historical file can be a data file that was created before the data type change and is still stored using the physical data type corresponding to the first logical data type.

[0105] In one implementation, the time-series database can read physical data from the target historical file and convert the physical data in the target historical file into data of the second logical data type according to the currently effective second logical data type of the target time series and a preset type conversion relationship. For example, after the data type of the target time series is changed from INT32 to INT64, the physical data in the target historical file is still stored in INT32 type. During the merging process, the INT32 type physical data can be converted into INT64 type data.

[0106] In one implementation, after obtaining the data converted to a second logical data type, the time-series database can regenerate the data block metadata corresponding to the target merged data file based on the converted data. The data block metadata can be reconstructed based on the converted second logical data type data, ensuring that the data type represented by the data block metadata is consistent with the second logical data type.

[0107] Furthermore, the time-series database can redetermine the corresponding data block statistics based on the data after it has been converted to the second logical data type. The data block statistics can include statistics such as the minimum value (MIN) and maximum value (MAX) of the data block, and can be recalculated or updated based on the converted data to make the data block statistics correspond to the second logical data type.

[0108] For example, when data in the target historical file is converted from INT32 to INT64, the minimum and maximum values ​​of the corresponding data blocks can be redefined based on the converted INT64 data, thereby generating data block statistics corresponding to the second logical data type. Thus, the data block metadata and data block statistics in the target merged data file both correspond to the converted second logical data type.

[0109] In one implementation, the time-series database can reassemble the converted data with other data participating in the merging process, and generate a target merged data file based on the reassembled data, giving the target merged data file a physical data type corresponding to the second logical data type. For data participating in the merging process that has already adopted the physical data type corresponding to the second logical data type, it can participate in the merging process according to its original physical data type; for physical data corresponding to the first logical data type in the target historical file, it is first converted to the second logical data type before participating in the merging process.

[0110] After generating the target merged data file, the time-series database can add it to the currently available data file set and remove data files that have been replaced by the target merged data file according to a preset data file replacement mechanism. Data file replacement can be performed atomically (e.g., by atomically updating the metadata manifest file or file version change log) so that the replaced data files are removed from the currently available data file set only after the target merged data file has been generated.

[0111] It should be noted that the above merging process can be executed as an existing background merging process in the time-series database, and does not require an additional dedicated merging scheduling mechanism for data type changes. For historical physical data that is still stored using the physical data type corresponding to the first logical data type, it can be converted according to the currently effective second logical data type when participating in normal merging processing, and stored using the physical data type corresponding to the second logical data type when generating new merged data files.

[0112] Through the above steps, the target historical file with physical data type of first logical data type can be converted into data of second logical data type in the background merging process, and the corresponding data block metadata and data block statistics are regenerated based on the converted data, thereby generating the target merged data file with physical data type corresponding to the second logical data type, so that the physical data type of historical physical data can be gradually converted into the physical data type corresponding to the second logical data type in subsequent merging processes.

[0113] In one embodiment, this disclosure also provides a time-series database system. For example... Figure 2 As shown, the time series database system may include a data management node 210, a data writing node 220, and a data query node 230, which are respectively used to perform metadata processing, data writing processing, and data query processing corresponding to data type changes, and to determine the data type of the target time series through metadata version collaboration.

[0114] In one implementation, the data management node 210 is used to manage the metadata information corresponding to the target time series. The metadata information is used to characterize the currently effective logical data type of the target time series and the corresponding metadata version.

[0115] When a data type change request for a target time series is received, the data management node 210 can verify the request and, upon successful verification, update the metadata version corresponding to the target time series, making the second logical data type the currently effective logical data type. The metadata version update can be committed atomically to ensure that the logical data type and its corresponding metadata version take effect simultaneously.

[0116] After the second logical data type takes effect, the data management node 210 can provide the updated metadata version to the data writing node 220 and the data query node 230, or the data writing node 220 and the data query node 230 can obtain the updated metadata version through the metadata synchronization mechanism. Thus, the data writing node 220 and the data query node 230 can determine the currently effective second logical data type of the target time series based on the same metadata version.

[0117] In one implementation, the data writing node 220 is used to process the data writing of the target time series according to the updated metadata version, and to establish a type barrier for the target time series based on the updated metadata version.

[0118] Specifically, when the data writing node 220 determines that the logical data type corresponding to the target time series has changed from the first logical data type to the second logical data type, it can stop the current active memory table from receiving new data written to the target time series and trigger the disk flushing process of the current active memory table, so that the target time series data already written therein forms a historical physical data file.

[0119] Historical physical data files can continue to store written data using the physical data type corresponding to the first logical data type. Data write node 220 can also create a new memory table corresponding to the second logical data type, allowing newly written data with the changed type to enter the new memory table.

[0120] Therefore, by switching the state of the active memory table, the write boundary before and after the data type change is formed, so that the data written before the type change forms a historical physical data file according to the physical data type corresponding to the first logical data type, while the newly written data after the type change is stored according to the second logical data type.

[0121] In one implementation, the data writing node 220 can determine the version of the data writing request based on the metadata version corresponding to the target time series, and write the data to the corresponding memory table according to the determination result, so as to avoid the written data before and after the type change entering the wrong data processing boundary.

[0122] In one implementation, the data query node 230 is used to process query requests for a target time series. When a query request is received, the data query node 230 can determine the currently effective second logical data type based on the updated metadata version and determine the data file corresponding to the query request.

[0123] For historical physical data files, data query node 230 can obtain the corresponding physical data type and compare the physical data type with the second logical data type. When the two are consistent, the corresponding data can be directly read and processed according to the second logical data type; when the two are inconsistent, it determines whether there is an available type adaptation relationship based on the preset type conversion relationship.

[0124] In one implementation, the physical data type corresponding to the historical physical data file can be obtained through a sequence attribute corresponding to the historical physical data file. The sequence attribute is used to characterize the physical data type of the corresponding data. The data query node 230 can compare the obtained physical data type with the currently effective second logical data type to determine whether the data in the historical physical data file belongs to the old type of data formed before the data type change.

[0125] When a usable type adaptation relationship exists, the data query node 230 can set up type adaptation processing in the data reading path to convert the physical type data read from the historical physical data file into data of the second logical data type, and provide the converted data to subsequent query processing.

[0126] In one implementation, type adaptation processing can be achieved through a type adaptation iterator set in the data read iteration path. The type adaptation iterator can be connected to the original read iterator used to read historical physical data files, so that the physical type data output by the original read iterator is converted by the type adaptation iterator before being provided to subsequent query operators.

[0127] For example, when the data in the historical physical data file is stored using the INT32 physical data type, while the second logical data type currently in effect for the target time series is INT64, the data query node 230 can convert the read INT32 data into INT64 data through a type adapter iterator and participate in the query processing according to the second logical data type corresponding to INT64, without modifying the original data representation in the historical physical data file.

[0128] In one implementation, when the query scope covers data both before and after the data type change, the data query node 230 can read both the historical physical data file and the data file formed after the type change. For historical data whose physical data type is inconsistent with the second logical data type, type adaptation is performed in the data reading path; for data that has already been physically stored using the second logical data type, it can be read directly. Thus, data represented by different physical data types can participate in subsequent query processing according to a unified second logical data type during the same query process.

[0129] Furthermore, the data query node 230 can determine the corresponding query processing method based on the physical data type, the second logical data type, and the specific query conditions of the historical physical data file. For example, for filter conditions that meet type compatibility conditions, the converted filter conditions can be pushed to the data reading layer; for cases where data block statistics still have valid comparison semantics under the second logical data type, data block-level filtering pruning can be performed using the data block statistics. Specific processing methods can be referred to the aforementioned related implementation methods, and will not be repeated here.

[0130] In one implementation, the time-series database system can also perform background merging of data files. When merging multiple data files, data whose physical data type is inconsistent with the currently effective second logical data type can be identified. During the merging process, the corresponding data is converted to the second logical data type, and a target merged data file is generated based on the converted data. Data block metadata and statistics corresponding to the converted data are also regenerated. Thus, historical physical data files can gradually converge to the second logical data type in subsequent merging processes.

[0131] In the above manner, the data management node 210 determines the currently effective logical data type of the target time series through the metadata version, the data writing node 220 establishes a type barrier based on the updated metadata version to form the writing boundary before and after the data type change, and the data query node 230 performs query adaptation based on the relationship between the currently effective second logical data type and the actual physical data type of the historical physical data file.

[0132] Therefore, time-series databases can complete the logical data type change of the target time series while continuously writing and querying data, and allow the existing historical physical data files to retain their original physical data type until the subsequent merging process is completed, thereby achieving decoupling between logical data type change and historical physical data storage.

[0133] Based on such Figure 2 The time-series database system shown in this disclosure Figure 3This paper demonstrates a workflow for performing data type change processing in a time-series database. This workflow involves collaborative processing among data management nodes, data writing nodes, data query nodes, and a merge processing module.

[0134] In one implementation, the aforementioned data management node, data writing node, data query node, and merging processing module can be located in the same database device or in different devices; this disclosure does not limit this. For example, in a distributed time-series database, the data management node can be implemented by a ConfigNode, the data writing node by a DataNode, and the data file can be implemented using a form such as TsFile. The specific names mentioned above are only used to illustrate possible implementation methods and do not constitute a limitation on the specific implementation form of each node, module, and data file.

[0135] This implementation method is illustrated by taking the example of changing the data type of the target time series from a first logical data type to a second logical data type.

[0136] Specifically, such as Figure 3 As shown, data type change processing may include the following steps.

[0137] Step 310: Receive data type change request.

[0138] In one implementation, the time series database receives a data definition statement submitted by a client or user, which requests that the first logical data type of the target time series be changed to a second logical data type.

[0139] For example, the data definition statement can be a data type change statement of type ALTER TIMESERIES, and can include the identification information of the target time series and a second logical data type. The target time series can be identified by a combination of sequence path, time series identifier, device identifier and measurement point identifier, or other information that can uniquely identify the target time series.

[0140] For example, a data type change request can be used to request a change of the data type of the target time series from INT32 to INT64.

[0141] Step 320: Verify the data type change request.

[0142] Upon receiving a data type change request, the data management node verifies the validity of the data type change request.

[0143] In one implementation, the verification may include at least one of the following: path verification of the target time series, permission verification, and type conversion relationship verification. For example, the data management node may determine whether the target time series exists, whether the requester has permission to modify the data type of the target time series, and whether a preset type conversion relationship exists between the first logical data type and the second logical data type.

[0144] Furthermore, a preset type conversion matrix can be used to characterize whether there are allowed type conversion relationships between different data types. For data type changes that satisfy the preset type conversion relationships, subsequent processing can continue; for data type changes that do not satisfy the preset type conversion relationships, the data type change request can be rejected.

[0145] By performing the above verification, it can be determined whether the data type change request meets the preset conditions before updating the metadata version corresponding to the target time series.

[0146] Step 330: Update the metadata version corresponding to the target time series.

[0147] Once the data type change request passes verification, the data management node updates the metadata version corresponding to the target time series to make the second logical data type effective.

[0148] In one implementation, the data management node can atomically submit changes to the metadata version corresponding to the target time series, thereby updating the metadata version corresponding to the target time series from the first metadata version corresponding to the first logical data type to the second metadata version corresponding to the second logical data type.

[0149] It should be noted that the metadata version mentioned above is used to characterize the effective status of the target time-series logical data type, and does not indicate that the corresponding SchemaVersion needs to be persistently stored in the historical physical data file. The actual physical data type in the historical physical data file can be determined based on its corresponding sequence attributes and other storage information.

[0150] By updating the metadata version, it can be determined that the second logical data type has become the currently effective logical data type for the target time series. Subsequent data writing and data querying can be based on the metadata version to determine the currently applicable second logical data type for the target time series.

[0151] Step 340: Publish type change to the data write node.

[0152] After the metadata version corresponding to the target time series is updated, the data management node will publish the updated metadata version to the data writing node.

[0153] In one implementation, in a distributed time-series database, a data management node can publish an updated version of the metadata to one or more data write nodes. The data write nodes can determine the currently effective second logical data type of the target time series based on the received metadata version, and update the data write status corresponding to the target time series accordingly.

[0154] For example, a data write node can maintain the current metadata version corresponding to the target time series and compare the received metadata version with the locally stored metadata version. When the received metadata version is updated, the data write node can determine that the data type of the target time series has changed and perform subsequent type barrier processing.

[0155] Step 350: Establish type barriers and process active memory tables.

[0156] Once it is determined at the data writing node that the data type of the target time series has changed from the first logical data type to the second logical data type, a type barrier can be established for the target time series.

[0157] Specifically, the data writing node can cause the active memory table that is currently storing the data corresponding to the first logical data type to stop receiving new data written to the target time series, and trigger the flushing process of the active memory table, so that the target time series data already written therein can form a historical physical data file.

[0158] In one implementation, the active memory table may include target time-series data written according to a first logical data type that has not yet formed a historical physical data file. After a type barrier is established, no new data is written to the active memory table for the target time series.

[0159] In one implementation, the active memory table can be used as a whole for flushing. When the data type of the target time series changes, the entire active memory table containing the target time series can be converted to an immutable state and flushed, while a new active memory table is created. Thus, the write boundary before and after the data type change of the target time series can be defined by switching the active memory table.

[0160] Step 360: Receive the newly written data according to the second logical data type.

[0161] After establishing the type barrier, the data write node creates a new memory table corresponding to the second logical data type to receive new write data generated by the target time series after the data type change.

[0162] In one implementation, the data writing node can perform corresponding data type verification, encoding, and writing processing on the newly written data of the target time series according to the currently effective second logical data type, and write the processed data into a new memory table.

[0163] For example, when the data type of the target time series is changed from INT32 to INT64, the data that has already entered the active memory table before the type barrier is established continues to be stored according to the physical data type corresponding to INT32; the new data written after the type barrier is established enters the new memory table corresponding to the second logical data type and is stored according to the physical data type corresponding to the second logical data type.

[0164] Step 370: Retain historical physical data files.

[0165] After the active memory table is flushed, a historical physical data file is created. The historical physical data file retains the physical data type it used when it was created, without requiring an immediate physical data type conversion when a data type change is completed.

[0166] For example, when the data type of the target time series changes from INT32 to INT64, the historical physical data files formed before the type barrier was established can continue to be stored using the physical data type corresponding to INT32, while the new data after the type change will be stored using the physical data type corresponding to INT64.

[0167] In one implementation, the sequence attributes corresponding to the historical physical data file may include the actual physical data type it uses. During subsequent data queries, the physical data type can be retrieved and compared with the currently active second logical data type to determine whether type adaptation is required for the corresponding data.

[0168] Therefore, the logical data type currently in effect for the target time series can remain different from the physical data type used in the historical physical data files that have already been formed, without having to rewrite the historical physical data files synchronously when the data type changes.

[0169] Step 380: Perform query adaptation and merging processing based on metadata version.

[0170] After the data type change is completed, the historical physical data file can continue to participate in data querying and background merging processing.

[0171] In one implementation, when a data query node receives a query request for a target time series, it can determine the currently effective second logical data type of the target time series based on the updated metadata version.

[0172] For historical physical data files identified during the query process, the data query node further obtains the physical data type corresponding to the historical physical data file and compares the physical data type with the second logical data type to determine whether type adaptation is required.

[0173] When the physical data type of the historical physical data file is consistent with the second logical data type, the corresponding data can be read and processed directly according to the second logical data type. When the two are inconsistent and there is a corresponding type conversion relationship, type adaptation can be performed in the data reading path to convert the data read from the historical physical data file into the second logical data type before providing it to subsequent query processing.

[0174] In one implementation, the physical data type corresponding to the historical physical data file can be determined through the sequence attributes of the historical physical data file, whereby the sequence attributes include data type information of the target time series. Therefore, the data query node can determine the appropriate data reading and type adaptation method based on the type relationship between the actual data type corresponding to the historical physical data file and the currently effective second logical data type.

[0175] In one implementation, type adaptation can be performed by a type adaptation iterator set in the data read iteration path. The type adaptation iterator can be connected to the original read iterator used to read historical physical data files, so that the physical type data output by the original read iterator is processed by the type adaptation iterator before being provided to subsequent query operators.

[0176] In one implementation, when performing a filtering query, the data query node can also determine whether the filtering conditions can be pushed down to the data reading layer based on the type relationship between the physical data type of the historical physical data file and the target comparison type corresponding to the filtering conditions.

[0177] When pushdown is possible, the comparison operands in the filter conditions can be converted into a form compatible with the physical data type, and the converted filter conditions can be pushed down to the data reading layer to perform comparisons based on the physical data in the historical physical data file; when pushdown is not possible, type adaptation and filtering can be performed after reading the corresponding data.

[0178] In one implementation, when performing query filtering, the data query node can also obtain the data block statistics information corresponding to the historical physical data file, and determine whether the statistical semantics of the data block statistics information under the second logical data type is valid based on the type relationship between the physical data type and the second logical data type.

[0179] When the statistical semantics are valid, data block-level filtering and pruning can be performed using data block statistics; when the statistical semantics are invalid, the corresponding data block pruning based on data block statistics is prohibited, and data details are read for filtering and judgment.

[0180] In one implementation, the merge processing module can perform merge processing on multiple data files, including historical physical data files, in the background.

[0181] During the merge process, the merge processing module can identify the physical data type of the data files to be merged and determine the corresponding data processing method based on the second logical data type currently in effect for the target time series.

[0182] For data files whose physical data type is consistent with the second logical data type, they can be read and reassembled according to the corresponding merging process; for data files whose physical data type still corresponds to the first logical data type, the corresponding data can be converted to the second logical data type during the merging process, and the target merged data file can be generated based on the converted data.

[0183] Furthermore, when generating the target merged data file, the corresponding data block metadata can be regenerated based on the data after being converted to the second logical data type, and the data block statistics corresponding to the data block can be redefined so that the data block metadata and data block statistics correspond to the second logical data type.

[0184] For example, for historical data stored using the INT32 physical data type, after converting it to INT64 during the merging process, the corresponding data block statistics can be re-determined based on the converted INT64 data, and a target merged data file using the INT64 physical data type can be generated.

[0185] Through steps 310 to 380 above, when the data type of the target time series changes, the metadata management node determines the effective status of the second logical data type by updating the metadata version. The data writing node establishes a type barrier based on the updated metadata version to form the write boundary before and after the data type change. The data before the type barrier is flushed to form a historical physical data file that retains the original physical data type, and the new data written after the type barrier enters the new memory table corresponding to the second logical data type.

[0186] For existing historical physical data files, the data query node determines the currently effective second logical data type based on the updated metadata version when executing the query, and performs the corresponding type adaptation based on the type relationship between the actual physical data type corresponding to the historical physical data file and the second logical data type; the merging module can then gradually convert the historical data into the physical data type corresponding to the second logical data type during the background merging process.

[0187] Therefore, during the transition phase following a data type change, the same target time series can simultaneously contain data with different physical data types, while the database can still provide a unified second logical data type semantic based on the current metadata version. Historical physical data files do not need to be physically rewritten immediately upon metadata version updates. Instead, query-side type adaptation and statistical validity checks can ensure that historical data participates in queries according to the current logical data type, and subsequent merging processes gradually achieve convergence of physical data types.

[0188] like Figure 4 As shown, this embodiment further illustrates the write path and background merge path of the time series database after a data type change. The write path is used to determine whether the active memory table matches the current data type based on the currently effective metadata version of the target time series, and to establish a type barrier if there is a mismatch. The background merge path is used to perform type conversion on historical physical data that still uses the old physical data type during the normal data file merging process, and to generate new data files, thereby gradually achieving convergence of physical data types.

[0189] Step 410: Receive write request.

[0190] In one implementation, a data node receives a write request for a target time series. The write request may include information such as the target time series' identifier, timestamp, and field values ​​to be written.

[0191] Step 420: Determine the data type status of the active memory table.

[0192] Upon receiving a write request, the data write node determines the active memory table corresponding to the target time series and the data type status corresponding to the active memory table. It then compares the data type status with the second logical data type corresponding to the currently effective metadata version of the target time series.

[0193] If the data type corresponding to the active memory table is consistent with the currently effective second logical data type, proceed to step 430; if they are inconsistent, proceed to steps 440 and 450.

[0194] Step 430: Write to the currently active memory table.

[0195] When it is determined that the active memory table corresponds to the currently effective second logical data type, the data writing node performs data type verification and encoding on the field values ​​in the write request according to the second logical data type, and writes the processed field values ​​into the active memory table.

[0196] Step 440: Isolate and flush the old active memory table.

[0197] When it is determined that the active memory table still corresponds to the first logical data type, it indicates that there is still data written according to the first logical data type in the active memory table.

[0198] At this point, the data writing node establishes a type barrier for the target time series, preventing the active memory table from receiving new data written to the target time series, and performs a flushing process on the data already written to form a historical physical data file.

[0199] When an active memory table is shared by multiple time series, a type barrier can be established only for the target time series; other time series that have not undergone data type changes can continue to be written to. If the active memory table is flushed as a whole, the entire active memory table can be switched to an immutable state and flushed.

[0200] Step 450: Create a new active memory table.

[0201] After isolating the target time series from the old active memory table, the data write node creates a new active memory table corresponding to the currently effective second logical data type.

[0202] For subsequent write requests generated for the target time series, the corresponding data type verification and encoding are performed according to the second logical data type, and the processed data is written to the new active memory table.

[0203] Therefore, the data before and after the type change forms a clear data type boundary during the write phase, without changing the physical data representation of the data already written to the old active memory table.

[0204] In one implementation, historical physical data files (TsFiles) whose data types have changed can continue to participate in normal background compaction. During the compaction of multiple data files, the background compaction module can identify the physical data types of the data being merged and perform type conversion on data whose physical data types are inconsistent with the currently effective second logical data type.

[0205] Step 460: Read historical physical data and data block metadata.

[0206] The background merging module determines the data files to be merged and reads the corresponding data blocks and data block metadata (ChunkMetadata).

[0207] In one implementation, the data type of the corresponding data can be determined based on the sequence attributes of the data file, and its actual physical data type can be determined accordingly. Data block metadata may also include information such as data block statistics corresponding to the data block.

[0208] Step 470: Convert the data according to the second logical data type.

[0209] The background merging module reads data whose physical data type is inconsistent with the second logical data type, and determines the data conversion method based on the currently effective second logical data type and the preset type conversion relationship.

[0210] For example, for historical data stored using the INT32 physical data type, when the second logical data type currently in effect for the target time series is INT64, the read INT32 data can be converted to INT64 data, and a new data block can be generated based on the converted data.

[0211] Step 480: Generate new data block metadata.

[0212] The background merging module writes the transformed data into a new data file and regenerates the corresponding data block metadata based on the transformed data.

[0213] In one implementation, during the transition phase of data type change, for data of different physical data types, the data block statistics can be uniformly processed according to the data type information of the corresponding data. When it is determined from the data type information in the metadata that the physical data type of the data to be processed is inconsistent with the physical data of the newly generated data type, the data block statistics corresponding to the old data type can be adapted according to the type conversion relationship between the first logical data type and the second logical data type. The adapted data block statistics are then merged with the data block statistics corresponding to the new data type to obtain the updated data block statistics.

[0214] In one implementation, the aforementioned statistical information processing can occur during the background merging process of data files. For example, when performing merging processing on multiple data files, if some of the data involved in the merging uses the physical data type corresponding to a first logical data type and another part of the data uses the physical data type corresponding to a second logical data type, the data block statistics of the corresponding data blocks can be obtained separately, and then merged after being unified to the second logical data type to obtain the data block statistics corresponding to the merged data blocks.

[0215] In another implementation, the above-mentioned statistical information processing can also occur when some old data types have not yet been completely flushed. For example, if there is still data in memory written according to the first logical data type that has not yet been fully flushed to disk, while there is already a data file on disk formed according to the second logical data type, the type difference between the memory data and the disk data can be determined based on the data type information in the metadata. Then, the statistical information corresponding to the memory data and the statistical information corresponding to the disk data can be adapted and merged accordingly to obtain updated statistical information corresponding to the current second logical data type.

[0216] For example, when the data type of the target time series is changed from INT32 to INT64, if there is still INT32 data in memory that has not yet been flushed, and there is already a data file on the disk that uses the INT64 physical data type, the statistical information corresponding to the INT32 data can be adapted to the statistical information corresponding to INT64 and merged with the statistical information corresponding to the INT64 data to update the corresponding data block statistical information.

[0217] By using the above method, even when data before and after the data type change are represented by different physical data types, different types of data can still be identified based on the data type information in the metadata, and the corresponding statistical information can be processed uniformly. This allows the updated data block statistical information to reflect the data range and statistical status after the merger of different types of data.

[0218] Step 490: Complete the replacement of the old and new data files.

[0219] After the new data file is written, the background merging module incorporates the new data file into the currently available data file set and removes the historical physical data files that have been replaced from the currently available data file set.

[0220] In one implementation, the replacement of the aforementioned data files can be achieved by atomically updating the metadata corresponding to the data file list, so that the data query process can maintain the consistency of the data file set during the data file replacement process.

[0221] Through steps 460 to 490 above, during the normal background merging process, historical data that still uses the first logical data type corresponding to the physical data type can be converted into physical data corresponding to the second logical data type, and the convergence of the historical data physical data type is gradually achieved by generating new data files.

[0222] like Figure 5 As shown, Figure 5This invention illustrates a process in which a data query node performs dynamic type adaptation and filtering pruning when querying historical physical data files, according to one embodiment of the present disclosure. This process determines the appropriate data reading and query processing method based on the type relationship between the currently effective second logical data type and the physical data type of the historical physical data file.

[0223] Step 510: Obtain the target logical data type and physical data type.

[0224] In one implementation, after receiving a query request for a target time series, the data query node determines the second logical data type corresponding to the target time series based on the currently effective metadata version, and determines the historical physical data file and its physical data type corresponding to the query request.

[0225] The physical data type can be determined based on the file-level metadata, chunk metadata, or other associated descriptive information of the historical physical data file.

[0226] Step 520: Determine if the types are consistent.

[0227] The data query node compares the physical data type corresponding to the historical physical data file with the second logical data type. If they match, proceed to step 530; if they do not match, proceed to the corresponding processing in steps 540 to 560.

[0228] Step 530: Read the data directly according to the second logical data type.

[0229] When the physical data type of the historical physical data file is consistent with the second logical data type, the data query node does not need to perform additional type conversion and can read and process the corresponding data according to the second logical data type.

[0230] For example, for historical physical data files that have been converted to the second logical data type through background merging processing, the corresponding data can be read directly according to the second logical data type.

[0231] Step 540: Change the filter conditions and perform filter pushdown.

[0232] When the physical data type of the historical physical data file is inconsistent with the second logical data type, and the query request contains filtering conditions, the data query node can determine whether the filtering conditions can be converted into comparison conditions compatible with the physical data type based on the conversion relationship between the physical data type of the historical physical data file and the target comparison type corresponding to the filtering conditions.

[0233] When a corresponding conversion relationship can be established, the comparison operands in the filter conditions can be converted into a form that matches the physical data type, and the converted filter conditions can be pushed down to the data reading layer so that the comparison can be performed directly using the physical data; when a compatible comparison relationship cannot be established, the filter conditions can be pushed down without performing the filter conditions, and subsequent type adaptation and filtering processing can be performed after reading the necessary data.

[0234] For example, when the target logical data type is DOUBLE and the physical data type of the historical data block is INT32, for filtering conditions such as value>1, the comparison conditions can be converted into comparison conditions applicable to the physical data type according to the preset conversion relationship, and then pushed down to the data reading layer for execution.

[0235] Step 550: Perform dynamic type adaptation using the type adaptation iterator.

[0236] In one implementation, when the physical data type of the historical physical data file is inconsistent with the second logical data type, a type adapter iterator can be set in the data reading iteration path.

[0237] The type-adaptive iterator is connected to the original read iterator used to read historical physical data files. It receives the physical type data output by the original read iterator and converts the physical type data into data of the second logical data type according to the preset type conversion relationship before providing it to the subsequent query operator.

[0238] Type conversion can be performed on a record-by-record basis or at a preset data processing granularity during data reading, without modifying the historical physical data file. For example, for historical data stored using the INT32 physical data type, when the second logical data type is INT64, the read INT32 data can be converted to INT64 data before participating in subsequent query processing.

[0239] Step 560: Evaluate the comparative semantic validity of the statistical information.

[0240] In one implementation, the data query node can also obtain data block statistics corresponding to historical physical data files or data blocks, and determine whether the data block statistics have valid comparison semantics under the second logical data type based on the type conversion relationship between the physical data type of the historical physical data file and the second logical data type.

[0241] When valid comparison semantics exist, data block statistics can be used to perform block-level or file-level filtering and pruning to skip data blocks or files that do not meet the query conditions. For example, for numeric type broadening transformations that do not change the data size relationship, range filtering can still be performed using minimum, maximum, and other statistical information.

[0242] When there is no valid comparison semantics, filtering and pruning are not performed based on the corresponding statistical information. Instead, the necessary data details are read, and the type adaptation iterator performs type adaptation before querying and judging.

[0243] For example, when the physical data type of a historical physical data file is a numeric type and the second logical data type is a text type, the minimum and maximum values ​​corresponding to the original numeric type may not reflect the comparison order under the text type. Therefore, it is possible to prohibit the use of corresponding statistical information for filtering and pruning to avoid erroneously excluding data blocks containing target data.

[0244] Step 570: Output the query results that match the second logical data type.

[0245] In one implementation, for data in historical physical data files, whether read directly or used for query processing after type adaptation, the data query node provides query results to subsequent query operators or clients according to the currently effective second logical data type.

[0246] When the same query range covers data formed before and after the data type change, the data query node can read data with different physical data types respectively, and perform type adaptation on historical data whose physical data type is inconsistent with the second logical data type, so that data with different physical representations can participate in the same query process according to a unified second logical data type.

[0247] Step 580: The server handles the type differences.

[0248] In one implementation, the identification of the physical data type of historical physical data files, type adaptation, filtering condition pushback, and comparative semantic judgment of data block statistics can all be completed by the data query node on the server side. Therefore, the client can directly obtain query results according to the currently effective second logical data type of the target time series without needing to know the actual physical data type used in the historical physical data files.

[0249] Therefore, this implementation method sets up a dynamic type adaptation mechanism in the data reading path and determines the usage of data block statistics under the filtering conditions by combining the type conversion relationship. This allows historical physical data files to participate in query processing according to the currently effective second logical data type without having to immediately modify their physical storage form due to changes in logical data type.

[0250] like Figure 6 As shown, Figure 6 This disclosure illustrates a process in which a time-series database determines the aggregation processing method based on data block statistics and data type relationships when processing aggregation queries. This process addresses situations where the target time series contains data blocks of different physical data types. If the data block statistics can be used to determine the local aggregation result, the statistics are used directly; otherwise, necessary data is read and type adaptation is performed during the reading process.

[0251] Specifically, such as Figure 6 As shown, aggregate query processing may include the following steps.

[0252] Step 610: Receive the aggregate query request.

[0253] In one implementation, a data query node receives an aggregation query request for a target time series. The aggregation query request may include an aggregation function and a corresponding query range.

[0254] For example, aggregate functions may include at least one of COUNT, SUM, MIN, and MAX.

[0255] Step 620: Determine the data type and data block statistics.

[0256] Upon receiving an aggregation query request, the query planner determines the second logical data type corresponding to the target time series based on the currently effective metadata version, and determines the data blocks to be processed within the query range, their physical data types, and data block statistics.

[0257] When the query range includes data before and after the data type change, different data blocks can correspond to different physical data types, so the corresponding aggregation processing method can be determined for each data block.

[0258] Step 630: Determine whether the local aggregation result can be determined based on the data block statistics.

[0259] The query planner determines whether the local aggregation result of the corresponding data block can be directly determined based on the data block statistics, according to the aggregation function, data block statistics, the type relationship between the physical data type and the second logical data type of the data block, and the query filtering conditions.

[0260] If the local aggregation result can be determined, proceed to step 640; otherwise, proceed to step 650.

[0261] In one implementation, when the filtering conditions cannot be accurately determined by the data block statistics, or when the corresponding statistics do not have valid comparison semantics under the second logical data type, the local aggregation result can be determined without relying on the data block statistics, and the detailed data processing path can be entered.

[0262] Step 640: Generate local aggregation results based on data block statistics.

[0263] When it is determined that the local aggregation result can be determined based on the data block statistics, the data query node reads the corresponding data block statistics without having to read all the detailed data in that data block.

[0264] For example, data block statistics can include at least one of the following: data volume, summation, minimum value, and maximum value. For COUNT aggregation, the local count result can be determined based on the data volume that meets the query conditions; for SUM, MIN, or MAX aggregations that meet preset conditions, the local aggregation result can also be determined based on the corresponding statistical information.

[0265] When the physical data type of a data block is inconsistent with the second logical data type, the aggregation result corresponding to the statistical information can be adapted to the second logical data type and then participate in subsequent aggregations according to the preset type conversion relationship.

[0266] For example, when historical data is stored using the INT32 physical data type and the second logical data type is INT64, the local aggregated values ​​obtained based on statistical information can be adapted to INT64 and then participate in the final aggregation without having to read and convert all the INT32 detailed data in the historical data block.

[0267] Step 650: Read the necessary data and update the aggregated cumulative state.

[0268] When the local aggregation result cannot be determined directly based on the statistical information of the data block, the data query node reads the necessary data in the corresponding data block and performs type adaptation according to the type conversion relationship between the physical data type and the second logical data type during the data reading process.

[0269] Furthermore, the adapted data can be directly provided to the accumulator corresponding to the second logical data type, and the accumulator can update the aggregation and accumulation state according to the aggregation function.

[0270] For example, for SUM aggregation, the sum value can be updated based on the adapted data; for MIN or MAX aggregation, the current minimum or maximum value can be updated based on the adapted data.

[0271] In one implementation, when a query request contains filtering conditions, the data to be read can be filtered according to the filtering conditions first, and then the data that meets the filtering conditions can be type-adapted and provided to the aggregator.

[0272] Step 660: Merge the partial aggregation results and output the query results.

[0273] The data query node merges the local aggregation results obtained based on data block statistics and the aggregation accumulation status obtained by reading detailed data to determine the final aggregation result corresponding to the target time series, and outputs it according to the currently effective second logical data type.

[0274] When the query range includes data before and after the data type change, the corresponding aggregation processing method can be applied to data blocks with different physical data types, and the obtained local aggregation results can be merged.

[0275] For example, for data blocks whose local aggregation results can be determined using data block statistics, the local aggregation results can be directly used to participate in the final aggregation; for data blocks whose data block statistics cannot be used, the necessary detailed data is read, the aggregation accumulation status is updated after type adaptation, and finally the results obtained from different processing paths are merged.

[0276] Through steps 610 to 660 above, after a data type change occurs in the target time series, appropriate aggregation processing paths can be selected for data blocks of different physical data types: when the statistical information of the data block meets the aggregation processing conditions, the local aggregation result is obtained directly using the statistical information; otherwise, the necessary data is read and type adaptation is completed during the reading process, and then the aggregation status is updated through the aggregation accumulator. Thus, while maintaining consistent query semantics before and after data type changes, unnecessary reading of historical detailed data and type conversions can be reduced.

[0277] In this disclosure, a data type change processing apparatus for a time-series database is also provided. For example... Figure 7 As shown, the data type change processing device 700 can be deployed in a time-series database and used to execute the data type change processing method of any of the above embodiments.

[0278] like Figure 7 As shown, the data type change processing device 700 includes: a change request receiving module 710, a version update module 720, a write barrier establishment module 730, and a data read adaptation module 740.

[0279] The change request receiving module 710 is used to obtain a data type change request for the target time series, and the data type change request is used to change the first logical data type of the target time series to the second logical data type. Version update module 720 is used to update the metadata version corresponding to the target time series in response to a data type change request, so that the second logical data type takes effect; The write barrier establishment module 730 is used to establish a type barrier for the target time series based on the updated metadata version, and to isolate data writes before and after the data type change according to the type barrier; The data reading adaptation module 740 is used to respond to the query request of the target time series, determine the second logical data type according to the updated metadata version, and perform type adaptation on the data read from the historical physical data file according to the type relationship between the physical data type corresponding to the historical physical data file and the second logical data type.

[0280] The specific implementation methods of each module are explained below.

[0281] In one implementation, the change request receiving module 710 is used to obtain a data type change request for the target time series, the data type change request being used to change the first logical data type of the target time series to a second logical data type.

[0282] In one embodiment, the change request receiving module 710 is further configured to perform a validity check on the data type change request to determine whether the data type change request meets the preset data type change conditions.

[0283] For example, the change request receiving module 710 can verify the data type change request based on the type conversion relationship between the first logical data type and the second logical data type; when there is a preset type conversion relationship between the first logical data type and the second logical data type, the data type change request can be determined to pass the verification; otherwise, the data type change request can be rejected.

[0284] The above method allows for the validation of data type change requests before data type changes are executed, to determine whether the corresponding data type change is permitted.

[0285] In one implementation, the version update module 720 is used to update the metadata version corresponding to the target time series in response to a data type change request that has passed the validity check, so that the second logical data type takes effect.

[0286] In one implementation, the version update module 720 can atomically submit the metadata version change corresponding to the target time series, so that the metadata version corresponding to the target time series is updated from the metadata version corresponding to the first logical data type to the metadata version corresponding to the second logical data type.

[0287] In one implementation, the version update module 720 is further configured to publish the updated metadata version to one or more data write nodes, so that the data write nodes can determine the second logical data type currently in effect for the target time series based on the updated metadata version.

[0288] Therefore, the effective status of data type changes can be determined by updating the metadata version, and the data writing nodes can perform subsequent data writing processes based on the updated metadata version.

[0289] In one implementation, the write barrier establishment module 730 is used to determine, based on the updated metadata version, that the data type of the target time series has changed from a first logical data type to a second logical data type, and to establish a type barrier for the target time series.

[0290] In one implementation, the write barrier establishment module 730 can obtain the active memory table currently corresponding to the target time series and determine the type version corresponding to the active memory table; when the type version corresponding to the active memory table is inconsistent with the currently effective metadata version, it can be determined that the active memory table still corresponds to the first logical data type, and a type barrier is established for the target time series.

[0291] In one implementation, the write barrier establishment module 730 can cause the active memory table storing data corresponding to the first logical data type to stop receiving new write data of the target time series, and perform a flushing process on the target time series data in the active memory table to form a historical physical data file. The historical physical data file can continue to be stored using the physical data type it was created with.

[0292] In one implementation, the write barrier establishment module 730 is further configured to create a new memory table corresponding to the second logical data type to receive new write data generated by the target time series after the data type change.

[0293] Therefore, the write barrier establishment module 730 can form a write boundary before and after the data type change of the target time series, so that the data before the data type change continues to be persisted according to the physical data type corresponding to the first logical data type, and the new write data after the data type change is written to a new memory table according to the second logical data type.

[0294] In one implementation, the data reading adaptation module 740 is used to determine the currently effective second logical data type based on the updated metadata version when the target time series is queried, and to obtain the physical data type corresponding to the historical physical data file involved in the query process; when the physical data type is inconsistent with the second logical data type and there is a preset type conversion relationship, the data in the historical physical data file is adapted.

[0295] In one implementation, the data read adaptation module 740 can perform type adaptation via a type adapter iterator set in the data read iteration path. The type adapter iterator is connected to the original read iterator used to read historical physical data files, and is used to convert the physical type data output by the original read iterator into data of a second logical data type, and provide it to subsequent query processing.

[0296] In one implementation, the data reading adaptation module 740 is further configured to, for a query containing filtering conditions, determine whether the filtering conditions can be converted into a form compatible with the physical data type based on the conversion relationship between the physical data type of the historical physical data file and the target comparison type corresponding to the filtering conditions, and push the converted filtering conditions to the data reading layer.

[0297] In one implementation, the data reading adaptation module 740 is further configured to obtain data block statistics information corresponding to historical physical data files or their data blocks, and determine whether the data block statistics information has comparative semantic validity under the second logical data type based on the type conversion relationship between the physical data type of the historical physical data file and the second logical data type; when it has comparative semantic validity, it performs data block-level or data file-level filtering and pruning based on the data block statistics information; when it does not have comparative semantic validity, it prohibits performing corresponding filtering and pruning based on the data block statistics information.

[0298] In one implementation, the data reading adaptation module 740 is further configured to, for an aggregation query, determine whether a local aggregation result for the corresponding data block can be directly generated based on the data block statistics and the statistical semantics corresponding to the aggregation operation; if a local aggregation result can be directly generated, the local aggregation result is generated based on the data block statistics; if a local aggregation result cannot be directly generated, the necessary data is read, and the read physical type data is converted into a second logical data type and provided to the aggregation accumulator to update the aggregation state.

[0299] In one implementation, the data reading adaptation module 740 is also used to perform merging processing on multiple data files, including historical physical data files, during the background merging process; for data that still uses the first logical data type corresponding to the physical data type, it is converted to the second logical data type during the merging process, and the target merged data file, as well as the corresponding data block metadata and data block statistics information, are generated based on the converted data.

[0300] Therefore, the data reading adaptation module 740 can perform corresponding type adaptation processing for historical data query reading, filtering and pruning, aggregation processing and background merging respectively, so that historical physical data files do not need to be physically rewritten immediately when the data type changes, and can participate in subsequent processing according to the currently effective second logical data type.

[0301] In one implementation, the data reading adaptation module 740 can also perform subsequent query processing on the historical data after type adaptation based on the currently effective second logical data type of the target time series, and output the query results according to the second logical data type. For query requests that simultaneously include data before and after the data type change, the data reading adaptation module 740 can process data with different physical data types separately, and then uniformly adapt them to the second logical data type before participating in the query processing.

[0302] It should be noted that the aforementioned change request receiving module 710, version update module 720, write barrier establishment module 730, and data reading adaptation module 740 can be implemented by independent hardware circuits, software modules, or combined hardware and software processing modules, or can be implemented by multiple nodes in collaboration depending on the specific deployment method of the time series database. This disclosure does not make any specific limitations in this regard.

[0303] The processing performed by each of the above modules corresponds to the corresponding processing procedures in the aforementioned method embodiments. The specific implementation methods can be found in the aforementioned method embodiments, and will not be repeated here.

[0304] Those skilled in the art will understand that the various embodiments of this disclosure can be implemented as systems, methods, apparatuses, electronic devices, or computer program products. Therefore, the various modules, units, apparatuses, or platforms in this disclosure can be implemented in a completely hardware manner, a completely software manner (including firmware, executable program instructions stored in memory, microcode, etc.), or a hardware-software co-implementation manner, and used to perform corresponding data processing operations.

[0305] Based on the same inventive concept, this disclosure also provides an electronic device, which includes: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the method described above by executing the executable instructions. Since the principle by which this electronic device embodiment solves the problem is similar to that of the above method embodiments, the implementation of this electronic device embodiment can refer to the implementation of the above method embodiments, and repeated details will not be described again.

[0306] Based on the same inventive concept, this disclosure also provides an electronic device, which is described below with reference to... Figure 8This invention describes an electronic device 800 according to an embodiment of the present disclosure. The electronic device 800 includes a processor (processing unit) 810 and a memory (storage unit) 820 for storing executable instructions of the processor. In specific time-series database application scenarios, the electronic device 800 can be embodied as a time-series database server, a data management node, a data writing node, or a data query node in a time-series database cluster, or a database computing device integrating data type change processing functions.

[0307] like Figure 8 As shown, the electronic device 800 is presented in the form of a general-purpose computing device. The components of the electronic device 800 may include, but are not limited to: at least one processing unit 810, at least one storage unit 820, a bus 830 connecting different system components (including storage unit 820 and processing unit 810), a display unit 840, etc.

[0308] The storage unit stores program code, which can be executed by the processing unit 810 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure. For example, the processing unit 810 can perform the above-described steps. Figure 1 The steps of the method shown.

[0309] Storage unit 820 may include readable media in the form of volatile storage units, such as random access memory (RAM) 821 and / or cache memory 822, and may further include read-only memory (ROM) 823.

[0310] The storage unit 820 may also include a program / utility 824 having a set (at least one) of program modules 825, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.

[0311] Bus 830 can represent one or more of several bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures. Electronic device 800 can also communicate with one or more external devices 870 (e.g., keyboard, pointing device, Bluetooth device, etc.), and with one or more devices that enable user interaction with electronic device 800, and / or with any device that enables electronic device 800 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed through input / output (I / O) interface 850. Furthermore, electronic device 800 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 860. As shown, network adapter 860 communicates with other modules of electronic device 800 via bus 830. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0312] In some embodiments, this disclosure also provides a computer program product, which includes a computer program that, when executed by a processor, implements the data type change processing method in the time-series database described above.

[0313] In some embodiments, this disclosure also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the data type change processing method in the time-series database described above.

[0314] Computer-readable storage media can be readable signal media or readable storage media. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), USB flash drive, portable hard disk, optical storage device, magnetic storage device, or any suitable combination of the foregoing.

[0315] Furthermore, computer-readable storage media may also include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof.

[0316] A readable signal medium can be any readable medium other than a readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. Optionally, program code contained on a computer-readable storage medium can be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.

[0317] In practical implementation, program code for performing the operations of this disclosure can be written in any combination of one or more programming languages. These programming languages ​​include object-oriented programming languages—such as Java and C++—as well as conventional procedural programming languages—such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device.

[0318] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0319] Furthermore, although the steps of the method in this disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or a step may be broken down into multiple steps.

[0320] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the appended claims.

Claims

1. A method for handling data type changes in a time-series database, characterized in that, include: Obtain a data type change request for a target time series, wherein the data type change request is used to change the first logical data type of the target time series to a second logical data type; In response to the data type change request, update the metadata version corresponding to the target time series so that the second logical data type takes effect; Based on the updated metadata version, a type barrier is established for the target time series, causing the active memory table storing data corresponding to the first logical data type to stop receiving new data written to the target time series, and the data of the target time series in the active memory table is flushed to form a historical physical data file with a physical data type corresponding to the first logical data type, and a new memory table corresponding to the second logical data type is created so that the new data written after the type change enters the new memory table; In response to a query request for the target time series, the second logical data type is determined based on the updated metadata version, and the data read from the historical physical data file is type-adapted according to the type relationship between the physical data type corresponding to the historical physical data file and the second logical data type, so that the query result of the target time series conforms to the second logical data type.

2. The method for handling data type changes in a time-series database according to claim 1, characterized in that, Updating the metadata version corresponding to the target time series includes: After the data type change request is verified, the metadata version change corresponding to the target time series is submitted atomically, so that the metadata version is updated from the first metadata version corresponding to the first logical data type to the second metadata version corresponding to the second logical data type, so that the second metadata version becomes the updated metadata version.

3. The method for handling data type changes in a time-series database according to claim 1, characterized in that, The establishment of a type barrier for the target time series includes: When it is detected that there is data of the target time series written in the first logical data type in the active memory table but not yet flushed to disk, the writing of data of the target time series to the active memory table in the first logical data type is prevented, and the flushing process of the corresponding data in the active memory table is triggered.

4. The method for handling data type changes in a time-series database according to claim 1, characterized in that, The step of performing type adaptation on the data read from the historical physical data file based on the type relationship between the physical data type corresponding to the historical physical data file and the second logical data type includes: Obtain the physical data type corresponding to the historical physical data file; Compare the physical data type with the second logical data type; When the physical data type is inconsistent with the second logical data type and there is a corresponding type conversion relationship, type adaptation processing is inserted in the data reading path to convert the data read from the historical physical data file into the second logical data type.

5. The data type change processing method in a time-series database according to claim 4, characterized in that, The type adaptation process is performed by a type adaptation iterator set in the data reading iteration path. The type adaptation iterator is used to convert the data read from the historical physical data file into the second logical data type in memory without modifying the historical physical data file.

6. The method for handling data type changes in a time-series database according to claim 4, characterized in that, The data type change processing method also includes: In response to a query request for the target time series, filter conditions for the target time series are obtained, the filter conditions being constructed based on the second logical data type; Based on the type conversion relationship between the physical data type of the historical physical data file and the second logical data type corresponding to the filtering condition, it is determined whether the filtering condition can be pushed down to the data reading layer corresponding to the historical physical data file; When it is determined that the filtering condition can be pushed down, the comparison operands in the filtering condition are converted into a form compatible with the physical data type, and the converted filtering condition is pushed down to the data reading layer, so that the data reading layer performs a comparison with the physical data in the historical physical data file based on the converted filtering condition.

7. The method for handling data type changes in a time-series database according to claim 4, characterized in that, The data type change processing method also includes: In response to the query request of the target time series, obtain the data block statistics information corresponding to the historical physical data file; Based on the type relationship between the physical data type of the historical physical data file and the second logical data type, determine whether the statistical semantics represented by the data block statistical information remain valid under the second logical data type; When it is determined that the statistical semantics remain valid, block-level filtering and pruning are performed using the data block statistics. If it is determined that the statistical semantics are not valid, block-level filtering and pruning based on the data block statistics are prohibited, and the data details in the historical physical data file are read to perform filtering.

8. The method for handling data type changes in a time-series database according to claim 1, characterized in that, The data type change processing method also includes: Perform a merge process on multiple data files, including the aforementioned historical physical data file; Target historical files whose physical data type is the first logical data type; and In the merging process, the physical data in the target historical file is converted into the second logical data type, and a target merged data file with the second logical data type is generated based on the converted data.

9. The data type change processing method in a time-series database according to claim 8, characterized in that, The step of generating a target merged data file with the second logical data type based on the transformed data includes: Based on the data converted to the second logical data type, the data block metadata corresponding to the target merged data file is regenerated so that the data type represented by the data block metadata is consistent with the second logical data type.

10. The method for handling data type changes in a time-series database according to claim 9, characterized in that, The step of regenerating the data block metadata corresponding to the target merged data file based on the data converted to the second logical data type includes: Based on the data after conversion to the second logical data type, the corresponding data block statistics are re-determined so that the data block statistics correspond to the second logical data type.

11. A data type change processing device in a time-series database, characterized in that, include: The change request receiving module is used to obtain a data type change request for a target time series, wherein the data type change request is used to change the first logical data type of the target time series to a second logical data type; The version update module is used to update the metadata version corresponding to the target time series in response to the data type change request, so that the second logical data type takes effect; The write barrier establishment module is used to establish a type barrier for the target time series based on the updated metadata version, so that the active memory table storing the data corresponding to the first logical data type stops receiving new write data of the target time series, and the data of the target time series in the active memory table is flushed to form a historical physical data file with a physical data type corresponding to the first logical data type, and a new memory table corresponding to the second logical data type is created so that the new write data after the type change enters the new memory table; The data reading adaptation module is used to respond to the query request of the target time series, determine the second logical data type according to the updated metadata version, and perform type adaptation on the data read from the historical physical data file according to the type relationship between the physical data type corresponding to the historical physical data file and the second logical data type, so that the query result of the target time series conforms to the second logical data type.

12. A time-series database system, characterized in that, include: The data management node is configured to receive a data type change request for a target time series, the data type change request being used to change the first logical data type of the target time series to a second logical data type, and to update the metadata version corresponding to the target time series in response to the data type change request, so that the second logical data type takes effect; The data writing node is configured to establish a type barrier for the target time series based on the updated metadata version, causing the active memory table storing data corresponding to the first logical data type to stop receiving new written data of the target time series, and to flush the data of the target time series in the active memory table to form a historical physical data file with a physical data type corresponding to the first logical data type, and to create a new memory table corresponding to the second logical data type, so that the new written data after the type change enters the new memory table; The data query node is configured to respond to a query request for the target time series, determine the second logical data type based on the updated metadata version, and perform type adaptation on the data read from the historical physical data file according to the type relationship between the physical data type corresponding to the historical physical data file and the second logical data type, so that the query result of the target time series conforms to the second logical data type.

13. An electronic device, characterized in that, include: processor; as well as A memory in which executable instructions of the processor are stored; The processor is configured to execute the data type change processing method in the time-series database according to any one of claims 1 to 10 by executing the executable instructions.

14. A computer-readable storage medium for storing a program, characterized in that, When the program is executed, it implements the data type change processing method in the time-series database as described in any one of claims 1 to 10.

15. A computer program product having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the data type change processing method in the time-series database as described in any one of claims 1 to 10.