Data storage method and device, electronic device and medium based on time series database

By obtaining and storing the timestamps and label information of the data source in the timing database, the classification storage and query of the target data source are realized, and the problem of poor data storage reliability in the prior art is solved, and the accuracy and timeliness of the query are improved.

CN119066074BActive Publication Date: 2025-08-01成都虚谷伟业科技有限公司
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411206442.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2024-06-24
Filing Date
2024-08-30
Publication Date
2025-08-01
Estimated Expiration
2044-08-30

AI Technical Summary

Technical Problem

In the existing storage technologies based on time-series databases, the reliability of data storage is relatively poor, and the query timeliness and accuracy are not high.

Method used

By obtaining the timestamp information and tag information of the data to be stored for each target data source, it is stored in the corresponding data storage subtable to form a data storage super table, and a classified storage based on the target data source is realized, and the tag information reflects the spatial characteristics of the data source for querying.

Benefits of technology

It improves the accuracy and timeliness of data queries, improves the reliability of data storage, and makes subsequent queries more reliable.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119066074B_ABST
    Figure CN119066074B_ABST
Patent Text Reader

Abstract

The data storage method, device, electronic device and medium based on a time series database provided by this application relate to the technical field of data storage. In this application, first, the data to be stored corresponding to each target data source can be obtained respectively to get multiple pieces of data to be stored corresponding to multiple target data sources; second, for each piece of data to be stored among the multiple pieces of data to be stored, the timestamp information of the data to be stored and the tag information of the data to be stored can be obtained; then, for each piece of data to be stored among the multiple pieces of data to be stored, the data to be stored, the timestamp information corresponding to the data to be stored, and the tag information corresponding to the data to be stored can be stored in the data storage sub-table corresponding to the target data source corresponding to the data to be stored. Based on the above, the problem of relatively poor reliability of data storage existing in the prior art can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data storage, and in particular, to a data storage method and device, an electronic device, and a medium based on a time series database. Background Art

[0002] In a time series database, for multiple pieces of data from multiple data sources, generally, an unfolding process is performed, such as unfolding into a single time series record for flat storage. In this way, corresponding queries and analyses can be performed through the corresponding time index. However, through the inventor's research, it is found that in the existing storage technology based on a time series database, there is a problem that the reliability of data storage is relatively poor (for example, for the data stored based on this storage technology, the timeliness or accuracy is relatively low during the query process). Summary of the Invention

[0003] In view of this, the purpose of the present application is to provide a data storage method and device, an electronic device, and a medium based on a time series database to improve the problem of relatively poor reliability of data storage in the existing technology.

[0004] To achieve the above purpose, the embodiments of the present application adopt the following technical solutions:

[0005] A data storage method based on a time series database includes:

[0006] Obtain the data to be stored corresponding to each target data source respectively, and obtain multiple pieces of data to be stored corresponding to multiple target data sources, where each of the target data sources is used to reflect the data source of the corresponding data to be stored;

[0007] For each piece of data to be stored among the multiple pieces of data to be stored, obtain the timestamp information of the data to be stored and the tag information of the data to be stored, where the tag information is at least used to reflect a data source space feature of the target data source;

[0008] For each piece of data to be stored among the multiple pieces of data to be stored, store the data to be stored, the timestamp information corresponding to the data to be stored, and the tag information corresponding to the data to be stored in the data storage sub-table corresponding to the target data source corresponding to the data to be stored. In the data storage sub-table, the stored data is stored in the time series characterized by the corresponding timestamp information, and the data storage super-table composed of multiple data storage sub-tables is stored in the target time series database.

[0009] In a preferred choice of the embodiments of the present application, in the above data storage method based on a time series database, the step of obtaining the timestamp information of the data to be stored and the tag information of the data to be stored for each piece of data to be stored among the multiple pieces of data to be stored includes:

[0010] For each of the multiple data to be stored, obtain the timestamp information of the data to be stored, and obtain the location feature information and shape feature information of the target data source corresponding to the data to be stored, where the location feature information and the shape feature information are used to reflect the data source space features of the corresponding target data source;

[0011] Determine the location feature information and shape feature information of the target data source as the label information of the corresponding data to be stored.

[0012] In a preferred selection of the embodiments of the present application, in the above data storage method based on a time series database, the step of, for each of the multiple data to be stored, obtaining the timestamp information of the data to be stored, and obtaining the location feature information and shape feature information of the target data source corresponding to the data to be stored includes:

[0013] For each of the multiple data to be stored, obtain the timestamp information of the data to be stored, and obtain the longitude and latitude information and altitude information of the target data source corresponding to the data to be stored, and determine the longitude and latitude information and the altitude information as the location feature information of the target data source;

[0014] Determine the spatial range information covered by the target data source, and determine the spatial range information as the shape feature information of the target data source, where when the target data source belongs to an information collection device, the spatial range information is used to reflect the effective range of information collection by the information collection device, and at least includes the spatial shape and size information of the effective range.

