Method and device for storing time series data

By generating and saving the first data structure and the second data structure, the storage location recording of timing data is simplified, and the problem of low efficiency in timing data storage and query in the prior art is solved, thereby realizing more efficient data storage and query.

CN120045597APending Publication Date: 2025-05-27HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311585428.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-25
Publication Date
2025-05-27

AI Technical Summary

Technical Problem

The prior art is less efficient when storing and querying timing data, especially due to the high concurrent write and frequent query of timing data, the storage method is complicated and the efficiency is affected.

Method used

By generating the first data structure and the second data structure, recording the dimension values ​​and measurement values ​​of the timing data, recording of storage locations is simplified and query efficiency is improved. The specific method includes receiving time series data, generating data structures and storing, and quickly positioning the metric value through the data structure during query.

Benefits of technology

It simplifies the storage location recording of time-series data, improves the storage and query efficiency of time-series data, and reduces the query complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045597A_ABST
    Figure CN120045597A_ABST
Patent Text Reader

Abstract

The invention relates to the field of computers, and provides a method and a device for storing time series data. The method comprises the steps that first time sequence data and second time sequence data are received, the first time sequence data comprise a first index, a first dimension value and a first metric value, and the second time sequence data comprise a second index, a second dimension value and a second metric value; if the first index is the same as the second index and the first metric value is equal to the second metric value, a first data structure and a second data structure are generated according to the first time sequence data and the second time sequence data, the first data structure comprises a first dimension value, a second dimension value, a first identifier and a second identifier, and the first identifier is the same as the second identifier; the second data structure comprises a first identifier or a second identifier, and the second data structure further comprises a first metric value or a second metric value; and storing the first data structure and the second data structure. According to the method, the storage and query efficiency of the time series data can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to a method and device for storing time series data. Background Art

[0002] Time series data refers to a series of data that is continuously generated over time. th With the continuous development of 5G (5th Generation Mobile Communication Technology) and Internet of Things (IoT) technology, the amount of data has exploded. The application scenarios of time series data are very wide, including IoT, Internet of Vehicles, Industrial Internet, application performance monitoring and other common scenarios. In these scenarios, time series data can record key information such as the operating status, operation data and monitoring data of the equipment. By analyzing and processing time series data, it can help enterprises predict faults, optimize production, and provide support for enterprise decision-making.

[0003] The characteristics of time series data are that the frequency of data generation is fast and the data is continuously written with high concurrency. These characteristics lead to high requirements for storage methods for time series data. Some time series data have the same dimension value. For example, if the temperature of city A and city B are both 30 degrees, the time series data recording the temperature of city A and the time series data recording the temperature of city B can be stored together. One storage method is to use a dictionary, dimension code value and inverted index to record the storage location of the temperature of city A and city B. When you need to find the temperature of city A or city B, first find the city name in the dictionary, then find the dimension code value according to the city name, then find the inverted index according to the dimension code value, and then find the temperature value according to the inverted index. This storage method is relatively complicated, resulting in a decrease in the efficiency of saving and querying time series data. Summary of the invention

[0004] Embodiments of the present application provide a method, apparatus, computer-readable storage medium, and computer program product for storing time series data, which can improve the efficiency of storing and querying time series data.

[0005] In the first aspect, an embodiment of the present application provides a method for saving time series data, and the execution subject of the method can be an electronic device (such as a server) or a chip applied to an electronic device. The following description is based on the execution subject being a server as an example. The method includes: receiving first time series data and second time series data, the first time series data includes a first indicator, a first dimension value and a first measurement value, and the second time series data includes a second indicator, a second dimension value and a second measurement value; if the first indicator is the same as the second indicator, and the first measurement value is equal to the second measurement value, a first data structure and a second data structure are generated according to the first time series data and the second time series data, the first data structure includes a first dimension value, a second dimension value, a first identifier and a second identifier, the first identifier is the same as the second identifier, the second data structure includes the first identifier or the second identifier, and the second data structure also includes the first measurement value or the second measurement value; save the first data structure and the second data structure.

[0006] An indicator is, for example, temperature, a dimension is, for example, a city name, and a metric is, for example, a temperature value. If the first indicator is the same as the second indicator, and the first metric is equal to the second metric, it means that the first time series data and the second time series data can be merged and saved, and the server can generate the first data structure and the second data structure as described above. When querying time series data, whether querying the first dimension value or the second dimension value, the corresponding identifier can be obtained from the first data structure, and then the first metric or the second metric can be queried from the second data result based on the identifier obtained from the first data structure. Since there are only two data structures for recording the information of the storage location of time series data, the information of recording the storage location of time series data is simplified compared to the prior art, thereby improving the efficiency of saving and querying time series data.

[0007] Optionally, the method also includes: generating a multi-value primary key based on the first time series data and the second time series data, the multi-value primary key including a primary key identifier and a primary key value, the primary key identifier is the first identifier or the second identifier, the primary key value includes a first information set and a second information set, the first information set includes a first dimension value, and the second information set includes a second dimension value.

[0008] In some cases, in addition to displaying the metric values, it is also necessary to display the dimension values ​​related to the metric values. Centrally storing multiple dimension values ​​can reduce storage space occupancy (for example, the first information set and the second information set share a primary key identifier) ​​and improve query efficiency.

[0009] Optionally, the primary key value further includes: a type identifier, where the type identifier is used to indicate that the primary key value includes multiple information sets.

[0010] In addition to storing multi-valued primary keys, time series databases may also store single-valued primary keys. The structure and size of single-valued primary keys are different from those of multi-valued primary keys. Using type identifiers to distinguish multi-valued primary keys from single-valued primary keys is beneficial to the maintenance and use of multi-valued primary keys.

[0011] Optionally, the type identifier is located at the beginning of the primary key value.

[0012] The type identifier is located at the beginning of the primary key value, which can quickly determine whether the primary key value is a multi-valued primary key or a single-valued primary key, thereby improving the query efficiency of multi-valued primary keys.

[0013] Optionally, the primary key value also includes: quantity information, where the quantity information is used to indicate the quantity of information sets included in the primary key value.

[0014] The number of information sets of a multi-valued primary key is indefinite. If there is no quantity information, the entire multi-valued primary key needs to be read to determine the number of information sets included in the primary key value. Therefore, quantity information can improve the query efficiency of the multi-valued primary key.

[0015] Optionally, the quantity information is located before the first information set and the second information set.

[0016] The quantity information is located before the first information set and the second information set, so the number of information sets included in the primary key value can be determined as quickly as possible, thereby improving the query efficiency of the multi-value primary key.

