Disclosure of Invention
In order to solve the foregoing technical problems, embodiments of the present application provide an access method and system for industrial time series data, so as to achieve the purpose of improving the performance of a query function, and the technical solution is as follows:
an access method of industrial time series data comprises the following steps:
when an industrial time series data query request is received, analyzing a data identifier and a query time range from the industrial time series data query request;
selecting one time sequence database from a plurality of different time sequence databases as a time sequence database to be accessed according to the query time range; the plurality of different timing databases comprises: the system comprises a real-time sequence database and a historical time sequence database, wherein the real-time sequence database stores industrial time sequence data with the reporting time within a first set time length before the current time, the historical time sequence database stores industrial time sequence data with the reporting time within a second set time length before the current time, and the second set time length is greater than the first set time length;
if the time sequence database to be accessed is a real-time sequence database, inquiring industrial time sequence data matched with the data identification and the inquiry time range from the real-time sequence database;
and if the time sequence database to be accessed is a historical time sequence database, inquiring the industrial time sequence data matched with the data identification and the inquiry time range from the historical time sequence database.
Preferably, the real-time series database includes: a first real-time data sub-base and a second real-time data sub-base;
the first real-time data sub-base stores industrial time sequence data with the reporting time within a first set time length before the current time, and the second real-time data sub-base stores industrial time sequence data with the reporting time before the current time.
Preferably, the plurality of different time series databases respectively store processes of industrial time series data, and the processes include:
when a storage request aiming at target industrial time sequence data is received, analyzing a data type from the storage request;
judging whether the data type is the data type supported by the time sequence database;
if not, discarding the target industrial time sequence data;
and if so, storing the target industrial time sequence data into the time sequence database.
Preferably, the method further comprises:
and modifying the data types supported by the time sequence database according to a modification instruction aiming at the data types supported by the time sequence database.
Preferably, in a case that the time-series database is a historical time-series database, the storing the target industrial time-series data into the time-series database includes:
compressing the target industrial time sequence data to obtain compressed data;
and storing the compressed data in the historical time sequence database according to a storage mode that all fields of the same type of industrial time sequence data are respectively stored in different rows.
Preferably, in the case that the time-series database is an HBase-based historical time-series database, the storing the target industrial time-series data into the time-series database includes:
compressing the target industrial time sequence data to obtain compressed data;
storing the compressed data in a first column cluster in the HBase-based historical time sequence database according to a storage mode that data of each field of the same type of industrial time sequence data are respectively stored in different columns;
and performing aggregation calculation on the target industrial time sequence data within a third set time length to obtain an aggregation result, and storing the aggregation result in a second column cluster in the HBase-based historical time sequence database.
An access system for industrial time series data, comprising: a plurality of different time series databases, the plurality of different time series databases comprising: the system comprises a real-time sequence database and a historical time sequence database, wherein the real-time sequence database stores industrial time sequence data with the reporting time within a first set time length before the current time, the historical time sequence database stores industrial time sequence data with the reporting time within a second set time length before the current time, and the second set time length is greater than the first set time length; an analysis module; a selection module; a first query module and a second query module;
the analysis module is used for analyzing a data identifier and an inquiry time range from the industrial time series data inquiry request when the industrial time series data inquiry request is received;
the selection module is used for selecting one of the plurality of different time sequence databases as a time sequence database to be accessed according to the query time range;
the first query module is used for querying industrial time sequence data matched with the data identifier and the query time range from the real-time sequence database if the time sequence database to be accessed is a real-time sequence database;
and the second query module is used for querying the industrial time sequence data matched with the data identifier and the query time range from the historical time sequence database if the time sequence database to be accessed is the historical time sequence database.
Preferably, the real-time series database includes: a first real-time data sub-base and a second real-time data sub-base;
the first real-time data sub-base stores industrial time sequence data with the reporting time within a first set time length before the current time, and the second real-time data sub-base stores industrial time sequence data with the reporting time before the current time.
Preferably, the method further comprises the following steps:
a storage module to:
when a storage request aiming at target industrial time sequence data is received, analyzing a data type from the storage request;
judging whether the data type is the data type supported by the time sequence database;
if not, discarding the target industrial time sequence data;
and if so, storing the target industrial time sequence data into the time sequence database.
Preferably, the method further comprises the following steps:
and the modification module is used for modifying the data types supported by the time sequence database according to the modification instruction aiming at the data types supported by the time sequence database.
Preferably, in a case that the time-series database is a historical time-series database, the storage module is specifically configured to:
compressing the target industrial time sequence data to obtain compressed data;
and storing the compressed data in the historical time sequence database according to a storage mode that all fields of the same type of industrial time sequence data are respectively stored in different rows.
Preferably, in the case that the time-series database is an HBase-based historical time-series database, the storage module is specifically configured to:
compressing the target industrial time sequence data to obtain compressed data;
storing the compressed data in a first column cluster in the HBase-based historical time sequence database according to a storage mode that data of each field of the same type of industrial time sequence data are respectively stored in different columns;
and performing aggregation calculation on the target industrial time sequence data within a third set time length to obtain an aggregation result, and storing the aggregation result in a second column cluster in the HBase-based historical time sequence database.
Compared with the prior art, the beneficial effect of this application is:
in the application, the time sequence database is divided into a real-time sequence database and a historical time sequence database, the real-time sequence database stores less and new data compared with the historical time sequence database, the query is preferentially carried out from the real-time sequence database under the condition that the time sequence database to be accessed is the real-time sequence database and the historical time sequence database, and the data stored in the real-time sequence database is small, so that the query workload can be reduced, the query efficiency is improved, and the performance of the query function of the time sequence database is improved.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application discloses an access method of industrial time sequence data, which comprises the following steps: when an industrial time series data query request is received, analyzing a data identifier and a query time range from the industrial time series data query request; determining a time sequence database to be accessed according to the query time range, wherein the time sequence database to be accessed comprises: the system comprises a real-time sequence database or a historical time sequence database, wherein the real-time sequence database stores industrial time sequence data with the reporting time within a first set time length before the current time, the historical time sequence database stores industrial time sequence data with the reporting time within a second set time length before the current time, and the second set time length is greater than the first set time length; if the time sequence database to be accessed is a real-time sequence database and a historical time sequence database, inquiring industrial time sequence data matched with the data identification and the inquiry time range from the real-time sequence database; and if the time sequence database to be accessed is a historical time sequence database, inquiring the industrial time sequence data matched with the data identification and the inquiry time range from the historical time sequence database. In the present application, the performance of the query function can be improved.
Next, a method for accessing industrial time series data disclosed in an embodiment of the present application is described, where the method for accessing industrial time series data is applied to a time series database, and as shown in fig. 1, a flowchart of an embodiment 1 of the method for accessing industrial time series data provided by the present application may include the following steps:
and step S11, when an industrial time series data query request is received, analyzing a data identifier and a query time range from the industrial time series data query request.
The data identification can be understood as: unique identification of a certain type of industrial time series data. Each type of industrial time sequence data has unique identification, so that the industrial time sequence data is convenient to store and search. For example, industrial timing data for an electric machine includes: power usage and power consumption, the power usage being identified as 1 and the power consumption being identified as 2. The electricity consumption and the power consumption are distinguished by different identifiers and are convenient to search.
And inquiring the industrial time sequence data of the corresponding time period from the time sequence database according to the inquiry time range. If the query time range is from the start time to the end time, the industrial time series data with the time period from the start time to the end time can be queried from the time series database.
And step S12, selecting one of the time sequence databases as a time sequence database to be accessed according to the query time range.
In this embodiment, a plurality of different time series databases may be provided. And different time sequence databases are respectively provided with an inquiry interface for inquiry. The plurality of different time series databases may include: a real-time timing database and a historical timing database. The real-time sequence database and the historical time sequence database comprise industrial time sequence data in different time ranges. If so, the real-time sequence database stores industrial time sequence data with the reporting time within a first set time length before the current time, and the historical time sequence database stores industrial time sequence data with the reporting time within a second set time length before the current time, wherein the second set time length is greater than the first set time length.
The reporting time can be understood as: the industrial time series data is reported to the time of the time series database.
Because each time sequence database comprises the industrial time sequence data in different time ranges, and each time sequence database respectively corresponds to different time ranges, one time sequence database can be selected from a plurality of different time sequence databases to be used as the time sequence database to be accessed according to the query time range.
The first set time period can be flexibly set according to actual needs, for example, the first set time period can be set to 1 hour.
Of course, the second set time duration may also be flexibly set according to actual needs, for example, the second set time duration may be set as a difference between the current time and the starting time.
And step S13, if the time sequence database to be accessed is a real-time sequence database and a historical time sequence database, inquiring industrial time sequence data matched with the data identification and the inquiry time range from the real-time sequence database.
And if the time sequence database to be accessed is a real-time sequence database and a historical time sequence database, inquiring the industrial time sequence data matched with the data identification and the inquiry time range from the real-time sequence database, wherein the inquiring workload is small and the inquiring efficiency is high compared with the inquiring of the industrial time sequence data matched with the data identification and the inquiry time range from the historical time sequence database.
In this embodiment, the real-time sequence database may include, but is not limited to: a first real-time data sub-base and a second real-time data sub-base.
The first real-time data sub-base stores industrial time sequence data with the reporting time within a first set time length before the current time, and the second real-time data sub-base stores industrial time sequence data with the reporting time before the current time.
It can be understood that the second real-time database stores the industrial time sequence data of the previous time when the reporting time is the current time, that is, the second real-time database stores the latest reported industrial time sequence data.
When the time sequence database to be accessed is the second real-time database, the first real-time database and the historical time sequence database, the time sequence database to be accessed can be preferentially selected from the second real-time database
And step S14, if the time sequence database to be accessed is a historical time sequence database, inquiring industrial time sequence data matched with the data identification and the inquiry time range from the historical time sequence database.
Because the industrial time sequence data in the real-time sequence database is less than the data in the historical time sequence database, under the condition that the time sequence database to be accessed is determined to be the historical time sequence database, the industrial time sequence data matched with the data identifier and the query time range needs to be queried from the historical time sequence database, and the query reliability is ensured.
In embodiment 2 of the present application, a process of storing industrial time series data in a plurality of different time series databases in embodiment 1 is described, as shown in fig. 2, the process may include the following steps:
and step S21, when a storage request aiming at the target industrial time series data is received, analyzing the data type from the storage request.
The data types may include, but are not limited to: string, Boolean, Long or Float types.
And step S22, judging whether the data type is the data type supported by the time sequence database.
It is understood that the types of data supported by the sequential database may be predetermined, e.g., the sequential database may be predetermined to support String and Boolean.
If not, go to step S23; if yes, go to step S24.
In this embodiment, the time sequence database provides a modification interface for receiving a modification instruction for a data type supported by the time sequence database.
The process of modifying the data types supported by the time series database can comprise the following steps: and modifying the data types supported by the time sequence database according to a modification instruction aiming at the data types supported by the time sequence database.
And step S23, discarding the target industrial time series data.
When the analyzed data type is not the data type supported by the time sequence database, the time sequence database cannot normally analyze and store the data, and therefore the target industrial time sequence data needs to be discarded.
And step S24, storing the target industrial time sequence data into the time sequence database.
The process of storing the target industrial timing data to the timing database may include:
and S241, sending the target industrial time sequence data to a message middleware, and storing the target industrial time sequence data in a set storage time length by the message middleware.
The message middleware stores the target industrial time sequence data within the set storage duration, and can facilitate external access.
And S242, reading the target industrial time sequence data from the message middleware by the time sequence database and storing the target industrial time sequence data.
As embodiment 3 of the present application, it is mainly a refinement of the process of storing industrial time series data in a plurality of different time series databases described in the above embodiment 2, as shown in fig. 3, the method may include, but is not limited to, the following steps:
and step S31, when a storage request aiming at the target industrial time series data is received, analyzing the data type from the storage request.
And step S32, judging whether the data type is the data type supported by the time sequence database.
If not, go to step S33; if not, step S34 is executed.
And step S33, discarding the target industrial time series data.
The detailed procedures of steps S31-S33 can be referred to the related descriptions of steps S21-S23 in embodiment 2, and are not described herein again.
And step S34, compressing the target industrial time sequence data to obtain compressed data under the condition that the time sequence database is a historical time sequence database.
And step S35, storing the compressed data in the historical time sequence database according to the storage mode that each field of the same type of industrial time sequence data is stored in different rows.
According to the storage mode that all fields of the same type of industrial time sequence data are stored in different rows, the compressed data are stored in the historical time sequence database, and all fields of the industrial time sequence data can be stored respectively, so that the query efficiency is improved when a certain field of the industrial time sequence data is queried.
And the compressed data is stored in the historical time sequence database, so that the storage space of the historical time sequence database can be saved.
Steps S34-S35 are a specific implementation of step S24 in example 2.
As embodiment 4 of the present application, it is mainly a refinement of the process of storing industrial time series data in a plurality of different time series databases described in the above embodiment 2, as shown in fig. 4, the method may include, but is not limited to, the following steps:
and step S41, when a storage request aiming at the target industrial time series data is received, analyzing the data type from the storage request.
And step S42, judging whether the data type is the data type supported by the time sequence database.
If not, go to step S43; if yes, go to step S44.
And step S43, discarding the target industrial time series data.
And step S44, compressing the target industrial time sequence data to obtain compressed data under the condition that the time sequence database is a historical time sequence database based on HBase.
In this embodiment, the HBase-based historical timing database may be configured such that a data table is automatically created every month, the data of the month is stored in the same data table, and the data table may be composed of a row key internal ID, a field name, a field type, and a time stamp (hour). Row keys of time series data of the same kind and the same hour can be set to be the same.
And step S45, storing the compressed data in a first column cluster in the HBase-based historical time sequence database according to a storage mode that data of each field of the same type of industrial time sequence data are respectively stored in different columns.
And step S46, performing aggregation calculation on the target industrial time sequence data within a third set time length to obtain an aggregation result, and storing the aggregation result in a second cluster in the HBase-based historical time sequence database.
Performing an aggregation calculation on the target industrial time series data within a third set time length may include, but is not limited to: and calculating the maximum value, the minimum value, the average value, the total point number, the first value or the last value of the target industrial time sequence data within the third set time length, and respectively returning a calculation result.
The third set period of time may be, but is not limited to: for 1 hour.
In this embodiment, the aggregation calculation result is stored separately, so that the query efficiency of the aggregation result can be improved.
Next, the access system of the industrial time series data provided by the present application is described, and the access system of the industrial time series data described below and the access method of the industrial time series data described above are referred to correspondingly.
Referring to fig. 5, the system for accessing industrial time series data includes: a plurality of different time series databases DB, a parsing module 11, a selection module 12, a first query module 13 and a second query module 14.
The plurality of different time series databases DB are denoted as DB1, DB2, …, DBn, respectively. n is an integer greater than 1.
The plurality of different time-series database DBs include: the system comprises a real-time sequence database and a historical time sequence database, wherein the real-time sequence database stores industrial time sequence data with the reporting time within a first set time length before the current time, the historical time sequence database stores industrial time sequence data with the reporting time within a second set time length before the current time, and the second set time length is greater than the first set time length; an analysis module; a selection module; a first query module and a second query module;
the analysis module 11 is configured to, when receiving an industrial time series data query request, analyze a data identifier and a query time range from the industrial time series data query request;
the selection module 12 is configured to select one of the multiple different time sequence databases as a time sequence database to be accessed according to the query time range;
the first query module 13 is configured to query, if the time sequence database to be accessed is a real-time sequence database, industrial time sequence data matched with the data identifier and the query time range from the real-time sequence database;
the second query module 14 is configured to query, if the time sequence database to be accessed is a historical time sequence database, industrial time sequence data matched with the data identifier and the query time range from the historical time sequence database.
In this embodiment, the real-time sequence database may include: a first real-time data sub-base and a second real-time data sub-base;
the first real-time data sub-base stores industrial time sequence data with the reporting time within a first set time length before the current time, and the second real-time data sub-base stores industrial time sequence data with the reporting time before the current time.
In this embodiment, the access system for the industrial time series data may further include:
a storage module to:
when a storage request aiming at target industrial time sequence data is received, analyzing a data type from the storage request;
judging whether the data type is the data type supported by the time sequence database;
if not, discarding the target industrial time sequence data;
and if so, storing the target industrial time sequence data to the time sequence database DB.
In this embodiment, the access system for the industrial time series data may further include:
and the modification module is used for modifying the data types supported by the time sequence database DB according to the modification instruction aiming at the data types supported by the time sequence database DB.
In this embodiment, in a case that the time sequence database DB is a historical time sequence database, the storage module may be specifically configured to:
compressing the target industrial time sequence data to obtain compressed data;
and storing the compressed data in the historical time sequence database according to a storage mode that all fields of the same type of industrial time sequence data are respectively stored in different rows.
In this embodiment, in a case that the time sequence database DB is an HBase-based historical time sequence database, the storage module may be specifically configured to:
compressing the target industrial time sequence data to obtain compressed data;
storing the compressed data in a first column cluster in the HBase-based historical time sequence database according to a storage mode that data of each field of the same type of industrial time sequence data are respectively stored in different columns;
and performing aggregation calculation on the target industrial time sequence data within a third set time length to obtain an aggregation result, and storing the aggregation result in a second column cluster in the HBase-based historical time sequence database.
It should be noted that each embodiment is mainly described as a difference from the other embodiments, and the same and similar parts between the embodiments may be referred to each other. For the device-like embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
From the above description of the embodiments, it is clear to those skilled in the art that the present application can be implemented by software plus necessary general hardware platform. Based on such understanding, the technical solutions of the present application may be essentially or partially implemented in the form of a software product, which may be stored in a storage medium, such as a ROM/RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments or some parts of the embodiments of the present application.
The above detailed description is provided for the method and system for accessing industrial time series data, and specific examples are applied herein to explain the principles and embodiments of the present application, and the description of the above embodiments is only used to help understand the method and core ideas of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.