[0015] In a preferred selection of the embodiments of the present application, in the above data storage method based on a time series database, the step of, for each of the multiple data to be stored, storing the data to be stored, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored in the data storage sub-table corresponding to the target data source corresponding to the data to be stored includes:

[0016] For each of the multiple target data sources, determine whether there is currently a data storage sub-table corresponding to the target data source;

[0017] For each target data source with a corresponding data storage sub-table currently existing, store the data to be stored corresponding to the target data source among the multiple data to be stored, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored in the data storage sub-table corresponding to the target data source;

[0018] For each target data source for which there is currently no corresponding data storage sub-table, construct the data storage sub-table corresponding to the target data source, and store the data to be stored corresponding to the target data source among the multiple data to be stored, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored in the data storage sub-table.

[0019] In a preferred choice of the embodiments of the present application, in the above data storage method based on a time series database, the step of storing the data to be stored corresponding to the target data source, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored among the multiple data to be stored in the data storage sub-table corresponding to the target data source includes:

[0020] For each target data source for which there is currently a corresponding data storage sub-table, perform the following operations on the target data source:

[0021] Store the data to be stored corresponding to the target data source among the multiple data to be stored into the data column in the data storage sub-table corresponding to the target data source, where the data storage sub-table at least includes a data column, a timestamp column, and a label column;

[0022] Store the timestamp information corresponding to the data to be stored into the timestamp column in the data storage sub-table corresponding to the target data source;

[0023] Store the label information corresponding to the data to be stored into the label column in the data storage sub-table corresponding to the target data source, where the data to be stored corresponding to the target data source, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored are stored in the same row in the data storage sub-table.

[0024] In a preferred choice of the embodiments of the present application, in the above data storage method based on a time series database, the step of constructing the data storage sub-table corresponding to the target data source for which there is currently no corresponding data storage sub-table, and storing the data to be stored corresponding to the target data source, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored in the data storage sub-table includes:

[0025] For each target data source for which there is currently no corresponding data storage sub - table, based on the data source space characteristics corresponding to the target data source, construct a data storage sub - table corresponding to the target data source, where the data storage sub - table includes at least one row and multiple columns, and the multiple columns at least include a data column, a timestamp column, and a label column. The data column is used to store data to be stored, the timestamp column is used to store timestamp information, and the label column is used to store label information;

[0026] After constructing the data storage sub - table corresponding to the target data source, store the data to be stored corresponding to the target data source among the multiple data to be stored, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored in the same row of the data storage sub - table.

[0027] An embodiment of the present application also provides a data storage device based on a time - series database, including:

[0028] A data acquisition module, configured to respectively acquire the data to be stored corresponding to each target data source, and obtain multiple data to be stored corresponding to multiple target data sources, where each of the target data sources is used to reflect the data source of the corresponding data to be stored;

[0029] A relevant information acquisition module, configured to, for each data to be stored among the multiple data to be stored, acquire the timestamp information of the data to be stored and the label information of the data to be stored, where the label information is at least used to reflect a data source space characteristic of the target data source;

[0030] A data storage module, configured to, for each data to be stored among the multiple data to be stored, store the data to be stored, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored in the data storage sub - table corresponding to the target data source corresponding to the data to be stored. In the data storage sub - table, the stored data is stored in the time sequence represented by the corresponding timestamp information, and the data storage super - table composed of multiple data storage sub - tables is stored in the target time - series database.

[0031] In a preferred selection of the embodiment of the present application, in the above - mentioned data storage device based on a time - series database, the relevant information acquisition module is specifically configured to:

[0032] For each data to be stored among the multiple data to be stored, acquire the timestamp information of the data to be stored, and acquire the location feature information and shape feature information of the target data source corresponding to the data to be stored, where the location feature information and the shape feature information are used to reflect the data source space characteristics of the corresponding target data source;

[0033] Determine the location feature information and shape feature information of the target data source as the corresponding label information of the data to be stored.

[0034] On this basis, an embodiment of the present application further provides an electronic device, including:

[0035] A memory for storing a computer program;

[0036] A processor connected to the memory for executing the computer program stored in the memory to implement the above-mentioned data storage method based on a time series database.

[0037] On this basis, an embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, and when the computer program runs, it executes each step of the above-mentioned data storage method based on a time series database.