[0017] Optionally, the primary key value further includes: first length information and second length information, the first length information is used to indicate the length of the first information set, and the second length information is used to indicate the length of the second information set.

[0018] The size of the information set of a multi-valued primary key is uncertain. Without length information, the server may not be able to determine which information belongs to the first information set and which information belongs to the second information set. Therefore, length information can improve the query accuracy of multi-valued primary keys.

[0019] Optionally, the first length information is located before the first information set and is adjacent to the first information set, and the second length information is located before the second information set and is adjacent to the second information set.

[0020] In this embodiment, the length information is adjacent to the information set and is located before the information set. After reading the length information, the server can directly read the adjacent information to obtain the information set without having to search for the location of the information set. Therefore, this embodiment can improve the query efficiency of multi-value primary keys.

[0021] Optionally, the method also includes: receiving a query instruction, the query instruction including a first dimension value and a second dimension value; determining a first identifier and a second identifier based on the first dimension value, the second dimension value and the first data structure; obtaining a target metric value based on the first identifier and the second data structure, the target metric value being the first metric value or the second metric value; saving the target metric value obtained from the second data structure in a buffer; and obtaining the target metric value from the buffer based on the second identifier.

[0022] During a query process, the metric value may need to be used multiple times. The second data structure is usually stored in the disk. The read and write rate of the disk is low, and the read and write efficiency of the buffer is high. Temporarily storing the metric value in the buffer can improve the execution efficiency of the query instruction.

[0023] Optionally, the method further includes: after the query instruction is executed, deleting the first metric value or the second metric value in the buffer.

[0024] After a query process is completed, the probability of the first metric value or the second metric value being used again in a short period of time is low, and the buffer is a storage area with limited space. Deleting the first metric value or the second metric value in the buffer after the query instruction is executed can improve the utilization rate of the buffer.

[0025] In a second aspect, an embodiment of the present application provides a device for storing time series data. The communication device may include an input unit and a processing unit, and is configured to execute any method in the first aspect and its optional implementations.

[0026] In a third aspect, an embodiment of the present application provides a device for storing time series data, which may be a server or a chip applied to a server. The device may include a processor for executing: any method in the first aspect and its optional implementation manners described above.

[0027] Optionally, the device may further include a transceiver. When the device is a server, the transceiver may be a transceiver circuit, an antenna, etc.; when the device is a chip applied to a server, the transceiver may be an input / output interface, a pin, a circuit, etc.

[0028] Optionally, the device may further include a memory, the memory being used to store instructions, and the processor executing the instructions stored in the memory so that the device executes any one of the methods in the first aspect and its optional implementations. When the device is a server, the memory may be a read-only memory, a random access memory, etc.; when the device is a chip applied to a server, the memory may be a register, a cache, etc.

[0029] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed on a computer, the computer executes any method in the first aspect and its optional embodiments.

[0030] In the fifth aspect, an embodiment of the present application provides a computer program product, which includes: computer program code or computer program instructions, when the computer program code or computer program instructions are executed by a computer, the computer executes any one of the methods in the first aspect and its optional embodiments.

[0031] The beneficial effects of the second to fifth aspects can refer to the beneficial effects of the first aspect and will not be elaborated on again. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 is a schematic diagram of a system applicable to an embodiment of the present application;

[0033] Figure 2 is a schematic diagram of a software architecture provided by an embodiment of the present application;

[0034] Figure 3 is a schematic diagram of a method for storing time series data provided by an embodiment of the present application;

[0035] Figure 4 is a schematic diagram of a method for querying time series data provided by an embodiment of the present application;

[0036] Figure 5 is a schematic diagram of a device for storing time series data provided by an embodiment of the present application;

[0037] Figure 6 It is a schematic diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0038] The technical solution in this application will be described below in conjunction with the accompanying drawings.

[0039] To facilitate understanding of the technical solutions of the embodiments of the present application, a brief introduction to the concepts involved in the embodiments of the present application is first given.

[0040] 1. Time series data.

[0041] Time series data refers to data of the same category and the same metric recorded in chronological order, representing data generated at a certain point in time. The characteristic of time series data is that each data has a timestamp. Time series data includes triples, which include a metric, a timestamp, and a metric value. Time series data can also include dimension values, which can also be called labels, and are used to describe different attributes or features. Taking the temperature sensor as an example, the time series data generated by the temperature sensor is shown in Table 1.

[0042] Table 1

[0043] index Timestamp City Numeric temperature 2023-1-1 00:00:01 beijing 28 temperature 2023-1-1 00:00:02 guangzhou 30 temperature 2023-1-1 00:00:02 shenzhen 30

[0044] In Table 1,<temperature,2023-1-1 00:00:01,beijing,28> ,<temperature,2023-1-100:00:02,guangzhou,30> and<temperature,2023-1-1 00:00:02,shenzhen,30> Represents three time series data, where temperature represents the name of the parameter recorded by the temperature sensor, that is, the indicator of the time series data; timestamps such as 2023-1-1 00:00:01 represent the moment corresponding to the temperature value recorded by the temperature sensor, that is, the timestamp of the time series data; city names such as beijing represent the characteristics or attributes corresponding to the temperature value recorded by the temperature sensor, that is, the dimension value of the time series data; 28 and 30 represent the specific values ​​of the temperature indicators recorded by the temperature sensor, that is, the measurement values ​​of the two time series data. It should be noted that the time series data in Table 1 are examples rather than limitations. Each time series data can also include more dimension values ​​or fewer dimension values. For example, when generating time series data, the temperature sensor can add the model of the temperature sensor as a dimension value in the time series data. In addition, the number of dimension values ​​of each time series data can be the same or different.

[0045] Based on the number of dimension values, time series data can be divided into single-value dimension data and multi-value dimension data. Single-value dimension data refers to time series data that includes one dimension value, such as the three time series data in Table 1. Multi-value dimension data refers to time series data that includes two or more dimension values. For example, in Table 1, the metric values ​​of the two time series data corresponding to guangzhou and shenzhen are the same. The two time series data can be merged and stored. The result after merging and storing is shown in Table 2.

[0046] Table 2

[0047] index Timestamp City Numeric temperature 2023-1-1 00:00:01 beijing 28 temperature 2023-1-1 00:00:02 guangzhou,shenzhen 30

