Data storage method, device and equipment and computer readable medium
By obtaining and synchronizing the metadata and database files of the time series database, the problem of old data overwriting in the time series database is solved, and the effectiveness and utilization of the data are improved.
Patent Information
- Application Number
- CN202410970927.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-19
- Publication Date
- 2024-10-01
AI Technical Summary
Old data in existing time series databases are overwritten by new data, causing earlier data to be averaged and aggregated, resulting in the loss of original data and reducing data utilization.
By obtaining the metadata information of the time series database, construct the data storage format of the external database, and call the encapsulated update request to obtain the identity of the data source and database file in the time series database, and synchronize to the external database according to the data storage format to store the time series. Update parameters in the database.
The identification of the data source in the time series database is stored in an external database corresponding to the data at each time point. The storage time limit can be set as needed, which improves the effectiveness of the data in the time series database and thus improves data utilization.
Smart Images

Figure CN118733657A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cloud computing technology, and in particular to a method, device, equipment and computer-readable medium for storing data. Background Art
[0002] Time series databases are mainly used to process data with time tags, that is, data that changes in time order. Data with time tags is also called time series data. Time series databases are used to store various indicator data.
[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art: old data in time series data may be overwritten by new data, and earlier data may be averaged and aggregated, resulting in the loss of original data. Summary of the invention
[0004] In view of this, embodiments of the present invention provide a method, apparatus, device and computer-readable medium for storing data, which can improve the validity of data in a time series database and thus improve data utilization.
[0005] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for storing data is provided, comprising:
[0006] In response to an external database storage request, obtaining metadata information of the time series database through a development interface of the time series database, the metadata information including an identifier of a data source, a collection time interval, and an update parameter;
[0007] According to the identifier of the data source and the collection time interval, construct a data storage format of the data source in an external database, wherein the data storage format includes a data storage precision corresponding to the identifier of the data source;
[0008] Call the encapsulated update request according to the collection time interval, obtain the database file corresponding to the collection of the identification of the data source in the time series database, and synchronize the corresponding database file to the external database according to the data storage format to store the update parameters in the database file in the external database.
[0009] The step of obtaining metadata information of the time series database through a development interface of the time series database in response to an external database storage request, wherein the metadata information includes an identifier of a data source, a collection time interval, and update parameters, includes:
[0010] In response to an external database storage request, an information acquisition command is used through the development interface of the time series database to acquire metadata information of the time series database, wherein the metadata information includes an identifier of a data source, a collection time interval, and an update parameter.
[0011] According to the identifier of the data source and the collection time interval, a data storage format of the data source in the external database is constructed, wherein the data storage format includes the data storage precision corresponding to the identifier of the data source, including:
[0012] Using the identifier of the data source and the collection time interval as fields to construct a library table of the data source in an external database, and using the library table as a data storage format of the data source in the external database;
[0013] The data storage precision in the time series database is used as the data storage precision corresponding to the identifier of the data source in the data storage format.
[0014] The calling of the encapsulated update request acquires, in the time series database, a database file corresponding to the identifier of the data source after the acquisition according to the acquisition time interval, including:
[0015] Based on the aggregation time period in the metadata information, identifying an extraction data time period for obtaining the collected data;
[0016] In the data extraction time period of the collected data, a package update request is called to obtain a database file corresponding to the identifier of the data source after the collection in the time series database.
[0017] The identifying, based on the aggregation time period in the metadata information, a data extraction time period for obtaining the collected data includes:
[0018] Locate the aggregation time point based on the current collection time interval and the aggregation time period in the metadata information;
[0019] The time period between the current collection time point and the aggregation time point is identified as the data extraction time period for obtaining the collection data.
[0020] The step of synchronizing the corresponding database file to the external database according to the data storage format so as to store the updated parameters in the time series database in the external database includes:
[0021] Establishing a database synchronization file using the corresponding database file according to the data storage format;
[0022] The database file corresponding to the identifier of the data source in the external database is updated according to the database synchronization file, and the update parameters in the time series database are stored in the external database.
[0023] The step of synchronizing the corresponding database file to the external database according to the data storage format so as to store the updated parameters in the time series database in the external database includes:
[0024] Establishing a database synchronization file of the collection time based on the corresponding database file according to the data storage format and the collection time of the corresponding database file;
[0025] A data synchronization queue is constructed with the database synchronization file of the acquisition time, and a database file corresponding to the identifier of the data source in the external database is updated according to the data synchronization queue to store the update parameters in the time series database in the external database.
[0026] According to a second aspect of an embodiment of the present invention, there is provided a device for storing data, including:
[0027] An acquisition module, configured to respond to an external database storage request and acquire metadata information of the time series database through a development interface of the time series database, wherein the metadata information includes an identifier of a data source, a collection time interval, and an update parameter;
[0028] A construction module, configured to construct a data storage format of the data source in an external database according to the identifier of the data source and the collection time interval, wherein the data storage format includes a data storage precision corresponding to the identifier of the data source;
[0029] A synchronization module is used to call the encapsulated update request according to the collection time interval, obtain the corresponding database file after the identification of the data source is collected in the time series database, and synchronize the corresponding database file to the external database according to the data storage format to store the update parameters in the database file in the external database.
[0030] According to a third aspect of an embodiment of the present invention, there is provided an electronic device for storing data, including:
[0031] one or more processors;
[0032] a storage device for storing one or more programs,
[0033] When the one or more programs are executed by the one or more processors, the one or more processors implement the above method.
[0034] According to a fourth aspect of an embodiment of the present invention, there is provided a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the method as described above is implemented.
[0035] According to a fifth aspect of an embodiment of the present invention, a computer program product is provided, including a computer program, and when the program is executed by a processor, the method as described above provided by an embodiment of the present invention is implemented.
[0036] One embodiment of the above invention has the following advantages or beneficial effects: in response to an external database storage request, metadata information of the time series database is obtained through the development interface of the time series database, and the metadata information includes the identifier of the data source, the collection time interval and the update parameters; according to the identifier of the data source and the collection time interval, the data storage format of the data source in the external database is constructed, and the data storage format includes the data storage accuracy corresponding to the identifier of the data source; the encapsulated update request is called according to the collection time interval to obtain the database file corresponding to the identifier of the data source in the time series database, and the corresponding database file is synchronized to the external database according to the data storage format, so as to store the update parameters in the database file in the external database. The data corresponding to each time point of the identifier of the data source in the time series database is stored in the external database, and the storage time limit can be set as needed, thereby improving the validity of the data in the time series database, and further improving the data utilization rate.
[0037] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0039] Figure 1 is a schematic diagram of the main flow of a method for storing data according to an embodiment of the present invention;
[0040] Figure 2 is a schematic diagram of a process of constructing a data storage format of a data source in an external database according to an embodiment of the present invention;
[0041] Figure 3 is a schematic diagram of a process of obtaining a database file corresponding to an identifier of a data source after collection in a time series database according to an embodiment of the present invention;
[0042] Figure 4 is a schematic diagram of a process of obtaining a time period of extracted data for collected data according to an embodiment of the present invention;
[0043] Figure 5is a schematic diagram of a process of synchronizing a corresponding database file to an external database according to an embodiment of the present invention;
[0044] Figure 6 is another schematic diagram of a process of synchronizing a corresponding database file to an external database according to an embodiment of the present invention;
[0045] Figure 7 is a schematic diagram of the main structure of a device for storing data according to an embodiment of the present invention;
[0046] Figure 8 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0047] Fig. 9 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0048] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description. The acquisition, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.
[0049] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0050] Time series databases include multiple databases. As an example, RRDTool is a time series database that is used to store various indicator data and display the data in the form of images as needed. RRDTool is simple and efficient, and can meet the data storage needs of certain scenarios.
[0051] RRDtool has built-in data round-robin mechanism, which means it will automatically overwrite old data in a fixed-size database, which is a key feature for saving space and optimizing performance.
[0052] However, this feature will inevitably lead to the overwriting of some key data. Generally, the storage granularity and retention time of data can be controlled by setting appropriate data collection intervals, heartbeat intervals and archiving methods. Increase the number of archived data and / or the retention time of each archived data.
[0053] RRDtool stores fixed-size data sets, and once a file is created, the data collection interval and heartbeat interval stored in it will not change. In addition, old data will be overwritten by new data, and older data may be averaged and aggregated, resulting in the loss of original data.
[0054] In summary, the use of time series databases is prone to data loss, which makes data analysis impossible and reduces data utilization.
[0055] In order to solve the problem of reduced data utilization caused by data loss, the following technical solutions in the embodiments of the present invention may be adopted.
[0056] See also Figure 1 , Figure 1 1 is a schematic diagram of the main flow of a method for storing data according to an embodiment of the present invention, wherein data in a time series database is synchronized in an external database according to a data storage format. Figure 1 As shown in 100, the following steps are specifically included:
[0057] S101. In response to an external database storage request, metadata information of a time series database is obtained through a development interface of the time series database, where the metadata information includes an identifier of a data source, a collection time interval, and update parameters.
[0058] A time series database is a database management system optimized for storing, retrieving, analyzing, and processing time series data. Time series data is data points recorded in chronological order, usually consisting of a timestamp and one or more values associated with it. In order to obtain the data in a time series database, it is necessary to obtain the metadata information in the time series database.
[0059] Specifically, in response to an external database storage request, metadata information of the time series database is obtained through a development interface of the time series database. The external database storage request is a request sent by a user through an instruction to obtain metadata information from the time series database.
[0060] As an example, metadata information includes the identifier of the data source, the collection time interval, and the update parameter. The identifier of the data source is used to identify the data source. Based on the identifier of the data source, the data of the specified data source can be filtered out in the time series database. The collection time interval is the data collection cycle. Different data source identifiers may correspond to different data collection time intervals. The update parameter is the identifier of the data source field. For example, the update parameter includes: network switch interface traffic.
[0061] In one embodiment of the present invention, in response to an external database storage request, an information acquisition command is used through the development interface of the time series database to acquire metadata information of the time series database, and the metadata information includes an identifier of a data source, a collection time interval, and update parameters.
[0062] In one embodiment of the present invention, after obtaining the metadata information of the time series database, it is necessary to verify the metadata information to ensure the integrity and accuracy of the metadata information, so as to ensure the reliability of the data and the validity of the subsequent stored data. For example: verify that the data source identifier, collection time interval and update parameter corresponding fields in the metadata exist and are not missing. The integrity verification of the metadata information is implemented. Then, verify that the values of the data source identifier, collection time interval and update parameter corresponding fields in the metadata are within the preset range to implement accurate verification of the metadata information. As an example, the time series database includes rrdtool, and the information acquisition command includes the rrdtool info command. The rrdtool info command is used to read the rrdtool file to obtain metadata information. As an example, the metadata information includes: step size, data source and round-robin archive.
[0063] Step: The time interval for data collection.
[0064] Data sources (DS): includes the name, type (such as GAUGE, COUNTER, DERIVE, etc.), heartbeat time, minimum value, maximum value, etc. As an example, the data source includes a sensor and / or a storage device.
[0065] Round Robin Archives (RRA): Defines how to merge data points into larger time intervals. This includes the merge function, the number of data points per merge cycle, the length of each cycle, and the amount of data saved in these cycles.
[0066] S102: construct a data storage format of the data source in an external database according to the identifier of the data source and the collection time interval, where the data storage format includes the data storage accuracy corresponding to the identifier of the data source.
[0067] In an embodiment of the present invention, the time series database corresponds to an external database. The external database may be a non-time series database. The validity period of the stored data is preset in the external database. For example, the validity period of the stored data is preset to be permanent. The data in the time series database is stored in the external database. Since the data in the time series database will be archived after a period of time, the original data cannot be obtained again after being overwritten. The data can be stored from the time series database to the external database, so that the data in the time series database can be obtained in the external database.
[0068] In order to store the data in the time series database in the external database, it is necessary to establish the data storage format in the external database. According to the identification of the data source and the collection time interval, the data storage format of the data source in the external database is constructed. The data storage format includes the data storage accuracy corresponding to the identification of the data source.
[0069] In the embodiment of the present invention, in order to ensure the data storage accuracy, the data storage format in the external database includes the data storage accuracy corresponding to the identifier of the data source. That is, the data storage accuracy in the external database is the same as the data storage accuracy in the time series database, and the data storage accuracy will not be reduced due to the change of the storage database.
[0070] As an example, the data storage precision of data a is 5 decimal places. When data a is stored from the time series database to the external database, the data storage precision of data a remains unchanged, and the data storage precision of data a is 5 decimal places.
[0071] See also Figure 2 That is 200, Figure 2 The present invention is a flowchart of constructing a data storage format of a data source in an external database according to an embodiment of the present invention, which specifically includes the following steps.
[0072] S201. Use the identifier of the data source and the collection time interval as fields to construct a library table of the data source in the external database, and use the library table as the data storage format of the data source in the external database.
[0073] In one embodiment of the present invention, the data in the time series database is stored in the external database in the form of a library table. Specifically, the identifier of the data source and the collection time interval are used as fields to construct a library table of the data source in the external database, and the library table is used as the data storage format of the data source in the external database.
[0074] Using database tables to store data allows efficient query, sorting, and filtering of data. In addition, since external databases support multiple data operations, including one or more of insert, delete, update, and query, they can meet the data needs of different business scenarios.
[0075] In one embodiment of the present invention, creating an index with a timestamp field in a database table can significantly improve query efficiency. The timestamp field is the acquisition time point of the database file. S202, using the data storage accuracy in the time series database as the data source identifier corresponding to the data storage accuracy in the data storage format.
[0076] In the embodiment of the present invention, in order to ensure the data storage accuracy to meet the accuracy requirements of the used data, the data storage accuracy in the time series database is used as the data storage accuracy corresponding to the identifier of the data source in the data storage format.
[0077] In this way, even if the database storing data is changed from a time series database to an external database, the data storage accuracy will not be affected by the change of the database.
[0078] exist Figure 2 In the embodiment, the library table is used as the data storage format of the data source in the external database, and the data storage accuracy is guaranteed.
[0079] S103: Call the encapsulated update request to obtain the corresponding database file after the data source identifier is collected in the time series database according to the collection time interval, and synchronize the corresponding database file to the external database according to the data storage format to store the update parameters in the database file in the external database.
[0080] In an embodiment of the present invention, the encapsulated update request is called to obtain the database file corresponding to the data source identifier after the data source identifier is collected in the time series database according to the collection time interval. According to the current time point and the collection time interval, data can be collected in the time series database at the collection time interval. Specifically, in order to obtain the data corresponding to the data source identifier, the database file corresponding to the data source identifier after the data source identifier is collected is obtained in the time series database.
[0081] After the database file is acquired, the corresponding database file is synchronized to the external database according to the data storage format, so as to store the updated parameters in the database file in the external database.
[0082] In one embodiment of the present invention, the time series database includes rrdtool, and the encapsulation update request includes rrdupdate. Calling the encapsulation update request may include: encapsulating with a script and calling rrdupdate.
[0083] See also Figure 3 That is 300, Figure 3 The present invention is a flowchart of obtaining a database file corresponding to an identifier of a data source after collection in a time series database according to an embodiment of the present invention. The flowchart specifically includes the following steps.
[0084] S301. Based on the aggregation time period in the metadata information, identify the data extraction time period for obtaining the collected data.
[0085] In a time series database, an aggregation time period is set for the data in the data source. The data in the aggregation time period is merged and processed to store data according to the aggregation time period. It is understandable that the merged data is different from the original data, and the merged data will directly overwrite or delete the original data. Therefore, it is necessary to obtain data within the aggregation time period to ensure data integrity.
[0086] Specifically, based on the aggregation time period in the metadata information, the data extraction time period for acquiring the collected data is identified. That is, for the aggregation time period in the metadata information, the data extraction time period for the collected data is determined. Acquiring data within the data extraction time period ensures data integrity because data will not be deleted or overwritten.
[0087] See also Figure 4 That is 400, Figure 4 The flowchart of obtaining the data extraction time period of the collected data according to the embodiment of the present invention is shown in FIG.
[0088] S401: Locate the aggregation time point based on the current collection time interval and the aggregation time period in the metadata information.
[0089] The aggregation time period is generally greater than the collection time interval. The aggregation time point is located based on the current collection time interval and the aggregation time period in the metadata information. The current collection time interval is determined based on the current time point, and the aggregation operation time point of the aggregation time period after the collection time point of the current collection time interval is used as the aggregation time point.
[0090] As an example, the current time point is 12:01, and the current collection time interval is determined to be 30 minutes. The collection time point of the current collection time interval is 12:30. The aggregation time period is 2 hours. The aggregation operation time point of the aggregation time period after the collection time point of the current collection time interval is 14:00, and the aggregation time point is 14:00.
[0091] S402: Identify the time period between the current collection time point and the aggregation time point as a data extraction time period for obtaining the collected data.
[0092] In the time period between the current collection time point and the aggregation time point, no merging operation is performed, so the time period between the current collection time point and the aggregation time point can be identified as the data extraction time period for obtaining the collection data.
[0093] As an example, the current collection time point is 12:30, and the aggregation time point is 14:00, then the extracted data time period for obtaining the collected data is from 12:30 to 14:00.
[0094] exist Figure 4 In the embodiment, data needs to be extracted before merging the data, so it is necessary to determine a data extraction time period for obtaining the collected data.
[0095] S302: within the data extraction time period of the collected data, call the encapsulation update request to obtain a database file corresponding to the identifier of the collected data source in the time series database.
[0096] During the data extraction time period of the collected data, the encapsulated update request is called to obtain the database file corresponding to the identifier of the data source after the collection in the time series database. The database file is the data collected according to the collection time interval. Based on the identifier of the data source, the database file corresponding to the identifier of the data source is obtained in the time series database.
[0097] exist Figure 3 In an embodiment, obtaining a database file in a time series database during a data extraction time period can improve the integrity of the database file.
[0098] See also Figure 5 That is 500, Figure 5 The flowchart of synchronizing the corresponding database file to the external database according to the embodiment of the present invention is shown in FIG.
[0099] S501. Create a database synchronization file using a corresponding database file according to a data storage format.
[0100] After obtaining the database file, you can create a database synchronization file according to the data storage format to prepare for storage in an external database.
[0101] S502: Update the database file corresponding to the identifier of the data source in the external database according to the database synchronization file, and store the update parameters in the time series database in the external database.
[0102] The database files are stored in the external database according to the identifier of the data source. As an example, the database files are stored according to the time when the data was collected and the identifier of the data source.
[0103] The database file corresponding to the identifier of the data source in the external database is updated according to the database synchronization file. Specifically, in the external database, based on the identifier of the data source and the data collection time, the database file is updated while retaining the original database file. The updated database file is the collection data of the latest collection data time.
[0104] After the database file is updated, the updated parameters in the time series database are stored in the external database. As an example, the network switch interface traffic in the database file is stored as an updated parameter in the external database. In this way, the data of the network switch interface traffic at multiple time points are recorded in the external database.
[0105] exist Figure 5 In the embodiment, the database file in the external database is updated according to the data storage format to achieve the storage of the time series database data in the external database.
[0106] See also Figure 6 That is 600, Figure 6 This is another schematic diagram of a process of synchronizing a corresponding database file to an external database according to an embodiment of the present invention, which specifically includes the following steps.
[0107] S601: Create a database synchronization file of the collection time based on the corresponding database file according to the data storage format and the collection time of the corresponding database file.
[0108] In the embodiment of the present invention, considering that the amount of data stored in the external database by the time series database is large, a queue method can be used to implement data storage in the external database.
[0109] Based on the corresponding database file, a database synchronization file of the acquisition time is established according to the data storage format and the acquisition time of the corresponding database file, and the database synchronization file is identified according to the acquisition time.
[0110] S602: construct a data synchronization queue with the database synchronization file of the acquisition time, and update the database file corresponding to the identifier of the data source in the external database according to the data synchronization queue to store the update parameters in the time series database in the external database.
[0111] The data synchronization queue is constructed with the database synchronization file of the acquisition time, and the database synchronization files corresponding to the identifiers of multiple data sources may be included in the data synchronization queue. The database file corresponding to the identifier of the data source in the external database is updated according to the data synchronization queue to store the update parameters in the time series database in the external database.
[0112] In one embodiment of the present invention, the timeliness of data synchronization update is considered. When the timeliness requirement is high, the database file corresponding to the identifier of the data source in the external database is synchronously updated according to the data synchronization queue. That is, after the data synchronization queue is updated, the database file corresponding to the identifier of the data source in the external database is synchronously updated immediately to improve the timeliness of the data in the external database.
[0113] In the case of low timeliness requirements, the database file corresponding to the identifier of the data source in the external database is asynchronously updated according to the data synchronization queue. That is to say, after the data synchronization queue is updated, the database file corresponding to the identifier of the data source in the external database does not need to be synchronously updated immediately, and the database file corresponding to the identifier of the data source in the external database is updated in a preset time period.
[0114] exist Figure 6 In the embodiment, a queue is used to implement storage in an external database, and asynchronous storage is used to implement storing data in a time series database into an external database.
[0115] In the above-mentioned embodiment of the present invention, in response to an external database storage request, metadata information of the time series database is obtained through the development interface of the time series database, and the metadata information includes the identifier of the data source, the collection time interval and the update parameters; according to the identifier of the data source and the collection time interval, the data storage format of the data source in the external database is constructed, and the data storage format includes the data storage accuracy corresponding to the identifier of the data source; the encapsulated update request is called according to the collection time interval to obtain the database file corresponding to the identifier of the data source in the time series database, and the corresponding database file is synchronized to the external database according to the data storage format, so as to store the update parameters in the database file in the external database. The data corresponding to each time point of the identifier of the data source in the time series database is stored in the external database, and the storage time limit can be set as needed, thereby improving the validity of the data in the time series database, and further improving the data utilization rate.
[0116] See also Figure 7 , Figure 7 is a schematic diagram of the main structure of a device for storing data according to an embodiment of the present invention. The device for storing data can implement a method for storing data, such as Figure 7 As shown in 700, the device for storing data specifically includes:
[0117] The acquisition module 701 is used to respond to the external database storage request and obtain the metadata information of the time series database through the development interface of the time series database, wherein the metadata information includes the identifier of the data source, the collection time interval and the update parameter;
[0118] A construction module 702 is used to construct a data storage format of the data source in an external database according to the identifier of the data source and the collection time interval, wherein the data storage format includes a data storage precision corresponding to the identifier of the data source;
[0119] The synchronization module 703 is used to call the encapsulated update request according to the collection time interval, obtain the database file corresponding to the collection of the identifier of the data source in the time series database, and synchronize the corresponding database file to the external database according to the data storage format to store the update parameters in the database file in the external database.
[0120] In one embodiment of the present invention, the acquisition module 701 is specifically used to respond to an external database storage request, and to obtain metadata information of the time series database through the development interface of the time series database using an information acquisition command, wherein the metadata information includes an identifier of a data source, a collection time interval, and update parameters.
[0121] In one embodiment of the present invention, the construction module 702 is specifically used to construct a library table of the data source in the external database by using the identifier of the data source and the collection time interval as fields, and use the library table as the data storage format of the data source in the external database;
[0122] The data storage precision in the time series database is used as the data storage precision corresponding to the identifier of the data source in the data storage format.
[0123] In one embodiment of the present invention, the synchronization module 703 is specifically used to identify the extraction data time period for obtaining the collected data based on the aggregation time period in the metadata information;
[0124] In the data extraction time period of the collected data, a package update request is called to obtain a database file corresponding to the identifier of the data source after the collection in the time series database.
[0125] In one embodiment of the present invention, the synchronization module 703 is specifically used to locate the aggregation time point based on the current collection time interval and the aggregation time period in the metadata information;
[0126] The time period between the current collection time point and the aggregation time point is identified as the data extraction time period for obtaining the collection data.
[0127] In one embodiment of the present invention, the synchronization module 703 is specifically used to establish a database synchronization file using the corresponding database file according to the data storage format;
[0128] The database file corresponding to the identifier of the data source in the external database is updated according to the database synchronization file, and the update parameters in the time series database are stored in the external database.
[0129] In one embodiment of the present invention, the synchronization module 703 is specifically used to establish a database synchronization file of the acquisition time based on the corresponding database file according to the data storage format and the acquisition time of the corresponding database file;
[0130] A data synchronization queue is constructed with the database synchronization file of the acquisition time, and a database file corresponding to the identifier of the data source in the external database is updated according to the data synchronization queue to store the update parameters in the time series database in the external database.
[0131] Figure 8 An exemplary system architecture 800 is shown to which the method for storing data or the apparatus for storing data according to the embodiments of the present invention can be applied.
[0132] like Figure 8 As shown, system architecture 800 may include terminal devices 801, 802, 803, a network 804, and a server 805. Network 804 is used to provide a medium for communication links between terminal devices 801, 802, 803 and server 805. Network 804 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0133] Users can use terminal devices 801, 802, and 803 to interact with server 805 through network 804 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 801, 802, and 803, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0134] The terminal devices 801 , 802 , and 803 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0135] The server 805 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 801, 802, and 803. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.
[0136] It should be noted that the method for storing data provided in the embodiment of the present invention is generally executed by the server 805 , and accordingly, the device for storing data is generally arranged in the server 805 .
[0137] It should be understood that Figure 8The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0138] A computer program product according to an embodiment of the present invention includes a computer program, and when the program is executed by a processor, the method for storing data provided by the embodiment of the present invention is implemented.
[0139] Reference below Fig. 9 , which shows a schematic diagram of the structure of a computer system 900 of a terminal device suitable for implementing an embodiment of the present invention. Fig. 9 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0140] like Fig. 9 As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the system 900 are also stored. The CPU 901, the ROM 902, and the RAM 903 are connected to each other through a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0141] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.
[0142] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the central processing unit (CPU) 901, the above-mentioned functions defined in the system of the present invention are executed.
[0143] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0144] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0145] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor, for example, they may be described as: a processor including an acquisition module, a construction module and a synchronization module. The names of these modules do not constitute limitations on the modules themselves in some cases. For example, the acquisition module may also be described as "used to respond to an external database storage request, obtain metadata information of the time series database through the development interface of the time series database, and the metadata information includes an identifier of a data source, a collection time interval and an update parameter".
[0146] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes:
[0147] In response to an external database storage request, obtaining metadata information of the time series database through a development interface of the time series database, the metadata information including an identifier of a data source, a collection time interval, and an update parameter;
[0148] According to the identifier of the data source and the collection time interval, construct a data storage format of the data source in an external database, wherein the data storage format includes a data storage precision corresponding to the identifier of the data source;
[0149] Call the encapsulated update request according to the collection time interval, obtain the database file corresponding to the collection of the identification of the data source in the time series database, and synchronize the corresponding database file to the external database according to the data storage format to store the update parameters in the database file in the external database.
[0150] According to the technical solution of the embodiment of the present invention, in response to an external database storage request, the metadata information of the time series database is obtained through the development interface of the time series database, and the metadata information includes the identifier of the data source, the collection time interval and the update parameters; according to the identifier of the data source and the collection time interval, the data storage format of the data source in the external database is constructed, and the data storage format includes the data storage accuracy corresponding to the identifier of the data source; the encapsulated update request is called according to the collection time interval to obtain the database file corresponding to the identifier of the data source in the time series database, and the corresponding database file is synchronized to the external database according to the data storage format, so as to store the update parameters in the database file in the external database. The data corresponding to each time point of the identifier of the data source in the time series database is stored in the external database, and the storage time limit can be set as needed, thereby improving the validity of the data in the time series database, and further improving the data utilization rate.
[0151] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
[0152] It should be noted that in the technical solution of the present invention, the collection, analysis, use, transmission, storage and other aspects of user personal information involved are in compliance with the provisions of relevant laws and regulations, are used for legal and reasonable purposes, are not shared, leaked or sold outside of these legal uses, and are subject to supervision and management by regulatory authorities. Necessary measures should be taken for user personal information to prevent illegal access to such personal information data, ensure that persons who have access to personal information data comply with the provisions of relevant laws and regulations, and ensure the security of user personal information. Once these user personal information data are no longer needed, the risks should be minimized by limiting or even prohibiting data collection and / or deleting data.
[0153] When applicable, including in certain relevant applications, protect user privacy by de-identifying data, such as by removing specific identifiers (e.g., date of birth, etc.) when applicable, controlling the amount or specificity of data stored (e.g., collecting location data at a city level rather than at a specific address level), controlling how data is stored, and / or other de-identification methods.
Claims
1. A method for storing data, characterized in that: include: In response to an external database storage request, obtaining metadata information of the time series database through a development interface of the time series database, the metadata information including an identifier of a data source, a collection time interval, and an update parameter; According to the identifier of the data source and the collection time interval, construct a data storage format of the data source in an external database, wherein the data storage format includes a data storage precision corresponding to the identifier of the data source; Call the encapsulated update request according to the collection time interval, obtain the database file corresponding to the collection of the identification of the data source in the time series database, and synchronize the corresponding database file to the external database according to the data storage format to store the update parameters in the database file in the external database.
2. The method for storing data according to claim 1, characterized in that: The step of obtaining metadata information of the time series database through a development interface of the time series database in response to an external database storage request, wherein the metadata information includes an identifier of a data source, a collection time interval, and update parameters, includes: In response to an external database storage request, an information acquisition command is used through the development interface of the time series database to acquire metadata information of the time series database, wherein the metadata information includes an identifier of a data source, a collection time interval, and an update parameter.
3. The method for storing data according to claim 1, characterized in that: According to the identifier of the data source and the collection time interval, a data storage format of the data source in the external database is constructed, wherein the data storage format includes the data storage precision corresponding to the identifier of the data source, including: Using the identifier of the data source and the collection time interval as fields to construct a library table of the data source in an external database, and using the library table as a data storage format of the data source in the external database; The data storage precision in the time series database is used as the data storage precision corresponding to the identifier of the data source in the data storage format.
4. The method for storing data according to claim 1, characterized in that: The calling of the encapsulated update request acquires, in the time series database, a database file corresponding to the identifier of the data source after the acquisition according to the acquisition time interval, including: Based on the aggregation time period in the metadata information, identifying an extraction data time period for obtaining the collected data; In the data extraction time period of the collected data, a package update request is called to obtain a database file corresponding to the identifier of the data source after the collection in the time series database.
5. The method for storing data according to claim 4, characterized in that: The identifying, based on the aggregation time period in the metadata information, a data extraction time period for obtaining the collected data includes: Locate the aggregation time point based on the current collection time interval and the aggregation time period in the metadata information; The time period between the current collection time point and the aggregation time point is identified as the data extraction time period for obtaining the collection data.
6. The method for storing data according to claim 1, characterized in that: The step of synchronizing the corresponding database file to the external database according to the data storage format so as to store the updated parameters in the time series database in the external database includes: Establishing a database synchronization file using the corresponding database file according to the data storage format; The database file corresponding to the identifier of the data source in the external database is updated according to the database synchronization file, and the update parameters in the time series database are stored in the external database.
7. The method for storing data according to claim 1, characterized in that: The step of synchronizing the corresponding database file to the external database according to the data storage format so as to store the updated parameters in the time series database in the external database includes: Establishing a database synchronization file of the collection time based on the corresponding database file according to the data storage format and the collection time of the corresponding database file; A data synchronization queue is constructed with the database synchronization file of the acquisition time, and a database file corresponding to the identifier of the data source in the external database is updated according to the data synchronization queue to store the update parameters in the time series database in the external database.
8. A device for storing data, characterized in that: include: An acquisition module, configured to respond to an external database storage request and acquire metadata information of the time series database through a development interface of the time series database, wherein the metadata information includes an identifier of a data source, a collection time interval, and an update parameter; A construction module, configured to construct a data storage format of the data source in an external database according to the identifier of the data source and the collection time interval, wherein the data storage format includes a data storage precision corresponding to the identifier of the data source; A synchronization module is used to call the encapsulated update request according to the collection time interval, obtain the corresponding database file after the identification of the data source is collected in the time series database, and synchronize the corresponding database file to the external database according to the data storage format to store the update parameters in the database file in the external database.
9. An electronic device for storing data, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