[0038] The data storage method and device, electronic device and medium based on a time series database provided by the present application can, first, respectively obtain the data to be stored corresponding to each target data source to obtain multiple data to be stored corresponding to multiple target data sources; second, for each data to be stored among the multiple data to be stored, obtain the timestamp information of the data to be stored and the label information of the data to be stored; then, for each data to be stored among the multiple data to be stored, store the data to be stored, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored in the data storage sub-table corresponding to the target data source corresponding to the data to be stored. Based on the above content, since the data to be stored are respectively stored in the corresponding data storage sub-tables, and the data storage sub-tables correspond to the target data sources, in this way, classification storage based on the target data source can be achieved. Moreover, since the stored data includes not only the data to be stored and the timestamp information, but also the label information, and the label information is at least used to reflect the data source space characteristics of the target data source, data query can also be performed based on the data source space characteristics in the subsequent data query process. In this way, the query accuracy can be improved to a certain extent, such as narrowing the query range through the data source space characteristics. Among them, when the query range is narrowed, not only the accuracy can be improved, but also the timeliness can be improved. Therefore, the problem of relatively poor reliability of data storage in the existing technology can be improved, making the data stored based on this data storage technology more reliable in subsequent queries. In addition, since multiple data storage sub-tables will form corresponding data storage super-tables in the target time series data for storage, in this way, more complex data models and query operations can be realized. Description of the Drawings

[0039] To make the above objects, features, and advantages of the present application more obvious and understandable, the following provides preferred embodiments in conjunction with the accompanying drawings and makes a detailed description as follows.

[0040] Figure 1 It is a structural block diagram of an electronic device provided by an embodiment of the present application.

[0041] Figure 2 It is a schematic flowchart of a data storage method based on a time series database provided by an embodiment of the present application.

[0042] Figure 3 It is a schematic diagram of a data storage sub-table provided by an embodiment of the present application.

[0043] Figure 4 It is a block diagram of a data storage device based on a time series database provided by an embodiment of the present application. Detailed implementation manners

[0044] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Generally, the components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.

[0045] Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the present application to be protected, but only represents the selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative efforts belong to the scope of protection of the present application.

[0046] As Figure 1 shown, an embodiment of the present application provides an electronic device. Among them, the electronic device may include a memory, a processor, and a data storage device based on a time series database.

[0047] Specifically, the memory and the processor may be electrically connected directly or indirectly to achieve data transmission or interaction. For example, they may be electrically connected through one or more communication buses or signal lines. The data storage device based on the time series database includes at least one software function module stored in the memory in the form of software or firmware. The processor is used to execute the executable computer program stored in the memory, such as the software function module and computer program included in the data storage device based on the time series database, to implement the data storage method based on the time series database provided by the embodiment of the present application.

[0048] Optionally, the memory may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), an Electric Erasable Programmable Read-Only Memory (EEPROM), etc.

[0049] Moreover, the processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), a System on Chip (SoC), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0050] It can be understood that Figure 1 The structure shown is only for illustration, and the electronic device may further include more or fewer components than those shown Figure 1 in the figure, or have a different configuration from that shown Figure 1 in the figure. For example, it may further include a communication unit for information interaction with other devices (such as terminal devices, etc.).

[0051] In combination with Figure 2 , an embodiment of the present application further provides a data storage method based on a time series database applicable to the above-mentioned electronic device. Among them, the method steps defined by the process related to the data storage method based on the time series database can be implemented by the electronic device.

[0052] Next, the Figure 2 specific process shown will be elaborated in detail.

[0053] Step S110: Obtain the data to be stored corresponding to each target data source respectively, and obtain multiple pieces of data to be stored corresponding to multiple target data sources.

[0054] In an embodiment of the present application, the electronic device may respectively obtain the data to be stored corresponding to each target data source, and obtain a plurality of data to be stored corresponding to a plurality of target data sources. Wherein, each of the target data sources is used to reflect the data source of the corresponding data to be stored. Exemplarily, the target data source may be a sensor, another electronic device, etc. Exemplarily, the data to be stored may be data collected by a sensor or a log file of an electronic device, etc.

[0055] Step S120: For each piece of data to be stored among the plurality of pieces of data to be stored, obtain the timestamp information of the data to be stored and the tag information of the data to be stored.

[0056] In an embodiment of the present application, the electronic device may, for each piece of data to be stored among the plurality of pieces of data to be stored, obtain the timestamp information of the data to be stored and the tag information of the data to be stored. Wherein, the tag information is at least used to reflect a data source spatial feature of the target data source, that is, a feature that the target data source has in space.

[0057] Step S130: For each piece of data to be stored among the plurality of pieces of data to be stored, store the data to be stored, the timestamp information corresponding to the data to be stored, and the tag information corresponding to the data to be stored in a data storage sub-table corresponding to the target data source corresponding to the data to be stored.

[0058] In an embodiment of the present application, the electronic device may, for each piece of data to be stored among the plurality of pieces of data to be stored, store the data to be stored, the timestamp information corresponding to the data to be stored, and the tag information corresponding to the data to be stored in a data storage sub-table corresponding to the target data source corresponding to the data to be stored. Wherein, in the data storage sub-table, the stored data is stored in the time sequence represented by the corresponding timestamp information. For example, the earlier the timestamp information, the more forward the storage position of the data, and the later the timestamp information, the more backward the storage position of the data. And a data storage super-table formed by a plurality of the data storage sub-tables is stored in a target time sequence database.