[0048] In Table 2,<temperature,2023-1-1 00:00:01,beijing,28> and<temperature,2023-1-100:00:02,guangzhou,shenzhen,30> Represents two time series data, where<temperature,2023-1-100:00:01,beijing,28> Includes one dimension value (beijing), and the time series data is single-value dimension data;<temperature,2023-1-100:00:02,guangzhou,shenzhen,30> Including two dimension values ​​(guangzhou and shenzhen), this time series data is multi-value dimension data. The advantage of merged storage is that it reduces the space required to store time series data and saves storage costs.

[0049] The difference between time series data and other data is that time series data is more suitable for reflecting the process of data "change". After the values ​​in the time series data are connected into lines in the time coordinate, multi-dimensional reports can be formed. These reports can reveal the trend and regularity of the data, capture anomalies, and achieve prediction and early warning.

[0050] In recent years, the application of time series data has become more and more extensive. Time series data has been widely used in the fields of IoT, economic and financial fields, environmental monitoring, medicine, industrial manufacturing, agricultural production, and hardware / software system monitoring. The use of time series data can reveal the trends, laws, and anomalies of the research object. With the rise of artificial intelligence, the role of time series data as basic data in big data, machine learning, real-time prediction and early warning has become more prominent. Therefore, the research and application of time series data has become more in-depth and important.

[0051] For example, in the field of autonomous driving, the location of a vehicle changes over time, while other attributes of the vehicle (such as model, color, and license plate number) remain unchanged. The time-related location data constitutes a set of time series data. Time series data also widely exists on the Internet, such as records of users visiting websites and system log data.

[0052] Time series data has the following characteristics:

[0053] 1) The most obvious feature of time series data is that it has a unique timestamp. Using timestamp as a unique identifier (ID) is the biggest difference between time series data and relational data. Relational data usually has other fields as unique identifiers, such as student data usually uses student ID as an identifier to distinguish.

[0054] 2) Time series data is growing continuously, and each time granularity will generate new data. The amount of time series data continues to grow linearly, and will continue to generate massive amounts of data. However, the growth of relational data is usually not continuous over time. For example, the amount of student data in a school is usually relatively stable over a period of time.

[0055] 3) Time series data rarely needs to be updated. Once a measurement value is recorded at a certain moment, it will not be changed again, so there is almost no need to update the time series data. For example, a temperature sensor will only record the temperature value once in a measurement cycle. For relational data, existing data is often updated. For example, student personal information (such as home address) may change frequently.

[0056] 4) Time series data has hot and cold characteristics. Time series data close to the current time has high value and can be stored as hot data; time series data farther away has gradually lower value and can be archived as cold data.

[0057] In addition, time series data also has the characteristics of high frequency of data generation and continuous high concurrent writing.

[0058] 2. Time series database.

[0059] Time series databases have emerged based on the rapidly growing demand for time series data applications and their characteristics that are different from traditional relational data. Time series databases are a type of database system specifically designed for the storage and query of time series data. Compared with traditional relational databases, time series databases focus more on writing and querying massive amounts of data and do not require complex transaction management capabilities.

[0060] Time series databases have the following characteristics:

[0061] 1) High-throughput and high-speed data writing capability: In the time series data business, massive amounts of time series data are continuously generated, and there are high requirements for writing speed. Therefore, the time series database needs to have high-throughput data writing capabilities to ensure the timeliness and reliability of the time series data.

[0062] 2) High compression rate: Since the amount of time series data is large and needs to be saved for a long time, the time series data needs to be compressed to save storage space and improve query efficiency.

[0063] 3) Efficient time window query capability: The query requirements of time series data business are usually divided into two categories: real-time data query and historical data query. For historical data query, it is usually necessary to query a large amount of data within a certain time window, so it is necessary to optimize the data query to improve the query efficiency.

[0064] 4) Efficient aggregation capabilities: Time series data businesses usually care about the aggregate values ​​of data, such as aggregation functions such as mean and count, to reflect the data situation within a certain period of time. Therefore, time series databases need to provide efficient aggregation capabilities.

[0065] 5) Batch overwrite and batch delete capabilities: For expired time series data, batch overwrite or batch delete operations need to be performed in a timely manner to ensure the stability and performance of the time series database.

[0066] 6) High scalability and high reliability: The time series database can support distributed architecture and dynamically expand the number of nodes to meet the needs of different data scales. At the same time, it can implement operations such as data backup and disaster recovery to improve the reliability of time series data.

[0067] 7) Large-scale parallel computing capabilities: Able to process time series data on multiple nodes, execute complex queries concurrently, and improve query efficiency.

[0068] In addition, time series databases usually need to provide rich data processing and analysis capabilities, such as data cleaning, statistics, analysis, and prediction, to provide more value for the business.

[0069] Based on the above characteristics, the time domain database can serve the following scenarios:

[0070] IoT: IoT uses sensors to collect a large amount of time series data, such as temperature, humidity, pressure, etc., which need to be stored and queried quickly and efficiently. Time series databases provide efficient data storage and query functions, providing important support for IoT applications.

[0071] Finance: Financial data has a time series nature. Data such as stock prices, trading volumes, exchange rates, etc. need to be processed and monitored in real time. Time series databases can help data analysts and traders quickly query data for decision making.

[0072] Commercial retail: Time series databases can process order transaction amounts and payment data, product inventory, and logistics data of e-commerce systems.

[0073] Industry: Time series databases can process industrial machine data, such as real-time rotation speed, wind speed data, and power generation data of wind turbines.

[0074] Development operations (DevOps): In a DevOps environment, it is necessary to collect, store, and analyze various logs and indicators to quickly locate and solve problems. Time series databases can provide reliable data storage and query support for DevOps.

[0075] Artificial intelligence: Artificial intelligence applications need to process a large amount of time series data, including video, audio, text data, etc. Time series databases can support artificial intelligence algorithms to process and analyze this data.

[0076] Energy and Utilities: The energy and utilities sectors require real-time monitoring of sensor data, grid status, weather information, etc. to ensure the normal operation of the system. Time series databases can provide efficient data storage and query to measure and control the grid system.

[0077] Smart city construction: Time series databases can be used to analyze urban operation data in real time, optimize urban public services, and improve urban water supply, power supply, and public transportation.

[0078] Scientific research: Time series databases can be used to store and analyze various scientific data, such as meteorological data, earthquake data, biological data, etc.

[0079] The above application scenarios are examples rather than limitations. The embodiments of the present application do not limit the application scenarios of the time series database.

[0080] The following describes a system applicable to an embodiment of the present application. Figure 1 As shown, the system 100 includes a client 110 and at least one server 120. When the system 100 includes one server 120, the server 120 can be called a stand-alone server. When the system 100 includes multiple servers 120, the server 120 can be called a cluster server.

