Storage method, computing device and storage medium for time series data
By obtaining and merging the target file collection from the time series database, and performing sequential storage through object storage, the need for long-term storage and real-time query of large-scale time series data is solved, and a low-cost and efficient storage solution is realized to meet the needs of Query requirements for second-level response time.
Patent Information
- Application Number
- CN202210200209.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-02
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2042-03-02
AI Technical Summary
Under the demand for long-term storage of large-scale time series data, it is difficult for existing technologies to provide low-cost storage solutions while meeting the needs of real-time queries, especially within second-level response times.
Obtain the target file set from the time series database, merge the files with the same number of merges, and store the files through object storage to ensure that the index metainformation is sorted in order, realizing the long-term storage function of cold data and reducing storage costs.
It achieves low-cost long-term storage while meeting real-time query requirements, providing second-level response time, reducing storage costs and improving data query efficiency.
Smart Images

Figure CN114676130B
Abstract
Description
Technical Field
[0001] The present application relates to the field of data storage, and in particular to a storage method, computing device and storage medium for time series data. Background Art
[0002] Time series data refers to a series of data indexed by time dimension. The collection, processing and analysis of time series data can realize real-time monitoring of production and operation processes. However, under the demand for long-term storage of large-scale time series data, it is necessary to provide a low-cost long-term storage solution that can also meet the needs of real-time query. Summary of the invention
[0003] Multiple aspects of the present application provide a storage method, computing device, and storage medium for time series data, which can reduce storage costs while meeting real-time query requirements.
[0004] An embodiment of the present application provides a method for storing time series data, which obtains a target file set corresponding to the time series data from a time series database, wherein no data is written to the target file set within a preset time; merges multiple files in the target file set to generate multiple merged files, wherein the multiple merged files have the same number of merges to indicate that the compression degree of the merged files is the same, and the first field corresponding to the merged file is sorted according to a sequence so that the corresponding index is sorted in sequence; the merged files in the target file set are stored through object storage, so that index meta information corresponding to the merged file is recorded through the object storage, and the index meta information records description information of the corresponding index, the description information of the corresponding index is sorted in sequence, and the description information of the corresponding index contains a second field sorted in sequence, and the first field corresponds to the second field.
[0005] An embodiment of the present application also provides a computing device, including: a memory, a processor; the memory is used to store a computer program; the processor executes the computer program to: obtain a target file set corresponding to the time series data from a time series database, and no data is written to the target file set within a preset time; merge multiple files in the target file set to generate multiple merged files, and the multiple merged files have the same number of merges to indicate that the compression degree of the merged files is the same, and the first field corresponding to the merged file is sorted in sequence so that the corresponding index is sorted in sequence; the merged files in the target file set are stored in file through object storage, so that the index meta information corresponding to the merged file is recorded through the object storage, and the index meta information records the description information of the corresponding index, the description information of the corresponding index is sorted in sequence, and the description information of the corresponding index contains a second field sorted in sequence, and the first field corresponds to the second field.
[0006] An embodiment of the present application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by one or more processors, the one or more processors implement the steps in the above method.
[0007] In an embodiment of the present application, a target file set corresponding to time series data is obtained from a time series database, and no data is written to the target file set within a preset time; multiple files in the target file set are merged to generate multiple merged files, and the multiple merged files have the same number of merges to indicate that the compression degree of the merged files is the same, and the first field corresponding to the merged file is sorted in sequence so that the corresponding index is sorted in sequence; the merged files in the target file set are stored through object storage, so that the index meta information corresponding to the merged file is recorded through the object storage, and the index meta information records the description information of the corresponding index, the description information of the corresponding index is sorted in sequence, and the description information of the corresponding index contains a second field sorted in sequence, and the first field corresponds to the second field.
[0008] The merged files in the target file set are stored through object storage, so that the index meta information corresponding to the merged files is recorded through the object storage, and the index meta information records the description information of the corresponding index, and the description information of the corresponding index is sorted in sequence, and the description information of the corresponding index contains a second field sorted in sequence. So that the function of cold data long-term storage can be realized through object storage, and the cost is relatively low, and it can meet the needs of real-time query (response in seconds). BRIEF DESCRIPTION OF THE DRAWINGS
[0009] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0010] Figure 1 A schematic flow chart of a method for storing time series data according to an exemplary embodiment of the present application;
[0011] Figure 2 A schematic diagram of the structure of a storage system for time series data according to an exemplary embodiment of the present application;
[0012] Figure 3 A schematic diagram of the structure of a storage device for time series data provided by an exemplary embodiment of the present application;
[0013] Figure 4 A schematic diagram of the structure of a computing device provided for an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0014] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0015] As we can see from the previous article, in order to meet the demand for long-term storage of large-scale time series data, a low-cost long-term storage solution is needed, which also needs to be able to meet the needs of real-time queries.
[0016] In response to the above problems, the embodiments of the present application provide a storage method, computing device and storage medium for time series data, which can reduce storage costs while meeting real-time query requirements.
[0017] The following is a detailed description of the storage process of time series data in conjunction with the method embodiment.
[0018] Figure 1 This is a flow chart of a method for storing time series data in an exemplary embodiment of the present application. The method 100 provided in the embodiment of the present application is executed by a time series database, which can be an engine in a time series database, namely a TSDB (Time Series Database) engine. The method 100 includes the following steps:
[0019] 101: Obtain a target file set corresponding to the time series data from the time series database.
[0020] There is no data written to the target file set within a preset time.
[0021] 102: Merge multiple files in the target file set to generate multiple merged files. The multiple merged files have the same number of merges to indicate that the compression levels of the merged files are the same. The first fields corresponding to the merged files are sorted in sequence so that the corresponding indexes are sorted in sequence.
[0022] 103: The merged files in the target file set are stored through object storage, so that the index meta information corresponding to the merged files is recorded through the object storage, the index meta information records the description information of the corresponding index, the description information of the corresponding index is sorted in sequence, and the description information of the corresponding index includes a second field sorted in sequence.
[0023] The first field corresponds to the second field.
[0024] The following is a detailed description of the above steps:
[0025] 101: Obtain a target file set corresponding to the time series data from the time series database.
[0026] The target file set has no data written into it within a preset time. For example, if no data point is written into the file set within a month, the file set can be used as the target file set.
[0027] A file set may refer to a set consisting of multiple files, and the set may be a shard set in a time series database, and the shard has multiple files.
[0028] The file includes multiple data and multiple indexes corresponding to the multiple data, the index has a corresponding first field, and the file has an identifier of the number of merges. For example, the file can be an underlying storage file in time series data, which can be composed of two major parts: series block data and series key index first field index (i.e. index, the index contains the first field). The file can be a TSM file (which refers to a file in TSM format). In a shard, a TSM file can have a corresponding number of merges, which can also be called a generation. The following is the structure of a shard:
[0029] …………
[0030] ├──[2.0G]000009571-000000002.tsm
[0031] ├──[2.0G]000009571-000000003.tsm
[0032] ├──[2.0G]000009571-000000004.tsm
[0033] ├──[2.0G]000009572-000000005.tsm
[0034] ├──[2.0G]000009572-000000006.tsm
[0035] ├──[2.0G]000009572-000000007.tsm
[0036] ├──[2.0G]000009573-000000008.tsm
[0037] ├──[2.0G]000009573-000000009.tsm
[0038] ├──[2.0G]000009574-000000010.tsm
[0039] ├──[918M]000009574-000000011.tsm
[0040] …………
[0041] The upper limit of a single TSM file is 2G (gigabyte) in size. The TSM file naming format is generation_seq.tsm, where seq is a sequence number, such as a serial number. Therefore, it can be determined that in a shard, the number of merges in the file 000009571-000000002.tsm is 000009571.
[0042] As a result, the engine can obtain multiple shards from the time series database and select the shards to which no data has been written within a preset period of time as cold shards, that is, the target file collection.
[0043] 102: Merge multiple files in the target file set to generate multiple merged files, wherein the multiple merged files have the same number of merges to indicate that the compression levels of the merged files are the same, and the first fields corresponding to the merged files are sorted in order (such as dictionary order) so that the corresponding indexes are sorted in order (such as dictionary order).
[0044] According to the above, when the number of generations is larger, it means that the number of merges is larger and the compression degree is larger. The file merging method can be combined by compression.
[0045] For example, according to the above, after the engine obtains the cold shard, it can merge the same generation in the cold shard, such as merging 000009571-000000002.tsm and 000009571-000000003.tsm. The series_key in the merged TSM file is sorted by dictionary, and the series_key of each file in the cold shard is also sorted by dictionary.
[0046] Specifically, multiple files in a target file set are merged to generate multiple merged files, including: merging files in the target file set with the same number of merges to generate a merged file, and the number of merges of the merged file is increased by one, so that the number of merges of the files finally merged in the target file set is the same; sorting the corresponding first fields in the merged files according to sequence, and sorting the first fields corresponding to the multiple merged files according to sequence (such as dictionary order), so that the indexes with the corresponding first fields are sorted in sequence (such as dictionary order).
[0047] For example, according to the above, the engine can use the full compactor to globally merge the compactors. A global compactor for a cold shard eventually reaches the merged final state, merging the TSM files of the same generation in the cold shard to generate the next generation, that is, the number of merges increases by one. For example, 000009571-000000002.tsm and 000009571-000000003.tsm are merged, and the generation increases from 000009571 to 000009572, so that the merged final states all belong to the same generation. The final form of the coldshard can be as follows:
[0048] …
[0049] ├──[2.0G]000009571-000000002.tsm
[0050] ├──[2.0G]000009571-000000003.tsm
[0051] ├──[2.0G]000009571-000000004.tsm
[0052] ├──[2.0G]000009571-000000005.tsm
[0053] ├──[2.0G]000009571-000000006.tsm
[0054] ├──[2.0G]000009571-000000007.tsm
[0055] ├──[2.0G]000009571-000000008.tsm
[0056] ├──[2.0G]000009571-000000009.tsm
[0057] ├──[2.0G]000009571-000000010.tsm
[0058] ├──[918M]000009571-000000011.tsm
[0059] …
[0060] From this we can see that the files in the final form all belong to the 000009571 generation.
[0061] According to the above, after the files are merged, each file page has a corresponding serial number, such as the serial number in the 000009571-000000009.tsm file is 000000009.
[0062] Specifically, the method 100 further includes: when the files have the same number of merging times, sorting the files according to the serial number identifiers corresponding to the files; and determining the serial number identifier of the corresponding first field according to the serial number identifier.
[0063] According to the above, seq can be used to represent the sorting order of files. The seq sorting order is also the dictionary sorting of the first field of series_key in the target file set, and the internal index of a single TSM file is also sorted by dictionary. The dictionary sorting can be performed by the minimum heap algorithm, that is, it can be sorted in order.
[0064] It should be noted that, as can be seen in the previous text, generation means that each time the file merge compactor generates the next generation of TSM files, and each time the merge compactor is triggered, generation increases by 1.
[0065] The target file set can be obtained in a scheduled manner or proactively to ensure that data is transferred before the file expires.
[0066] Specifically, the method 100 also includes: obtaining a file set corresponding to the time series data from a time series database, merging multiple files in the file set to generate multiple merged files, and the first fields corresponding to the merged files are sorted in sequence so that the corresponding indexes are sorted in sequence; when no data is written to the file set within a preset time, the step of obtaining a target file set corresponding to the time series data from the time series database is executed.
[0067] For example, as described above, the engine can obtain multiple shards from the time series database, and then merge the files according to the method described above. The first field corresponding to the merged file is sorted in order so that the corresponding index is sorted in order. I will not go into details. Then the engine needs to obtain the cold shard before the shard expires and is deleted. Then perform a local full compactor on the cold shard to ensure that the series keys are sorted in the dictionary within the TSM file and between files. I will not go into details.
[0068] 103: The merged files in the target file set are stored through object storage, so that the index meta information corresponding to the merged files is recorded through the object storage, the index meta information records the description information of the corresponding index, the description information of the corresponding index is sorted in sequence, and the description information of the corresponding index includes a second field sorted in sequence.
[0069] Among them, Object Storage Service (OSS) is a massive, secure, low-cost, and highly reliable cloud storage service. By transferring historical cold data cold shards to OSS object archiving storage, the function of long-term storage of cold data is solved, while the cost is relatively low and it can meet the needs of real-time queries (response in seconds).
[0070] The first field corresponds to the second field. For example, according to the above, after the engine obtains the shard after the full compactor, it transfers the shard to the object storage for storage of the shard. After storage, under the organizational structure of the object storage, there is corresponding index meta information: meta file, which describes the basic meta information of the index file list, which is used for fast binary query, and in which index file the queried series key is located. Among them, the meta file stores auxiliary information such as minkey, maxkey, Tag key-value pairs, mintime and maxtime in order. The meta file belongs to BlockMeta block meta information (index meta). Among them, minkey (minimum field, that is, belonging to the second field) corresponds to the minimum dictionary order series key in the slice (that is, belonging to the first field), maxkey (maximum field, that is, belonging to the second field) corresponds to the maximum dictionary order series key in the slice (that is, belonging to the first field), mintime (minimum time) corresponds to the minimum time in the slice, and maxtime (maximum time) corresponds to the maximum time in the slice. In this way, data query can be performed.
[0071] The information in the meta file is sorted in order. Its format can be as follows:
[0072] {"min_t":XXX,"max_t":YYY,"min_key":"AAA","max_key":BBB","block_size":CCC,"seq":1}
[0073] {"min_t":XXX,"max_t":YYY,"min_key":"DDD","max_key":"EEE","block_size":FFF,"seq":2}
[0074] For easy storage, it can be uploaded in slices.
[0075] Specifically, the method 100 also includes: determining the cutting granularity of the merged file according to the first field corresponding to the merged file in the target file set and the corresponding index entry; transmitting the merged file for storage according to the cutting granularity and the sequence identifier corresponding to the merged file in the target file set.
[0076] For example, according to the above, when uploading the above shard, the engine can upload files in order, such as uploading by seq number, uploading by slices on demand, and the minimum granularity of cutting is series key block (first field block) and serieskey index entry (index entry containing the first field). That is, the first field with the smallest granularity can be formed by taking block as the unit, and the corresponding index entry as the index of the smallest granularity, to cut the file and obtain slices. Then, upload the corresponding slices according to the order corresponding to the serial number.
[0077] Specifically, according to the cutting granularity and the sequence identifier corresponding to the merged file in the target file set, the merged file is transmitted for storage, including: according to the serial number identifier, the corresponding data of the merged file in the target file set is stored through object storage according to the cutting granularity; according to the serial number identifier, the corresponding index of the merged file in the target file set is indexed and stored through object storage according to the cutting granularity, and the storage file where the data is located corresponds to the storage file where the index is located.
[0078] For example, during the upload process, the engine uploads the slices according to the above minimum granularity. The Block and index of the merged TSM file are stored separately in objects, one object stores the block data, and the other object stores the index. That is, one block data file and one index file, the two correspond one to one.
[0079] Specifically, the merged files in the target file set are stored through object storage, including: according to the serial number identifier, the files in the target file set are cut according to the granularity, and the corresponding data is stored through object storage; according to the serial number identifier, the files in the target file set are cut according to the granularity, and the corresponding index is indexed and stored through object storage, and the storage file where the data is located corresponds to the storage file where the index is located.
[0080] Since this has been explained in the previous article, I will not repeat it here.
[0081] It should be noted that during the slice upload process, you can set the TTL (Time To Live) value of the slice object Object and use the OSS Tag elimination policy to set the Object expiration time.
[0082] The organization structure of the stored OSS files is as follows:
[0083] Bucket (dividing clusters and regions)
[0084] ---DB (tenant or user)
[0085] --shard time
[0086] --hash slot (distributed cluster slot)
[0087] ----BlockData(block data)
[0088] -----1.block
[0089] -----2.block
[0090] ----BlockIndex(index data index)
[0091] -----1.idx
[0092] -----2.idx
[0093] -----BlockMeta (index meta index meta information)
[0094] -----meta (index meta information)
[0095] After the storage is completed, the data can be queried.
[0096] Specifically, the method 100 also includes: receiving a first field to be queried, determining corresponding index metadata and a corresponding index based on the first field to be queried and the second field in the index metadata; determining corresponding data based on the corresponding index; and obtaining corresponding time series data based on the logical location of the corresponding data.
[0097] For example, according to the foregoing, the engine may receive a query request, which may carry the series_key to be queried. The request may be a query request sent by a user through a computer, which is used to query a certain time series data. The engine determines the corresponding key second field from the minkey and maxkey in the above meta through the known series_key to be queried, and then determines the corresponding index index, and queries the corresponding block file or data through the index. Once the offset of the block file where the series key to be queried starts and ends is located, the required time series compression block can be pulled through the GetRange function, reducing other unnecessary download bandwidth costs.
[0098] In this way, we can quickly locate the index description file of the Tsm file through the known series key, determine the index, and finally locate the block file.
[0099] It should be noted that during the transfer stage, the Tsm file is sliced in the above manner and can support real-time query requirements through secondary indexes.
[0100] This embodiment can also be stored locally through a local disk or cloud disk storage method, but this method has an upper limit on storage capacity, does not utilize capacity expansion, and has a relatively high storage cost.
[0101] After testing, by pulling the tsar command monitoring data with the same data size and time span, it was determined that the OSS cold storage method in the embodiment of the present application has met the final demand. On the basis of significantly reducing the cost of cold data, the query is responded to in seconds.
[0102] Figure 2 The following is a schematic diagram of a storage system for time series data provided by an exemplary embodiment of the present application. Figure 2 As shown, the system 200 may include: a first device 201 and a second device 202. The system 200 may also include a third device 203.
[0103] The first device 201 refers to a device that can provide computing and processing services in a network virtual environment, and can refer to a device that uses a network to transfer data. In physical implementation, the first device 201 can be any device that can provide computing services, respond to service requests, and determine the similarity of binary files, such as a cloud server, a cloud host, a virtual center, a conventional server, etc. The first device 201 mainly includes a processor, a memory, a hard disk, a system bus, etc., which is similar to a general computer architecture.
[0104] The implementation form of the second device 202 is similar to that of the first device 201, and will not be described in detail.
[0105] The third device 203 refers to a smart terminal, such as a computer, through which a user can access the second device 202.
[0106] Specifically, the first device 201 obtains a target file set corresponding to the time series data from a time series database, wherein no data is written to the target file set within a preset time; merges multiple files in the target file set to generate multiple merged files, wherein the multiple merged files have the same number of merges to indicate that the compression degree of the merged files is the same, and the first field corresponding to the merged file is sorted in sequence, so that the corresponding index is sorted in sequence; the merged files in the target file set are stored through object storage, so that the index meta-information corresponding to the merged file is recorded through the object storage, and the index meta-information records the description information of the corresponding index, the description information of the corresponding index is sorted in sequence, and the description information of the corresponding index contains a second field sorted in sequence, and the first field corresponds to the second field.
[0107] Among them, the first device 201 implements object storage through the second device 202.
[0108] The file includes multiple data and multiple indexes corresponding to the multiple data, the index has a corresponding first field, and the file has an identifier of the number of merges.
[0109] Specifically, the first device 201 merges files with the same number of merges in the target file set to generate a merged file, and the number of merges of the merged file is increased by one, so that the number of merges of the files finally merged in the target file set is the same; sorts the corresponding first fields in the merged file according to sequence, and sorts the first fields corresponding to multiple merged files according to sequence, so that the indexes with the corresponding first fields are sorted in sequence.
[0110] In addition, the first device 201, when the files have the same number of merging times, sorts them according to the serial number identifiers corresponding to the files; and determines the serial number identifier of the corresponding first field according to the serial number identifier.
[0111] In addition, the first device 201 obtains a file set corresponding to the time series data from the time series database, merges multiple files in the file set, and generates multiple merged files, and the first fields corresponding to the merged files are sorted in sequence so that the corresponding indexes are sorted in sequence; when no data is written to the file set within a preset time, the step of obtaining a target file set corresponding to the time series data from the time series database is executed.
[0112] In addition, the first device 201 determines the cutting granularity of the merged file based on the first field corresponding to the merged file in the target file set and the corresponding index entry; and transmits the merged file for storage based on the cutting granularity and the sequence identifier corresponding to the merged file in the target file set.
[0113] Specifically, the first device 201, according to the serial number identifier, stores the corresponding data through object storage according to the cutting granularity of the files after merging in the target file set; according to the serial number identifier, stores the corresponding index through object storage according to the cutting granularity of the files after merging in the target file set, and the storage file where the data is located corresponds to the storage file where the index is located.
[0114] In addition, the first device 201 receives the first field to be queried from the third device 203, determines the corresponding index meta-information and the corresponding index based on the first field to be queried and the second field in the index meta-information; determines the corresponding data based on the corresponding index; and obtains the corresponding timing data based on the logical location of the corresponding data.
[0115] For any incomplete content, please refer to the previous article and I will not repeat it here.
[0116] In the scenario of transferring time series data, the first device 201, such as time series data, wherein the engine can obtain multiple shards from the time series database, and select the shard to which no data is written within a preset time as the cold shard, that is, the target file set.
[0117] The engine can use the full compactor to globally merge the compactors. A global compactor for a cold shard eventually reaches the merged final state, merging the TSM files of the same generation in the cold shard to generate the next generation, that is, the number of merges increases by one. For example, 000009571-000000002.tsm and 000009571-000000003.tsm are merged, and the generation increases from 000009571 to 000009572, so that the merged final state belongs to the same generation. The final form of the cold shard can be as follows:
[0118] …
[0119] ├──[2.0G]000009571-000000002.tsm
[0120] ├──[2.0G]000009571-000000003.tsm
[0121] ├──[2.0G]000009571-000000004.tsm
[0122] ├──[2.0G]000009571-000000005.tsm
[0123] ├──[2.0G]000009571-000000006.tsm
[0124] ├──[2.0G]000009571-000000007.tsm
[0125] ├──[2.0G]000009571-000000008.tsm
[0126] ├──[2.0G]000009571-000000009.tsm
[0127] ├──[2.0G]000009571-000000010.tsm
[0128] ├──[918M]000009571-000000011.tsm
[0129] …
[0130] After the engine obtains the shard after the full compactor, it transfers the shard to the object storage for storage. That is, execute step 211: store the merged file. After storage, under the organizational structure of the object storage, there is corresponding index meta information: meta file, which describes the basic meta information of the index file list, which is used for fast binary query, and in which index file the queried series key is located. Among them, the meta file stores auxiliary information such as minkey, maxkey, Tag key-value pairs, mintime and maxtime in sequential rows. The meta file belongs to BlockMeta block meta information (indexmeta). Among them, minkey (minimum field, that is, belonging to the second field) corresponds to the minimum dictionary order series key (that is, belonging to the first field) in the slice, maxkey (maximum field, that is, belonging to the second field) corresponds to the maximum dictionary order serieskey (that is, belonging to the first field) in the slice, mintime (minimum time) corresponds to the minimum time in the slice, and maxtime (maximum time) corresponds to the maximum time in the slice. In this way, data query can be performed.
[0131] When uploading the above shards, the engine can upload files in order, such as uploading by seq number, uploading by slices on demand, and the minimum granularity of cutting is series key block (first field block) and series key index entry (index entry containing the first field). That is, the first field with the smallest granularity can be formed by taking blocks as units, and the corresponding index entries as the index of the smallest granularity, to cut the file and obtain slices. Then, upload the corresponding slices according to the order corresponding to the sequence number.
[0132] The engine can receive a query request sent by a third device 203 such as a computer, and the query request can carry the series_key to be queried. That is, execute step 212: send a query request. The request can be a query request sent by a user through a computer, which is used to query a certain time series data. The engine queries through the known series_key to be queried, that is, execute step 213: query the corresponding data, the engine determines the corresponding key second field from the minkey and maxkey in the above meta, and then determines the corresponding index index, and queries the corresponding block block file or data through the index. Once the offset of the block file where the series key to be queried starts and ends is located, the required time series compression block can be pulled by the GetRange function, that is, execute step 214: return the corresponding data, reducing other unnecessary download bandwidth costs. Finally, the corresponding data is returned to the computer, that is, execute step 215: send the found data.
[0133] For the contents not recorded in detail here, please refer to the previous content and I will not repeat them here.
[0134] In the above embodiment, the first device 201 is connected to the network with the second device 202 and the third device 203. The first device 201 is connected to the second device 202 and the third device 203 for communication, and the network standard of the mobile network can be any one of 2G (GSM), 2.5G (GPRS), 3G (WCDMA, TD-SCDMA, CDMA2000, UTMS), 4G (LTE), 4G+ (LTE+), WiMax, 5G, etc.
[0135] The first device 201 and the second device 202 may be implemented through a cluster.
[0136] Figure 3 A schematic diagram of the structural framework of a storage device for time series data provided by an exemplary embodiment of the present application. The device 300 can be applied to a processing node in a big data processing system, specifically a server. The device 300 includes: an acquisition module 301, a merging module 302, and a storage module 303; the functions of each module are described in detail below:
[0137] The acquisition module 301 is used to acquire a target file set corresponding to the time series data from a time series database.
[0138] There is no data written to the target file set within a preset time.
[0139] The merging module 302 is used to merge multiple files in the target file set to generate multiple merged files. The multiple merged files have the same number of merges to indicate that the compression degree of the merged files is the same. The first fields corresponding to the merged files are sorted in sequence so that the corresponding indexes are sorted in sequence.
[0140] The storage module 303 is used to store the merged files in the target file set through object storage, so that the index meta-information corresponding to the merged files is recorded through the object storage, and the index meta-information records the description information of the corresponding index. The description information of the corresponding index is sorted in sequence, and the description information of the corresponding index includes a second field sorted in sequence, and the first field corresponds to the second field.
[0141] The file includes multiple data and multiple indexes corresponding to the multiple data, the index has a corresponding first field, and the file has an identifier of the number of merges.
[0142] Specifically, the merging module 302 includes: a merging unit, which is used to merge files with the same number of merges in the target file set to generate a merged file, and the number of merges of the merged file is increased by one, so that the number of merges of the files finally merged in the target file set is the same; a sorting unit, which is used to sort the corresponding first fields in the merged file according to the sequence, and sort the first fields corresponding to multiple merged files according to the sequence, so that the indexes with the corresponding first fields are sorted in sequence.
[0143] In addition, the device 300 also includes: a sorting module, which is used to sort the files according to the serial number identifiers corresponding to the files when the files have the same number of merging times; and a determination module, which is used to determine the serial number identifier of the corresponding first field according to the serial number identifier.
[0144] In addition, the merging module 302 is also used to: obtain a file set corresponding to the time series data from the time series database, merge multiple files in the file set, generate multiple merged files, and the first fields corresponding to the merged files are sorted in sequence so that the corresponding indexes are sorted in sequence; when no data is written to the file set within a preset time, the step of obtaining a target file set corresponding to the time series data from the time series database is executed.
[0145] In addition, the determination module is also used to determine the cutting granularity of the merged file based on the first field corresponding to the merged file in the target file set and the corresponding index entry; the storage module 303 is also used to transmit the merged file for storage based on the cutting granularity and the sequence identifier corresponding to the merged file in the target file set.
[0146] In addition, the storage module 303 includes: a storage unit, which is used to store the corresponding data through object storage according to the cutting granularity of the files after merging in the target file set according to the serial number identification; a storage unit, which is used to index and store the corresponding index through object storage according to the cutting granularity of the files after merging in the target file set according to the serial number identification, and the storage file where the data is located corresponds to the storage file where the index is located.
[0147] In addition, the device 300 also includes: a receiving module, which is used to receive the first field to be queried, determine the corresponding index metadata based on the first field to be queried and the second field in the index metadata, and determine the corresponding index; a determination module, which is also used to determine the corresponding data based on the corresponding index; an acquisition module 301, which is also used to acquire the corresponding time series data based on the logical location of the corresponding data.
[0148] For details of the device 300 that are not fully described, please refer to the above description and will not be repeated here.
[0149] The above describes Figure 3 The internal functions and structure of the device 300 shown, in one possible design, Figure 3 The structure of the device 300 shown can be implemented as a server. Figure 4 As shown, the device 400 may include: a memory 401, a processor 402;
[0150] The memory 401 is used to store computer programs.
[0151] Processor 402 is used to execute a computer program to: obtain a target file set corresponding to the time series data from a time series database, where no data is written to the target file set within a preset time; merge multiple files in the target file set to generate multiple merged files, where the multiple merged files have the same number of merges to indicate that the compression degree of the merged files is the same, and the first field corresponding to the merged file is sorted in sequence so that the corresponding index is sorted in sequence; store the merged files in the target file set through object storage, so that the object storage records the index meta information corresponding to the merged file, the index meta information records the description information of the corresponding index, the description information of the corresponding index is sorted in sequence, and the description information of the corresponding index contains a second field sorted in sequence, and the first field corresponds to the second field.
[0152] The file includes multiple data and multiple indexes corresponding to the multiple data, the index has a corresponding first field, and the file has an identifier of the number of merges.
[0153] Specifically, processor 402 is specifically used to merge files with the same number of merges in the target file set to generate a merged file, and the number of merges of the merged file is increased by one so that the number of merges of the files finally merged in the target file set is the same; sort the corresponding first fields in the merged file according to the sequence, and sort the first fields corresponding to multiple merged files according to the sequence so that the indexes with the corresponding first fields are sorted in sequence.
[0154] In addition, the processor 402 is further configured to sort the files according to the serial number identifiers corresponding to the files when the files have the same number of merging times; and determine the serial number identifier of the corresponding first field according to the serial number identifier.
[0155] In addition, the processor 402 is also used to obtain a file set corresponding to the time series data from the time series database, merge multiple files in the file set, and generate multiple merged files, and the first fields corresponding to the merged files are sorted in sequence so that the corresponding indexes are sorted in sequence; when no data is written to the file set within a preset time, the step of obtaining a target file set corresponding to the time series data from the time series database is executed.
[0156] In addition, the processor 402 is also used to determine the cutting granularity of the merged file based on the first field corresponding to the merged file in the target file set and the corresponding index entry; and transmit the merged file for storage based on the cutting granularity and the sequence identifier corresponding to the merged file in the target file set.
[0157] Specifically, processor 402 is specifically used to store the corresponding data of the files merged in the target file set through object storage according to the cutting granularity according to the serial number identifier; and index and store the corresponding index of the files merged in the target file set through object storage according to the cutting granularity according to the serial number identifier, and the storage file where the data is located corresponds to the storage file where the index is located.
[0158] In addition, processor 402 is also used to receive the first field to be queried, determine the corresponding index metadata and the corresponding index based on the first field to be queried and the second field in the index metadata; determine the corresponding data based on the corresponding index; and obtain the corresponding time series data based on the logical location of the corresponding data.
[0159] For details of the device 400 that are not fully detailed, please refer to the previous description and will not be repeated here.
[0160] An embodiment of the present invention provides a computer storage medium, which, when a computer program is executed by one or more processors, causes the one or more processors to implement Figure 1The steps of a method for storing time series data in the method embodiment will not be described in detail.
[0161] In addition, in some of the processes described in the above embodiments and the accompanying drawings, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or executed in parallel, and the sequence numbers of the operations, such as 101, 102, 103, etc., are only used to distinguish between different operations, and the sequence numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., do not represent the order of precedence, and do not limit the "first" and "second" to be different types.
[0162] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0163] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by combining hardware and software. Based on such an understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a computer product, and the present invention can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0164] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable multimedia data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable multimedia data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1A device that provides the functions specified in a block or multiple blocks.
[0165] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable multimedia data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0166] These computer program instructions may also be loaded onto a computer or other programmable multimedia data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0167] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0168] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0169] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0170] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for storing time series data, characterized in that: include: Acquire a target file set corresponding to the time series data from a time series database, where no data is written to the target file set within a preset time; Merging multiple files in the target file set to generate multiple merged files, wherein the multiple merged files have the same number of merges to indicate that the compression levels of the merged files are the same, and the first fields corresponding to the merged files are sorted in sequence so that the corresponding indexes are sorted in sequence; The merged files in the target file set are stored through object storage, so that index meta-information corresponding to the merged files is recorded through the object storage, the index meta-information records description information of the corresponding index, the description information of the corresponding index is sorted in sequence, and the description information of the corresponding index includes a second field sorted in sequence, and the first field corresponds to the second field.
2. The method according to claim 1, characterized in that The file includes a plurality of data and a plurality of indexes corresponding to the plurality of data, the index has a corresponding first field, and the file has an identifier of the number of merges.
3. The method according to claim 1, characterized in that The step of merging the multiple files in the target file set to generate multiple merged files includes: Merge the files with the same merge times in the target file set to generate a merged file, and increase the merge times of the merged file by one, so that the merge times of the files finally merged in the target file set are the same; The corresponding first fields in the merged files are sorted in sequence, and the first fields corresponding to the plurality of merged files are sorted in sequence, so that the indexes having the corresponding first fields are sorted in sequence.
4. The method according to claim 1 or 3, characterized in that: The method further comprises: When the files have the same number of merging times, they are sorted according to the serial number identifiers corresponding to the files; According to the sequence number identifier, determine the sequence number identifier of the corresponding first field.
5. The method according to claim 1, characterized in that The method further comprises: Obtaining a file set corresponding to the time series data from a time series database, merging multiple files in the file set to generate multiple merged files, wherein the first fields corresponding to the merged files are sorted in sequence, so that the corresponding indexes are sorted in sequence; When no data is written to the file set within the preset time, the step of acquiring the target file set corresponding to the time series data from the time series database is executed.
6. The method according to claim 1, characterized in that The method further comprises: Determine the cutting granularity of the merged file according to the first field corresponding to the merged file in the target file set and the corresponding index entry; According to the cutting granularity and the sequence identifiers corresponding to the merged files in the target file set, the merged files are transmitted for storage.
7. The method according to claim 1, characterized in that The step of storing the merged files in the target file set through object storage includes: According to the serial number identifier, the merged files in the target file set are cut according to the granularity, and the corresponding data is stored in the object storage; According to the serial number identifier, the merged files in the target file set are indexed and stored through object storage according to the cutting granularity, and the storage file where the data is located corresponds to the storage file where the index is located.
8. The method according to claim 1, characterized in that The method further comprises: Receiving a first field to be queried, determining corresponding index meta-information according to the first field to be queried and a second field in the index meta-information, and determining a corresponding index; According to the corresponding index, determine the corresponding data; According to the logical position of the corresponding data, the corresponding time series data is obtained.
9. A computing device, characterized in that include: Memory, processor; The memory is used to store computer programs; The processor executes the computer program to: Acquire a target file set corresponding to the time series data from a time series database, where no data is written to the target file set within a preset time; Merging multiple files in the target file set to generate multiple merged files, wherein the multiple merged files have the same number of merges to indicate that the compression levels of the merged files are the same, and the first fields corresponding to the merged files are sorted in sequence so that the corresponding indexes are sorted in sequence; The merged files in the target file set are stored through object storage, so that index meta-information corresponding to the merged files is recorded through the object storage, the index meta-information records description information of the corresponding index, the description information of the corresponding index is sorted in sequence, and the description information of the corresponding index includes a second field sorted in sequence, and the first field corresponds to the second field.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by one or more processors, the one or more processors are caused to implement the steps of the method according to any one of claims 1 to 8.