[0059] It should be noted that a super table is a collection containing multiple sub-tables, usually used to represent a one-to-many or many-to-many relationship. The super table itself does not store data, but is only a logical combination. Each sub-table is associated with the super table through a foreign key. A sub-table is an independent table in the super table, containing relevant data of a certain entity or concept. The sub-table can be associated with the data in other sub-tables or the super table through a foreign key.

[0060] Based on the above, since the data to be stored is stored in the corresponding data storage sub-tables respectively, and the data storage sub-tables correspond to the target data sources, thus, it is possible to achieve classified storage based on the target data sources. Moreover, since the stored data includes not only the data to be stored and the timestamp information, but also the tag information, and the tag information is at least used to reflect the data source space characteristics of the target data source, it enables data query based on the data source space characteristics in the subsequent data query process. In this way, to a certain extent, the query accuracy can be improved, such as narrowing the query range through the data source space characteristics, etc. Among them, when the query range is narrowed, not only the accuracy can be improved, but also the timeliness can be improved. Therefore, the problem of relatively poor reliability of data storage existing in the prior art can be improved, making the data stored based on this data storage technology more reliable in subsequent queries. In addition, since multiple data storage sub-tables will form corresponding data storage super-tables in the target time-series data for storage, thus, more complex data models and query operations can be realized.

[0061] In the first aspect, it should be noted that for step S110, the specific manner of obtaining the data to be stored is not limited and can be selected according to actual needs.

[0062] For example, in an alternative embodiment, the data obtained directly from the target data source can be used as the data to be stored, so that the efficiency of data storage can be higher.

[0063] For another example, in another alternative embodiment, the data can be obtained from the target data source first, and then, the data can be further processed, and the processed data can be used as the data to be stored, so that the reliability of the stored data can be higher. Further processing of the data can include data cleaning, removing outliers, filling in missing values, data smoothing, etc.

[0064] In the second aspect, it should be noted that for step S120, the specific manner of obtaining the timestamp information of the data to be stored and the tag information of the data to be stored is not limited and can be selected according to actual needs.

[0065] For example, in an alternative embodiment, after data storage, in order to enable more accurate data query based on the tag information, the above step S120 can further include step S121 and step S122, and the specific content of each step is as follows.

[0066] Step S121, for each of the multiple data to be stored, obtain the timestamp information of the data to be stored, and obtain the location feature information and shape feature information of the target data source corresponding to the data to be stored.

[0067] In an embodiment of the present application, after obtaining the multiple data to be stored, for each data to be stored among the multiple data to be stored, timestamp information of the data to be stored (such as the acquisition time, formation time, etc. of the data to be stored) can be obtained, and location feature information and shape feature information possessed by the target data source corresponding to the data to be stored can be obtained. Wherein, the location feature information and the shape feature information are used to reflect the data source space features of the corresponding target data source, that is, the features possessed by the target data source in space are characterized by the location feature information and the shape feature information. It can be understood that in other embodiments, only any one of the location feature information and the shape feature information may be obtained.

[0068] Step S122, determine the location feature information and the shape feature information possessed by the target data source as the label information corresponding to the data to be stored.

[0069] In an embodiment of the present application, after obtaining the location feature information and the shape feature information, the location feature information and the shape feature information possessed by the target data source can be determined as the label information corresponding to the data to be stored. In this way, after data storage, corresponding data queries can be performed based on the location feature information and the shape feature information.

[0070] It can be understood that for step S121, it should be noted that the specific manner of obtaining the location feature information and the shape feature information possessed by the target data source corresponding to the data to be stored is not limited and can be selected according to actual needs.

[0071] For example, in an alternative embodiment, after data storage, in order to enable more accurate data queries based on the label information, step S121 described above can further include step S121a and step S121b, and the specific content of each step is as follows.

[0072] Step S121a, for each data to be stored among the multiple data to be stored, obtain the timestamp information of the data to be stored, and obtain the longitude and latitude information and altitude information possessed by the target data source corresponding to the data to be stored, and determine the longitude and latitude information and the altitude information as the location feature information possessed by the target data source.

[0073] In an embodiment of the present application, after obtaining the multiple data to be stored, for each of the data to be stored, on the one hand, the timestamp information of the data to be stored can be obtained, and on the other hand, the longitude and latitude information and altitude information of the target data source corresponding to the data to be stored can be obtained. Then, the longitude and latitude information and the altitude information can be determined as the position feature information of the target data source. In this way, three-dimensional positioning of the target data source can be achieved.

[0074] Step S121b: Determine the spatial range information covered by the target data source, and determine the spatial range information as the shape feature information of the target data source.