[0081] The client 110 may be a mobile phone, a tablet computer, a computer with wireless transceiver function, a virtual reality (VR) terminal, an augmented reality (AR) terminal, a wireless terminal in industrial control, a whole vehicle, a wireless communication module in a whole vehicle, a telematics box (T-box), a roadside unit (RSU), a wireless terminal in unmanned driving, a smart speaker in IoT, a wireless user device in remote medical, a wireless user device in a smart grid, a wireless user device in transportation safety, a wireless user device in a smart city, or a wireless user device in a smart home, and the embodiments of the present application are not limited to this.

[0082] As an example but not limitation, in the embodiments of the present application, the client 110 may also be a wearable device. Wearable devices may also be referred to as wearable smart devices, which are a general term for wearable devices that are intelligently designed and developed using wearable technology for daily wear, such as glasses, gloves, watches, clothing, and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also achieve powerful functions through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include electronic devices that are fully functional, large in size, and can achieve full or partial functions without relying on smartphones, such as smart watches or smart glasses, or electronic devices that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various types of smart bracelets and smart jewelry for measuring vital signs.

[0083] The server 120 includes at least one processor core 121 and at least one memory 122. Optionally, the server 120 may also include at least one memory 123, that is, the memory 123 may be integrated in the server 120 or may be arranged outside the server 120.

[0084] At least one processor core 121 may be located in one processor or in different processors. The processor may be a central processor unit (CPU), a system on chip (SoC), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), a micro controller unit (MCU), a programmable logic device (PLD), or other logic devices, such as discrete gates, transistor logic devices, or discrete hardware components.

[0085] The memory 122 is a cache memory, which may also be referred to as a memory, and is generally a volatile memory. As an example and not a limitation, the memory 122 may be a random access memory (RAM), such as a static RAM (SRAM), a dynamic RAM (DRAM), a synchronous DRAM (SDRAM), a double data rate synchronous dynamic random access memory (DDR SDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM), and a direct rambus RAM (DR RAM).

[0086] The memory 123 is a persistent storage device, which may also be referred to as a disk or hard disk, and is generally a non-volatile memory. As an example and not limitation, the memory 122 may be a read-only memory (ROM), such as a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory.

[0087] The processor core 121, the memory 122 and the memory 123 may be interconnected via a bus or other technology. The embodiment of the present application does not limit the specific types of the processor core 121, the memory 122 and the memory 123, nor does the embodiment of the present application limit the communication method between the processor core 121, the memory 122 and the memory 123.

[0088] As an example but not limitation, in the embodiment of the present application, the server 120 may be a tower server, a blade server, a rack server or a cabinet server, or the server 120 may be a complex instruction set computer (CISC) server, a reduced instruction set computer (RISC) server or an explicitly parallel instruction computing (EPIC) server. The server 120 may also be a virtual server, such as a virtual machine (VM) or a container (docker).

[0089] The client 110 and the server 120 may communicate via a wired connection or a wireless connection. The wired connection may be an optical fiber or a cable, and the wireless connection may be a cellular network connection, wireless fidelity (WiFi) or Bluetooth. The embodiment of the present application does not limit the connection method between the client 110 and the server 120.

[0090] The server 120 is installed with a time series database, which stores and processes the time series data when the time series data is stored. For example, after receiving the three time series data shown in Table 1, the time series database can store the three time series data in the memory 123. Optionally, the time series data can be pre-aggregated for the three time series data, for example, the count function is used to count the number of time series data in a time window, and the max function is used to count the maximum value of the time series data in a time window. The number of time series data and the maximum value of the time series data are pre-aggregated data.

[0091] The client 110 is used to provide a query entry for the user, that is, the user can input a query request through the client 110, and the query request is used to query the time series data in the time series database on the server 120. After receiving the query request, the client 110 sends the query request to the server 120.

[0092] According to the function, the time series database can be divided into Figure 2The architecture shown. The architecture includes a read-write module, an index module and a storage module. The read-write module includes a single-value dimension write function, a multi-value dimension write function and a query function, wherein the single-value dimension write function is used to parse time series data in the form of single-value dimension data, the multi-value dimension write function is used to parse time series data in the form of multi-value dimension data, and the query function is used to process user query services. The index module is used to generate an index for time series data. For single-value dimension data, the index generated by the index module is a single-value index; for multi-value dimension data, the index generated by the index module is a multi-value index. The storage module provides a storage engine for providing write and read services for time series data.

[0093] The following describes the workflow of this architecture.

[0094] The time series database obtains time series data through the read and write modules<temperature,2023-1-1 00:00:02,guangzhou,30> and<temperature,2023-1-1 00:00:02,shenzhen,30> If it is stored in the form of single-value dimension data, the triples and other information of the two time series data can be parsed out through the single-value dimension write function, and a single-value index is assigned to each time series data through the index module, and the single-value index and the parsed information are stored in the disk through the storage engine. If it is stored in the form of multi-value dimension data, the triples and other information of the two time series data can be parsed out through the multi-value dimension write function, and a multi-value index is assigned to the two time series data through the index module, and the multi-value index and the parsed information are stored in the disk through the storage engine.

[0095] After receiving the query request, the time series database parses the query request through the query function and determines that the query request needs to query the time series data with dimension values ​​of guangzhou and shenzhen. The time series database can determine the single-value index or multi-value index corresponding to the dimension values ​​guangzhou and shenzhen through the index module, and then read the information corresponding to the single-value index or the multi-value index through the storage engine and send it to the user.

[0096] As mentioned above, storing time series data in the form of multi-valued dimensional data can reduce the space required to store time series data, thereby saving storage costs. However, the structure of multi-valued dimensional data is more complex than that of single-valued dimensional data. In addition to the need for query functions, storing time series data in the form of multi-valued dimensional data may bring about problems such as difficult database maintenance and inefficient query. It is necessary to design a simple and efficient method to store time series data.

[0097] The following describes a method for storing time series data provided by an embodiment of the present application. Figure 3As shown, the execution subject of method 300 may be an electronic device (eg, a server) or a chip applied to an electronic device, and the following description is made taking the execution subject being a server as an example. Method 300 includes the following contents.

[0098] S310, receiving first time series data and second time series data, the first time series data including a first indicator, a first dimension value and a first metric value, and the second time series data including a second indicator, a second dimension value and a second metric value.

[0099] The first time series data and the second time series data can be any two time series data in Table 1. For example, the first time series data is<temperature,2023-1-1 00:00:02,guangzhou,30> , the second time series data is<temperature,2023-1-100:00:02,shenzhen,30> , the first indicator is temperature, the first dimension value is guangzhou, the first measurement value is 30, the second indicator is temperature, the second dimension value is shenzhen, and the second measurement value is 30.

[0100] The server may directly obtain the time series data from a device that generates the time series data (eg, an IoT device). For example, after a temperature sensor generates the time series data, the time series data is transmitted to the server 120 via the IoT.

[0101] The server may also obtain time series data from the node device. For example, the server 120 obtains at least one time series data from other servers in the server cluster where it is located.

[0102] In addition, the server may receive the first time series data and the second time series data through a wireless connection (e.g., a 5G network), or may receive the first time series data and the second time series data through a wired connection (e.g., an optical fiber). The server may receive the first time series data and the second time series data at the same time, or may receive the first time series data first and then the second time series data, or may receive the second time series data first and then the first time series data. The embodiments of the present application do not limit the specific method for receiving the first time series data and the second time series data.

[0103] The server can perform indicator judgment and metric value judgment on the time series data received within a period of time. For example, if the time series data received by the server within 1 minute includes the first time series data and the second time series data, the following steps can be performed.

[0104] S320, if the first indicator is the same as the second indicator, and the first measurement value is equal to the second measurement value, a first data structure and a second data structure are generated according to the first time series data and the second time series data, the first data structure includes a first dimension value, a second dimension value, a first identifier and a second identifier, the first identifier is the same as the second identifier, the second data structure includes the first identifier or the second identifier, and the second data structure also includes the first measurement value or the second measurement value.

[0105] If the first indicator is the same as the second indicator, and the first metric value is equal to the second metric value, it means that the first time series data and the second time series data can be stored together. The first data structure includes a first dimension value, a second dimension value, a first identifier and a second identifier. If the user queries the first dimension value, the server can query the first data structure according to the first dimension value to determine the first identifier, and then query the second data structure according to the first identifier to determine the first metric value or the second metric value; if the user queries the second dimension value, the server can query the first data structure according to the second dimension value to determine the second identifier, and then query the second data structure according to the second identifier to determine the first metric value or the second metric value. It can be seen that when querying time series data, whether querying the first dimension value or the second dimension value, the corresponding identifier can be obtained from the first data structure, and then the first metric value or the second metric value can be queried from the second data result according to the identifier obtained from the first data structure. Since there are only two data structures for recording the information of the storage location of time series data, the information of recording the storage location of time series data is simplified compared with the prior art, thereby improving the efficiency of saving and querying time series data.

[0106] The first data structure and the second data structure may be tables or other types of data structures. The first data structure and the second data structure may be the same or different, and the embodiments of the present application do not limit the specific forms of the first data structure and the second data structure. Taking the table as an example, the server may parse the information in the three time series data in Table 1 to generate the first data structure shown in Table 3 and the second data structure shown in Table 4.

[0107] Table 3

[0108] Dimensions Primary Key ID city ​​= beijing 100 city ​​= guangzhou 200 city ​​= shenzhen 200

[0109] Table 4

[0110] Primary Key ID Metrics 100 28 200 30

[0111] In Table 3, guangzhou and shenzhen are the first dimension value and the second dimension value, and the two 200s in the primary key ID column are the first identifier and the second identifier.

[0112] In Table 4, 200 in the primary key ID column is the first identifier or the second identifier, and the metric value 30 is the first metric value or the second metric value.

[0113] Optionally, Table 3 may also include more dimensions. For example, if the first time series data and the second time series data also include the model of the temperature sensor, the server may generate a first data structure as shown in Table 5.

[0114] Table 5

[0115] Dimension 1 Dimension 2 Primary Key ID type= / city ​​= beijing 100 type=A city ​​= guangzhou 200 type=B city ​​= shenzhen 200

[0116] In Table 5, type= / indicates that the timing data is a model of a temperature sensor, type=A indicates that the temperature sensor model of the first timing data is A, and type=B indicates that the temperature sensor model of the second timing data is B.

[0117] After generating the first data structure and the second data structure, the server may perform the following steps.

[0118] S330: Save the first data structure and the second data structure.

[0119] The first data structure and the second data structure may be stored in a disk or in other types of storage media. The embodiments of the present application do not limit the storage method of the first data structure and the second data structure.

[0120] If the user queries the temperature of Beijing, the server can determine that the primary key ID is 100 according to Beijing in Table 3, and then determine the metric value 28 in Table 4 according to 100, and 28 is the query result of Beijing. If the user queries the temperature of Guangzhou, the server can determine that the primary key ID is 200 according to Guangzhou in Table 3, and then determine the metric value 30 in Table 4 according to 200, and 30 is the query result of Guangzhou. If the user queries the temperature of Shenzhen, the server can determine that the primary key ID is 200 according to Shenzhen in Table 3, and then determine the metric value 30 in Table 4 according to 200, and 30 is the query result of Shenzhen. If the user queries the temperature of the temperature sensor of type=A, the server can determine that the primary key ID is 200 according to A in Table 5, and then determine the metric value 30 in Table 4 according to 200, and 30 is the query result of A.

[0121] Table 3 and Table 4 are data structures generated when stored in the form of single-value dimension data. Optionally, if dimension values ​​and metric values ​​are stored in the form of single-value dimension data, the server can generate data structures as shown in Table 6 and Table 7.

[0122] Table 6

[0123] Dimensions Primary Key ID city ​​= beijing 10 city ​​= guangzhou 20 city ​​= shenzhen 30

[0124] Table 7

[0125] Primary Key ID Metrics 10 28 20 30 30 30

[0126] Optionally, when the time series data includes more dimensions, the server may also generate the data structure shown in Table 8.

[0127] Table 8

[0128] Dimension 1 Dimension 2 Primary Key ID type= / city ​​= beijing 10 type=A city ​​= guangzhou 20 type=B city ​​= shenzhen 30

[0129] The usage of Table 6, Table 7 and Table 8 is similar to that of Table 3, Table 4 and Table 5, and will not be repeated here.

[0130] In some cases, in addition to the metric values, the user also needs to obtain the dimension values ​​related to the metric values. The server can save the dimension values ​​of the first time series data and the second time series data in the following manner.

[0131] Optionally, the method 300 further includes:

[0132] A multi-value primary key is generated according to the first time series data and the second time series data. The multi-value primary key includes a primary key identifier and a primary key value. The primary key identifier is the first identifier or the second identifier. The primary key value includes a first information set and a second information set. The first information set includes a first dimension value, and the second information set includes a second dimension value.

[0133] For example, the first information set is "temp, city = guangzhou", the second information set is "temp, city = shenzhen", and the multi-value primary key may be "200; temp, city = guangzhou; temp, city = shenzhen".

[0134] In the above example, the first information set and the second information set share a primary key identifier (200), so centrally storing multiple dimension values ​​can reduce storage space usage. If the user needs to query the dimension values ​​of guangzhou and shenzhen, the temperature values ​​of multiple time series data can be obtained through one query, thereby improving query efficiency.

[0135] Optionally, the primary key value further includes: a type identifier, where the type identifier is used to indicate that the primary key value includes multiple information sets.

[0136] In addition to storing multi-valued primary keys, time series databases may also store single-valued primary keys. The structure and size of single-valued primary keys are different from those of multi-valued primary keys. Using type identifiers to distinguish multi-valued primary keys from single-valued primary keys is beneficial to the maintenance and use of multi-valued primary keys.

[0137] Optionally, the type identifier is located at the beginning of the primary key value.

[0138] The type identifier is located at the beginning of the primary key value, which can quickly determine whether the primary key value is a multi-valued primary key or a single-valued primary key, thereby improving the query efficiency of multi-valued primary keys.

[0139] Optionally, the primary key value also includes: quantity information, where the quantity information is used to indicate the quantity of information sets included in the primary key value.

[0140] The number of information sets of a multi-valued primary key is indefinite. If there is no quantity information, the entire multi-valued primary key needs to be read to determine the number of information sets included in the primary key value. Therefore, quantity information can improve the query efficiency of the multi-valued primary key.

[0141] Optionally, the quantity information is located before the first information set and the second information set.

[0142] The quantity information is located before the first information set and the second information set, so the number of information sets included in the primary key value can be determined as quickly as possible, thereby improving the query efficiency of the multi-value primary key.

[0143] Optionally, the primary key value further includes: first length information and second length information, the first length information is used to indicate the length of the first information set, and the second length information is used to indicate the length of the second information set.

[0144] The size of the information set of a multi-valued primary key is uncertain. Without length information, the server may not be able to determine which information belongs to the first information set and which information belongs to the second information set. Therefore, length information can improve the query accuracy of multi-valued primary keys.

[0145] Optionally, the first length information is located before the first information set and is adjacent to the first information set, and the second length information is located before the second information set and is adjacent to the second information set.

[0146] In this embodiment, the length information is adjacent to the information set and is located before the information set. After reading the length information, the server can directly read the adjacent information to obtain the information set without having to search for the location of the information set. Therefore, this embodiment can improve the query efficiency of multi-value primary keys.

[0147] It should be noted that the multi-value primary key may include all or part of the type identifier, quantity information and length information. Table 9 is a multi-value primary key including type identifier, quantity information and length information provided by an embodiment of the present application.

[0148] Table 9

[0149] Primary Key ID Primary key value 100 00017temp,city=beijing 200 0000 02 00019temp,city=guangzhou 00018temp,city=shenzhen

[0150] In Table 9, the primary key value with the primary key ID of 100 contains one information set, which can be called a single-value primary key, and the primary key value with the primary key ID of 200 contains two information sets, which can be called a multi-value primary key.

[0151] For a multi-valued primary key, the first 4-digit value "0000" is a prefix code, i.e., the type identifier of the multi-valued primary key, used to indicate that the primary key value is a multi-valued primary key; the two-digit value "02" after the prefix code is a quantity code, i.e., the quantity information of the multi-valued primary key, used to indicate that the number of information sets contained in the primary key value is 2; the values ​​"00019" and "00018" after the quantity information are length codes, i.e., the length information of the multi-valued primary key, where 00019 is the first length information, used to indicate the length of the first information set "temp, city = guangzhou", and 00018 is the second length information, used to indicate the length of the second information set "temp, city = shenzhen". In the example shown in Table 9, the length information is the number of characters in the information set.

[0152] For a single-valued primary key, the first 5-digit value "00017" is a length code, that is, the length information of the single-valued primary key, which is used to indicate the length of the information set "temp, city = beijing". The first 4 digits of the length code can be used as a type identifier for a single-valued primary key, which is used to indicate that the primary key value is a single-valued primary key. That is to say, in method 300, the server can generate a single-valued primary key based on the third time series data (such as the time series data with the dimension of beijing in Table 1), and the single-valued primary key includes a third identifier (such as 0001) and a third length information (such as 00017). Optionally, the third identifier is part of the information in the third length information. In this way, the storage space occupied by the single-valued primary key can be reduced when the single-valued primary key and the multi-valued primary key coexist.

[0153] If the user queries the primary key value of beijing, the server can determine that the primary key ID is 100 based on beijing in Table 3, and then determine the primary key value corresponding to 100 in Table 9 based on 100, determine that the primary key value is a single-value primary key based on the first 4 bits 0001 in the length code, and read 17 bits of information from the information after the length code based on the length code 00017 to obtain the query result "temp, city = beijing".

[0154] If the user queries the primary key value of guangzhou, the server can determine that the primary key ID is 200 according to guangzhou in Table 3, and then determine the primary key value corresponding to 200 in Table 9 according to 200, determine that the primary key value is a multi-value primary key according to the prefix code 0000, determine that the primary key value includes two information sets according to the quantity code 02, read 19 bits of information from the information after the length code according to the length code 00019, and obtain the first information set "temp, city = guangzhou". The first information set contains the content queried by the user, so the first information set is the query result, and the server no longer reads subsequent content.

[0155] If the user queries the primary key value of Shenzhen, the server can determine that the primary key ID is 200 according to Shenzhen in Table 3, and then determine the primary key value corresponding to 200 in Table 9 according to 200, determine that the primary key value is a multi-value primary key according to the prefix code 0000, and determine that the primary key value includes two information sets according to the quantity code 02. According to the length code 00019, 19 bits of information are read from the information after the length code to obtain the first information set "temp, city = guangzhou". The first information set does not contain the content of the user's query, so the server can continue to read the subsequent information. The server reads 18 bits of information from the information after the length code according to the length code 00018, and obtains the second information set "temp, city = shenzhen". The second information set contains the content of the user's query, so the second information set is the query result, and the server no longer reads subsequent content.

[0156] Optionally, if the primary key value is stored in the form of single-value dimension data, the server may generate a data structure as shown in Table 10.