[0075] In an embodiment of the present application, after obtaining the multiple data to be stored, for each of the data to be stored, the spatial range information covered by the target data source corresponding to the data to be stored can also be obtained, and the spatial range information can be determined as the shape feature information of the target data source. Wherein, when the target data source belongs to an information collection device, the spatial range information is used to reflect the effective range for the information collection device to collect information, and at least includes the spatial shape and size information of the effective range. Exemplarily, the target data source can be a temperature sensor for collecting temperature data in the space where it is located. In this way, for any temperature sensor, the temperature data it collects can be stored in a corresponding data storage sub-table, and the multiple data storage sub-tables corresponding to multiple temperature sensors can be associated to form a corresponding data storage super-table, which can be used to reflect the temperature of the area where multiple temperature sensors are located as a whole.

[0076] It should be noted that the specific representation method of the spatial range information is not limited and can also be selected according to actual needs. For example, for a regular space, it can be represented by a rectangular shape, a spherical shape, a regular polygon shape, etc., and can also be assisted by the distances from the center point of the regular space to each side or each face. For another example, for an irregular space, it can be represented by the position information of multiple edge points, etc.

[0077] Thirdly, regarding step S130, it should be noted that the specific method of storing the data to be stored, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored in the corresponding data storage sub-table is not limited and can be selected according to actual needs.

[0078] For example, in an alternative embodiment, in order to ensure that each data to be stored can be reliably stored in the corresponding data storage sub-table, the above step S130 can further include step S131, step S132, and step S133, and the specific content of each step is described as follows:

[0079] Step S131: For each of the multiple target data sources, determine whether there is a corresponding data storage sub-table for the target data source currently.

[0080] In the embodiment of the present application, for each of the multiple target data sources, it can be first determined whether there is a corresponding data storage sub-table for the target data source. Generally speaking, when the data storage sub-table has not been deleted due to exceptions or other reasons, the already constructed data storage sub-table will always exist. And when it is necessary to store the first data to be stored of the target data source, there may also be no corresponding data storage sub-table for the target data source currently.

[0081] Step S132: For each of the target data sources that currently have corresponding data storage sub-tables, store the data to be stored corresponding to the target data source, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored among the multiple data to be stored in the data storage sub-table corresponding to the target data source.

[0082] In the embodiment of the present application, after determining whether there is a corresponding data storage sub-table for the target data source, for each of the target data sources that currently have corresponding data storage sub-tables, the data to be stored corresponding to the target data source, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored among the multiple data to be stored can be stored in the data storage sub-table corresponding to the target data source.

[0083] Step S133: For each of the target data sources that currently do not have corresponding data storage sub-tables, construct a data storage sub-table corresponding to the target data source, and store the data to be stored corresponding to the target data source, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored among the multiple data to be stored in the data storage sub-table.

[0084] After determining whether there is a corresponding data storage sub-table for the target data source, for each of the target data sources that currently do not have corresponding data storage sub-tables, a data storage sub-table corresponding to the target data source can be first constructed, and then, the data to be stored corresponding to the target data source, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored among the multiple data to be stored can be stored in the data storage sub-table.

[0085] It can be understood that for Step S132, it should be noted that for each of the target data sources that currently have corresponding data storage sub-tables, the specific storage method of the data corresponding to the target data source is not limited and can be selected according to actual needs.

[0086] For example, in an alternative embodiment, in order to improve the orderliness of data storage and the reliability of subsequent data search, step S132 described above may further include the following steps:

[0087] For each target data source for which there is a corresponding data storage sub-table currently, the following operations may be performed on the target data source:

[0088] First, the data to be stored corresponding to the target data source among the multiple data to be stored may be stored into the data column in the data storage sub-table corresponding to the target data source, where the data storage sub-table at least includes a data column, a timestamp column, and a label column; exemplarily, the data column may be one column or multiple columns, which may be determined according to the required data, the timestamp column may also be one column or multiple columns, and may also be determined according to the data to be stored, and the label column may also be one column or multiple columns, and may also be determined according to the data to be stored;

[0089] Second, the timestamp information corresponding to the data to be stored may be stored into the timestamp column in the data storage sub-table corresponding to the target data source;

[0090] Then, the label information corresponding to the data to be stored is stored into the label column in the data storage sub-table corresponding to the target data source, where the data to be stored corresponding to the target data source, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored are stored in the same row in the data storage sub-table; exemplarily, for the data to be stored collected at the first time point, it may have timestamp information 1 and label information 1, thus, the data to be stored collected at the first time point, timestamp information 1, and label information 1 may be stored in the first row of the data storage sub-table; for the data to be stored collected at the second time point, it may have timestamp information 2 and label information 2 (generally, label information 2 may be the same as label information 1, that is, the label information generally does not change), thus, the data to be stored collected at the second time point, timestamp information 2, and label information 2 may be stored in the second row of the data storage sub-table.