[0157] Table 10

[0158] Primary Key ID Primary key value 10 00017temp,city=beijing 20 00019temp,city=guangzhou 30 00018temp,city=shenzhen

[0159] In Table 10, all primary key values ​​are in the form of single-value dimensional data. There is no need to distinguish the primary key type, nor to identify the number of information sets contained in the primary key value. Therefore, the primary key values ​​in Table 10 do not contain prefix codes and quantity codes.

[0160] If the user queries the primary key value of guangzhou, the server can determine that the primary key ID is 20 according to guangzhou in Table 6, and then determine the primary key value corresponding to 20 in Table 10 according to 20, and read 19 bits of information from the information after the length code according to the length code 00019 to obtain the information set "temp, city = guangzhou", which is the query result.

[0161] It should be noted that the information contained in each primary key value in Table 9 and Table 10 is an example rather than a limitation. The embodiments of the present application do not limit the specific forms of the type identification, quantity information, and length information, nor do they limit the positional relationship between the type identification, quantity information, and length information. In addition, the primary key value may also include more content. For example, the information set in the primary key value may also include the model of the temperature sensor.

[0162] In the query examples described above, each query by the user is a single dimension. In some cases, the user may query multiple dimensions. For example, if the user queries the temperature of Guangzhou and Shenzhen, the server needs to query the temperature of Guangzhou and Shenzhen multiple times. A query method provided by an embodiment of the present application is described below.

[0163] Optionally, the method 300 further includes:

[0164] Receive a query instruction, the query instruction includes a first dimension value and a second dimension value; determine a first identifier and a second identifier based on the first dimension value, the second dimension value and the first data structure; obtain a target metric value based on the first identifier and the second data structure, the target metric value is the first metric value or the second metric value; save the target metric value obtained from the second data structure in a buffer; obtain the target metric value from the buffer based on the second identifier.

[0165] For example, if a user queries the temperature in Guangzhou or Shenzhen, the first dimension value in the query instruction is Guangzhou and the second dimension value is Shenzhen. The server can Figure 4 The method shown is used to query. Figure 4 As shown, the first identifier and the second identifier are determined to be 200 from Table 3 according to guangzhou and shenzhen. Subsequently, the server obtains the metric value 30 from Table 4 according to the first identifier 200 and puts the metric value 30 into a buffer. When the server queries the metric value corresponding to the second identifier 200, it can directly obtain the metric value 30 from the buffer. After obtaining the metric values ​​corresponding to the first identifier and the second identifier, the server can perform aggregation operations and other processing on the two metric values ​​based on user needs.

[0166] During a query process, the metric value may need to be used multiple times. The second data structure is usually stored in the disk. The read and write rate of the disk is low, and the buffer is usually located in the RAM. Therefore, the read and write efficiency of the buffer is high. Temporarily storing the metric value in the buffer can improve the execution efficiency of the query instruction.

[0167] Optionally, the method 300 further includes: after the query instruction is executed, deleting the first metric value or the second metric value in the buffer.

[0168] After a query process is completed, the probability of the first metric value or the second metric value being used again in a short period of time is low, and the buffer is a storage area with limited space. Deleting the first metric value or the second metric value in the buffer after the query instruction is executed can improve the utilization rate of the buffer.

[0169] The above describes in detail the method examples provided by the embodiments of the present application. It is understandable that the corresponding device includes hardware structures and / or software modules corresponding to the execution of each function in order to realize the above functions. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.

[0170] Figure 5 1 is a schematic diagram of a structure of a device 500 for pre-aggregating time series data provided in an embodiment of the present application, wherein the device 500 includes a processing unit 510 and an input unit 520. The input unit 520 performs a receiving step or an input step under the control of the processing unit 510.

[0171] The input unit 520 is used to receive first time series data and second time series data, the first time series data includes a first indicator, a first dimension value and a first measurement value, and the second time series data includes a second indicator, a second dimension value and a second measurement value.

[0172] The processing unit 510 is used to: if the first indicator is the same as the second indicator, and the first measurement value is equal to the second measurement value, generate a first data structure and a second data structure according to the first time series data and the second time series data, the first data structure includes a first dimension value, a second dimension value, a first identifier and a second identifier, the first identifier is the same as the second identifier, the second data structure includes the first identifier or the second identifier, and the second data structure also includes the first measurement value or the second measurement value; save the first data structure and the second data structure.

[0173] Optionally, the processing unit 510 is also used to: generate a multi-value primary key based on the first time series data and the second time series data, the multi-value primary key includes a primary key identifier and a primary key value, the primary key identifier is the first identifier or the second identifier, the primary key value includes a first information set and a second information set, the first information set includes a first dimension value, and the second information set includes a second dimension value.

[0174] Optionally, the primary key value further includes: a type identifier, where the type identifier is used to indicate that the primary key value includes multiple information sets.

[0175] Optionally, the type identifier is located at the beginning of the primary key value.

[0176] Optionally, the primary key value also includes: quantity information, where the quantity information is used to indicate the quantity of information sets included in the primary key value.

[0177] Optionally, the quantity information is located before the first information set and the second information set.

[0178] Optionally, the primary key value further includes: first length information and second length information, the first length information is used to indicate the length of the first information set, and the second length information is used to indicate the length of the second information set.

[0179] Optionally, the first length information is located before the first information set and is adjacent to the first information set, and the second length information is located before the second information set and is adjacent to the second information set.

[0180] Optionally, the input unit 520 is also used to: receive a query instruction, the query instruction includes a first dimension value and a second dimension value; the processing unit 510 is also used to: obtain a target metric value based on the first identifier and the second data structure, the target metric value is the first metric value or the second metric value; save the target metric value obtained from the second data structure in a buffer; obtain the target metric value from the buffer according to the second identifier.

[0181] Optionally, the processing unit 510 is further configured to: after the query instruction is executed, delete the first metric value or the second metric value in the buffer.

[0182] Those skilled in the art can clearly understand that the specific working process of the device 500 and the technical effects produced by the execution steps can be referred to the description in the corresponding method embodiment above, and for the sake of brevity, they will not be repeated here.

[0183] The device 500 may be a server or a chip. The processing unit 510 may be implemented by hardware or software. When implemented by hardware, the processing unit 510 may be a logic circuit, an integrated circuit, etc.; when implemented by software, the processing unit 510 may be a general-purpose processor implemented by reading software codes stored in a storage unit. The storage unit may be integrated in the processing unit 510 or located outside the processing unit 510 and exists independently.