[0091] It can be understood that regarding step S133, for each target data source for which there is no corresponding data storage sub-table currently, the specific storage method of the data corresponding to the target data source is not limited and may be selected according to actual requirements.

[0092] For example, in an alternative embodiment, in order to improve the orderliness of data storage and the reliability of subsequent data search, step S133 described above may further include step S133a and step S133b, and the specific content of each step is described as follows.

[0093] Step S133a: For each target data source for which there is currently no corresponding data storage sub-table, based on the data source space characteristics corresponding to the target data source, construct the data storage sub-table corresponding to the target data source.

[0094] In the embodiment of the present application, for each of the target data sources, after determining that there is no corresponding data storage sub-table for the target data source, if the data storage sub-table corresponding to the target data source is deleted due to reasons such as anomalies or it is the first time to store the data corresponding to the target data source, the data storage sub-table corresponding to the target data source can be constructed first based on the data source space characteristics of the target data source. Among them, the data storage sub-table includes at least one row and multiple columns, and the multiple columns at least include a data column, a timestamp column, and a tag column. The data column is used to store the data to be stored, the timestamp column is used to store timestamp information, and the tag column is used to store tag information. In this way, different data storage sub-tables can be constructed for different target data sources, realizing the adaptation between the target data source and the data storage sub-table.

[0095] Step S133b: After constructing the data storage sub-table corresponding to the target data source, store the data to be stored corresponding to the target data source, the timestamp information corresponding to the data to be stored, and the tag information corresponding to the data to be stored among the multiple data to be stored in the same row of the data storage sub-table.

[0096] In the embodiment of the present application, after constructing the data storage sub-table corresponding to the target data source, the data to be stored corresponding to the target data source, the timestamp information corresponding to the data to be stored, and the tag information corresponding to the data to be stored among the multiple data to be stored can be stored in the same row of the data storage sub-table. For example, store the data to be stored in the data column, store the timestamp information in the timestamp column, and store the tag information in the tag column.

[0097] Combined with Figure 3 , in a specific application example, one row in the data storage sub-table may include a timestamp column (denoted by "ts") for storing timestamp information, at least two data columns (denoted by "data1" and "data2") for storing the data to be stored, and at least five tag columns (denoted by "x", "y", "z", "r", and "type"). Among them, "x" represents longitude information, "y" represents latitude information, "z" represents altitude information, "r" represents the distance from the center point to an arbitrary plane, and "type" represents the shape of a cube.

[0098] Combined with Figure 4, an embodiment of the present application further provides a data storage device based on a time series database that can be applied to the above-mentioned electronic device. Among them, the data storage device based on the time series database may include a data acquisition module, a relevant information acquisition module, and a data storage module.

[0099] Specifically, the data acquisition module can be used to respectively acquire the data to be stored corresponding to each target data source, and obtain a plurality of data to be stored corresponding to a plurality of target data sources, where each of the target data sources is used to reflect the data source of the corresponding data to be stored. In the embodiment of the present application, the data acquisition module can be used to execute Figure 2 the steps S110 shown, and the relevant content of the data acquisition module can be referred to the description of step S110 above.

[0100] Specifically, the relevant information acquisition module can be used to, for each of the plurality of data to be stored, acquire the timestamp information of the data to be stored and the tag information of the data to be stored, where the tag information is at least used to reflect a data source space feature of the target data source. In the embodiment of the present application, the relevant information acquisition module can be used to execute Figure 2 the steps S120 shown, and the relevant content of the relevant information acquisition module can be referred to the description of step S120 above.

[0101] Specifically, the data storage module can be used to, for each of the plurality of data to be stored, store the data to be stored, the timestamp information corresponding to the data to be stored, and the tag information corresponding to the data to be stored in the data storage sub-table corresponding to the target data source corresponding to the data to be stored. Among them, in the data storage sub-table, the stored data is stored in the time series characterized by the corresponding timestamp information, and the data storage super-table composed of a plurality of the data storage sub-tables is stored in the target time series database. In the embodiment of the present application, the data storage module can be used to execute Figure 2 the steps S130 shown, and the relevant content of the data storage module can be referred to the description of step S130 above.

[0102] Exemplarily, in an alternative embodiment, the relevant information acquisition module can specifically be used to:

[0103] For each of the plurality of data to be stored, acquire the timestamp information of the data to be stored, and acquire the location feature information and shape feature information of the target data source corresponding to the data to be stored, where the location feature information and the shape feature information are used to reflect the data source space feature of the corresponding target data source;

[0104] Determine the location feature information and shape feature information of the target data source as the label information of the corresponding data to be stored.

[0105] Exemplarily, in an alternative embodiment, the data storage module may specifically be configured to:

[0106] For each target data source among the multiple target data sources, determine whether there is a corresponding data storage sub-table for this target data source currently;