[0184] Figure 6 Schematic diagram of the structure of a server provided in an embodiment of the present application. For ease of explanation, Figure 6 Only the main components of the server are shown. Figure 6 As shown, the server 600 includes a processor 610, a memory 620, and an input-output device 630. The processor 610 is mainly used to process the time series database protocol and time series data, and to control the entire server 600, execute software programs, and process the data of software programs, for example, to support the server 600 to perform the actions described in the above method embodiment. The memory 620 is mainly used to store software programs and data. The input-output device 630 is, for example, a network card, an antenna, etc., and is mainly used to receive data and output data to the user. The processor 610, the memory 620, and the input-output device 630 can be connected through various buses.

[0185] The processor 610 and the memory 620 can serve one or more boards. That is, a memory and a processor can be set separately on each board. It is also possible that multiple boards share the same memory and processor. In addition, necessary circuits can be set on each board.

[0186] Those skilled in the art will appreciate that for ease of description, Figure 6 Only one memory and one processor are shown. In an actual server, there may be multiple processors and multiple memories. The memory may also be referred to as a storage medium or a storage device, etc., which is not limited in this application.

[0187] It can be understood that the processor in each embodiment of the present application can be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method embodiment can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a CPU, SoC, ASIC, FPGA, MCU, PLD or other logic device, such as a discrete gate, a transistor logic device or a discrete hardware component. The disclosed methods, steps and logic block diagrams in the embodiments of the present application can be implemented or executed.

[0188] It is understood that the memory in each embodiment of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memory. Among them, the non-volatile memory can be a ROM, a PROM, an EPROM, an EEPROM or a flash memory. The volatile memory can be a RAM, which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as SRAM, DRAM, SDRAM, DDR SDRAM, ESDRAM, SLDRAM and DR RAM. It should be noted that the memory in the system and method described herein is intended to include but is not limited to these and any other suitable types of memory.

[0189] In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software. The steps of the method disclosed in conjunction with the embodiment of the present application can be directly embodied as a hardware processor for execution, or a combination of hardware and software modules in a processor for execution. The software module can be located in a storage medium mature in the art such as a random access register, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory and completes the steps of the above method in conjunction with its hardware. To avoid repetition, it is not described in detail here.

[0190] The present application also provides a computer-readable medium on which a computer program is stored. When the computer program is executed by a computer, the functions of any of the above method embodiments are implemented.

[0191] The present application also provides a computer program product, which implements the functions of any of the above method embodiments when executed by a computer.

[0192] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless or microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a high-density digital video disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).

[0193] It should be understood that the "embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, the various embodiments in the entire specification may not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the terminal device and / or the network device can perform some or all of the steps in the various embodiments. These steps or operations are only examples, and the embodiments of the present application can also perform other operations or variations of various operations. In addition, the various steps can be performed in different orders presented in the various embodiments, and it is possible that not all operations in the embodiments of the present application are to be performed. Moreover, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0194] It should also be understood that in the present application, "when", "if" and "if" all mean that the executing subject will take corresponding measures under certain objective circumstances, and do not limit the time, nor do they require the executing subject to make judgments when implementing them, nor do they mean that there are other limitations.

[0195] In addition, the terms "system" and "network" are often used interchangeably in this article. The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.

[0196] It should be understood that in each embodiment of the present application, "B corresponding to A" means that B is associated with A, and B can be determined according to A. However, it should also be understood that determining B according to A does not mean determining B only according to A, and B can also be determined according to A and / or other information.

[0197] The above contents are optional embodiments of the technical solution of this application, and are not intended to limit the protection scope of this application. Any modification, equivalent replacement, improvement, etc. made within the principles of this application shall be included in the protection scope of this application.

Claims

1. A method for saving time series data, It is characterized in that include: Receive first time series data and second time series data, the first time series data includes a first indicator, a first dimension value and a first metric value, and the second time series data includes a second indicator, a second dimension value and a second metric value; If the first indicator is the same as the second indicator, and the first metric value is equal to the second metric value, a first data structure and a second data structure are generated according to the first time series data and the second time series data, the first data structure includes the first dimension value, the second dimension value, a first identifier and a second identifier, the first identifier is the same as the second identifier, the second data structure includes the first identifier or the second identifier, and the second data structure also includes the first metric value or the second metric value; The first data structure and the second data structure are saved.

2. The method according to claim 1, It is characterized in that Also includes: A multi-value primary key is generated according to the first time series data and the second time series data, wherein the multi-value primary key includes a primary key identifier and a primary key value, wherein the primary key identifier is the first identifier or the second identifier, and the primary key value includes a first information set and a second information set, wherein the first information set includes the first dimension value, and the second information set includes the second dimension value.

3. The method according to claim 2, It is characterized in that The primary key value also includes: A type identifier, where the type identifier is used to indicate that the primary key value includes multiple information sets.

4. The method according to claim 3, It is characterized in that The type identifier is located at the beginning of the primary key value.

5. The method according to any one of claims 2 to 4, It is characterized in that The primary key value also includes: Quantity information, where the quantity information is used to indicate the quantity of information sets included in the primary key value.

6. The method according to claim 5, It is characterized in that The quantity information is located before the first information set and the second information set.

7. The method according to any one of claims 2 to 6, It is characterized in that The primary key value also includes: First length information and second length information, the first length information is used to indicate the length of the first information set, and the second length information is used to indicate the length of the second information set.

8. The method according to claim 7, It is characterized in that The first length information is located before the first information set and is adjacent to the first information set, and the second length information is located before the second information set and is adjacent to the second information set.

9. The method according to any one of claims 1 to 8, It is characterized in that Also includes: receiving a query instruction, wherein the query instruction includes the first dimension value and the second dimension value; Determine the first identifier and the second identifier according to the first dimension value, the second dimension value and the first data structure; Acquire a target metric value according to the first identifier and the second data structure, where the target metric value is the first metric value or the second metric value; storing the target metric value obtained from the second data structure in a buffer; The target metric value is obtained from the buffer according to the second identifier.

10. The method according to claim 9, It is characterized in that Also includes: After the query instruction is executed, the first metric value or the second metric value in the buffer is deleted.

11. A device for storing time series data, It is characterized in that include: Module for executing the method according to any one of claims 1 to 10.

12. A device for storing time series data, It is characterized in that include: A processor, configured to execute a computer program stored in the memory so that the apparatus performs the method according to any one of claims 1 to 10; A communication interface is coupled to the processor and is used to input or output information.

13. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 10.