[0107] For each target data source that currently has a corresponding data storage sub-table, store the data to be stored corresponding to this target data source among the multiple data to be stored, the timestamp information corresponding to this data to be stored, and the label information corresponding to this data to be stored in the data storage sub-table corresponding to this target data source;

[0108] For each target data source that currently does not have a corresponding data storage sub-table, construct a data storage sub-table corresponding to this target data source, and store the data to be stored corresponding to this target data source among the multiple data to be stored, the timestamp information corresponding to this data to be stored, and the label information corresponding to this data to be stored in this data storage sub-table.

[0109] In the embodiments of the present application, corresponding to the above data storage method based on a time series database applied to the electronic device, a computer-readable storage medium is further provided. A computer program is stored in this computer-readable storage medium, and when this computer program runs, it executes each step of the data storage method based on a time series database.

[0110] Among them, the steps executed when the foregoing computer program runs will not be elaborated one by one here, and reference can be made to the foregoing explanation of the data storage method based on a time series database.

[0111] In summary, for the data storage method, apparatus, electronic device, and medium based on a time series database provided in this application, first, the data to be stored corresponding to each target data source can be obtained separately to obtain multiple pieces of data to be stored corresponding to multiple target data sources; second, for each piece of data to be stored among the multiple pieces of data to be stored, the timestamp information and tag information of the data to be stored can be obtained; then, for each piece of data to be stored among the multiple pieces of data to be stored, the data to be stored, the timestamp information corresponding to the data to be stored, and the tag information corresponding to the data to be stored can be stored in the data storage sub-table corresponding to the target data source corresponding to the data to be stored. Based on the above, since the data to be stored is stored separately in the corresponding data storage sub-tables, and the data storage sub-tables correspond to the target data sources, in this way, classified storage based on the target data sources can be achieved. Moreover, since the stored data includes not only the data to be stored and timestamp information but also tag information, and the tag information is at least used to reflect the data source space characteristics of the target data source, data queries can also be performed based on the data source space characteristics during subsequent data query processes. In this way, the query accuracy can be improved to a certain extent, such as narrowing the query range through the data source space characteristics. Among them, when the query range is narrowed, not only can the accuracy be improved, but the timeliness can also be improved. Therefore, the problem of relatively poor reliability of data storage existing in the prior art can be improved, making the data stored based on this data storage technology more reliable in subsequent queries. In addition, since multiple data storage sub-tables will form corresponding data storage super-tables in the target time series data for storage, in this way, more complex data models and query operations can be realized.

[0112] In several embodiments provided in the embodiments of the present application, it should be understood that the disclosed apparatus and method can also be implemented in other ways. The apparatus and method embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of the apparatus, method, and computer program product according to multiple embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, program segment, or part of the code, and the module, program segment, or part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order from that marked in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, as well as the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0113] In addition, each functional module in various embodiments of the present application may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.

[0114] If the above-mentioned function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, an electronic device, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present application. The aforementioned storage medium includes: USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs, etc., all kinds of media that can store program codes. It should be noted that in this article, the term "including", "comprising", or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article, or device including a series of elements not only includes those elements, but also includes other elements that are not explicitly listed, or further includes elements inherent to such a process, method, article, or device. Without further limitations, an element defined by the statement "including one..." does not exclude the existence of another identical element in the process, method, article, or device including the said element.

[0115] The above are only the preferred embodiments of the present application and are not used to limit the present application. For those skilled in the art, the present application may have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the protection scope of the present application.

Claims

1. A data storage method based on a time series database, characterized in that, Including: Obtain the data to be stored corresponding to each target data source respectively, and obtain multiple data to be stored corresponding to multiple target data sources. Wherein, each of the target data sources is used to reflect the data source of the corresponding data to be stored; For each of the multiple data to be stored, obtain the timestamp information of the data to be stored, and obtain the longitude and latitude information and altitude information of the target data source corresponding to the data to be stored. And determine the longitude and latitude information and the altitude information as the location feature information of the target data source; determine the spatial range information covered by the target data source, and determine the spatial range information as the shape feature information of the target data source. Wherein, the location feature information and the shape feature information are used to reflect the data source spatial features of the corresponding target data source. When the target data source belongs to an information collection device, the spatial range information is used to reflect the effective range of information collection by the information collection device, and at least includes the spatial shape and size information of the effective range; determine the location feature information and the shape feature information of the target data source as the label information of the corresponding data to be stored; For each of the multiple data to be stored, store the data to be stored, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored in the data storage sub-table corresponding to the target data source corresponding to the data to be stored. Wherein, in the data storage sub-table, the stored data is stored in the time sequence represented by the corresponding timestamp information, and the data storage super-table formed by the multiple data storage sub-tables is stored in the target time sequence database. The target data source includes a temperature sensor for collecting temperature data in the space where it is located. For any one temperature sensor, the temperature data collected by it is stored through a corresponding data storage sub-table, and the multiple data storage sub-tables corresponding to the multiple temperature sensors are associated to form a corresponding data storage super-table for reflecting the temperature of the area where the multiple temperature sensors are located as a whole.

2. The data storage method based on a time series database according to claim 1, wherein The step of storing the data to be stored, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored in the data storage sub-table corresponding to the target data source corresponding to each of the multiple data to be stored includes: For each of the multiple target data sources, determine whether there is currently a data storage sub-table corresponding to the target data source; For each target data source with a corresponding data storage sub-table currently existing, store the data to be stored corresponding to the target data source, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored in the data storage sub-table corresponding to the target data source; For each target data source for which there is currently no corresponding data storage sub-table, construct the data storage sub-table corresponding to the target data source, and store the data to be stored corresponding to the target data source, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored in the multiple data to be stored in the data storage sub-table.

3. The data storage method based on a time series database according to claim 2, wherein The step of storing the data to be stored corresponding to the target data source, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored in the multiple data to be stored in the data storage sub-table corresponding to the target data source for each target data source for which there is currently a corresponding data storage sub-table includes: For each target data source for which there is currently a corresponding data storage sub-table, perform the following operations on the target data source: Store the data to be stored corresponding to the target data source in the multiple data to be stored in the data column in the data storage sub-table corresponding to the target data source, where the data storage sub-table includes at least a data column, a timestamp column, and a label column; Store the timestamp information corresponding to the data to be stored in the timestamp column in the data storage sub-table corresponding to the target data source; Store the label information corresponding to the data to be stored in the label column in the data storage sub-table corresponding to the target data source, where the data to be stored corresponding to the target data source, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored are stored in the same row in the data storage sub-table.

4. The data storage method based on a time series database according to claim 2, wherein The step of constructing the data storage sub-table corresponding to the target data source and storing the data to be stored corresponding to the target data source, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored in the multiple data to be stored in the data storage sub-table for each target data source for which there is currently no corresponding data storage sub-table includes: For each target data source for which there is currently no corresponding data storage sub-table, construct the data storage sub-table corresponding to the target data source based on the data source space characteristics corresponding to the target data source, where the data storage sub-table includes at least one row and multiple columns, the multiple columns include at least a data column, a timestamp column, and a label column, the data column is used to store the data to be stored, the timestamp column is used to store the timestamp information, and the label column is used to store the label information; After constructing the data storage sub-table corresponding to the target data source, store the data to be stored corresponding to the target data source, the timestamp information corresponding to the data to be stored, and the label information corresponding to the data to be stored in the same row in the data storage sub-table.

5. A data storage device based on a time series database, characterized in that, Including: A data acquisition module for respectively acquiring the data to be stored corresponding to each target data source to obtain multiple data to be stored corresponding to multiple target data sources, where each of the target data sources is used to reflect the data source of the corresponding data to be stored; A relevant information acquisition module, which is used to, for each of the multiple data to be stored, acquire the timestamp information of the data to be stored, and acquire the longitude and latitude information and altitude information of the target data source corresponding to the data to be stored, and determine the longitude and latitude information and the altitude information as the location feature information of the target data source; determine the spatial range information covered by the target data source, and determine the spatial range information as the shape feature information of the target data source, where the location feature information and the shape feature information are used to reflect the data source spatial features of the corresponding target data source. When the target data source belongs to an information collection device, the spatial range information is used to reflect the effective range of information collection by the information collection device, and at least includes the spatial shape and size information of the effective range; determine the location feature information and the shape feature information of the target data source as the tag information of the corresponding data to be stored. A data storage module, which is used to, for each of the multiple data to be stored, store the data to be stored, the timestamp information corresponding to the data to be stored, and the tag information corresponding to the data to be stored in the data storage sub-table corresponding to the target data source corresponding to the data to be stored. Among them, in the data storage sub-table, the stored data is stored in the time sequence represented by the corresponding timestamp information, and the data storage super-table composed of multiple data storage sub-tables is stored in the target time sequence database. The target data source includes a temperature sensor, which is used to collect temperature data in the space where it is located. For any one temperature sensor, the temperature data collected by it is stored through a corresponding data storage sub-table, and the multiple data storage sub-tables corresponding to the multiple temperature sensors are associated to form a corresponding data storage super-table, which is used to reflect the temperature of the area where the multiple temperature sensors are located as a whole.

6. An electronic device, characterized in that, including: A memory, which is used to store computer programs; A processor connected to the memory, which is used to execute the computer program stored in the memory to implement the data storage method based on the time sequence database according to any one of claims 1-4.

7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program runs, it executes each step of the data storage method based on the time sequence database according to any one of claims 1-4.

Citation Information

Patent Citations

  • Medical internet-of-things data storage method, storage medium, internet-of-things server and system

    CN117421356A