A time series data compression method, device, equipment and storage medium
By determining the compression step size and traversing the time series data to generate a parent time data set, the problem of long loading time for time series line charts in browsers is solved, achieving efficient compression and visualization of time series data processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI DAMENG DATABASE
- Filing Date
- 2022-06-08
- Publication Date
- 2026-06-23
AI Technical Summary
The long loading time of time-series line charts in browsers can lead to memory overflow, and existing technologies struggle to efficiently process large amounts of time-series data.
By obtaining the set of business models to be compressed, determining the compression step size, traversing and updating the temporary business models, recording the parent time data, and generating the parent time data set and the business model compression result set, the ordered compression of time series data is achieved.
It improves the compression efficiency of time series data, ensures the visualization effect of time series data, does not affect the trend of line charts, and records the original time data for reference.
Smart Images

Figure CN115065366B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database technology, and in particular to a method, apparatus, device, and storage medium for compressing time-series data. Background Technology
[0002] Time series data refers to data collected over time. It is a series of data recorded in chronological order, following a unified set of indicators. Time series data can be categorized into periods or points in time. Analyzing time series data can reveal within-sample statistical characteristics and patterns, as well as provide out-of-sample forecasting tools.
[0003] A time-series line chart is an image that visualizes data in chronological order over a specified time period. In a time-series line chart, each line segment is generally not a line connecting two points, but rather a line segment describing the trend of multiple data points within that time period.
[0004] However, if the time series line chart contains a large number of data points, the browser needs to load all the data points first when loading the time series line chart. This will result in a long loading time for the time series line chart, and may even lead to browser memory overflow. Summary of the Invention
[0005] This invention provides a method, apparatus, device, and storage medium for compressing time-series data, which solves the problem of long processing times for browsers when handling large amounts of time-series data and drawing time-series line graphs.
[0006] In a first aspect, embodiments of the present invention provide a method for compressing time-series data, comprising:
[0007] Obtain a set of business models to be compressed and determine the compression step size. The business models to be compressed in the set of business models to be compressed include original time series data, and the original time series data includes the correspondence between original time data and original indicator data.
[0008] Based on the temporary business model and the compression step size, the set of business models to be compressed is traversed, and the temporary business model is updated during the traversal process, and the parent time data is recorded. The temporary business model is used to cache temporary time-series data during the compression process, and the parent time data is used to indicate the original time data corresponding to the original indicator data that meets the preset feature requirements within the unit compression range corresponding to the compression step size.
[0009] Based on the traversal results, determine the parent class time data set and the business model compression result set.
[0010] Secondly, embodiments of the present invention provide a time-series data compression apparatus, comprising:
[0011] The compression step size determination module is used to obtain a set of business models to be compressed and determine the compression step size. The set of business models to be compressed includes original time series data, and the original time series data includes the correspondence between original time data and original indicator data.
[0012] The traversal module is used to traverse the set of business models to be compressed based on the temporary business model and the compression step size, update the temporary business model during the traversal process, and record the parent time data. The temporary business model is used to cache temporary time-series data during the compression process, and the parent time data is used to indicate the original time data corresponding to the original indicator data that meets the preset feature requirements within the unit compression range corresponding to the compression step size.
[0013] The compression result and parent time determination module is used to determine the parent time data set and the business model compression result set based on the traversal results.
[0014] Thirdly, embodiments of the present invention provide an electronic device, the electronic device comprising:
[0015] At least one processor;
[0016] and memory that is communicatively connected to at least one processor;
[0017] The memory stores a computer program that can be executed by at least one processor, which enables the at least one processor to perform the timing data compression method described in the first aspect.
[0018] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing computer instructions for causing a processor to execute the timing data compression method described in the first aspect.
[0019] The time-series data compression scheme provided in this embodiment of the invention obtains a set of business models to be compressed and determines a compression step size. The set of business models to be compressed includes original time-series data, which contains a correspondence between original time data and original indicator data. Based on a temporary business model and the compression step size, the set of business models to be compressed is traversed, and the temporary business model is updated during the traversal process. Parent time data is also recorded. The temporary business model is used to cache temporary time-series data during the compression process, and the parent time data indicates the original time data corresponding to the original indicator data that meets preset feature requirements within the unit compression range corresponding to the compression step size. Based on the traversal results, a set of parent time data and a set of business model compression results are determined. By adopting the above technical solution, the compression step size is first determined based on the set of business models to be compressed. Then, the set of business models to be compressed is traversed, the compressed data is cached in a temporary business model, and the parent time data is recorded. After the traversal is completed, the parent time data and the compression result of the business model can be determined. This solution compresses a large amount of time-series data in an orderly manner, which not only ensures the compression efficiency of time-series data, but also records the parent time data so that users can view the original time data.
[0020] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 This is a flowchart of a time-series data compression method provided according to Embodiment 1 of the present invention;
[0023] Figure 2 This is a time-series line chart of the same performance value of the same indicator for different objects, provided according to Embodiment 1 of the present invention;
[0024] Figure 3 This is a time-series line chart of the same object and the same indicator with different performance values provided in Embodiment 1 of the present invention;
[0025] Figure 4 This is a flowchart of a time-series data compression method provided according to Embodiment 2 of the present invention;
[0026] Figure 5 This is a flowchart of traversing a set of business models to be compressed according to Embodiment 2 of the present invention;
[0027] Figure 6 A schematic diagram of the structure of a time-series data compression device according to Embodiment 3 of the present invention;
[0028] Figure 7 This is a schematic diagram of the structure of an electronic device provided according to Embodiment 4 of the present invention. Detailed Implementation
[0029] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0030] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. In the description of this invention, unless otherwise stated, "a plurality of" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist; for example, A and / or B can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.
[0031] Example 1
[0032] Figure 1 The flowchart of a time-series data compression method provided in Embodiment 1 of the present invention is applicable to the compression of time-series data. The method can be executed by a time-series data compression device, which can be implemented in hardware and / or software. The time-series data compression device can be configured in an electronic device, which can be composed of two or more physical entities or a single physical entity.
[0033] like Figure 1 As shown, the time-series data compression method provided in Embodiment 1 of the present invention specifically includes the following steps:
[0034] S101. Obtain the set of business models to be compressed and determine the compression step size.
[0035] Among them, the business models to be compressed in the set of business models to be compressed include raw time series data, and the raw time series data contains the correspondence between raw time data and raw indicator data.
[0036] In this embodiment, the compression step size of the set of business models to be compressed can be determined based on the amount of data in the set, according to actual conditions such as the ratio of the actual amount of time-series data to the expected amount of time-series data. Here, a business model can be understood as a data packet used to store time-series data, which may include time data, objects, and indicator data. The compression step size can be understood as the range unit for compressing the time-series data. For example, a compression step size of 3 means that the range unit for compressing the time-series data is 3 time-series data, i.e., compression is performed once every 3 time-series data. The browser can draw time-series line charts based on the loaded time-series data. The time-series line charts can include time-series line charts of different objects with the same indicator and the same object with different indicator performance values, etc.
[0037] For example, Figure 2 A time-series line chart showing the same performance value of the same indicator for different objects, such as... Figure 2 As shown, Beijing, Shanghai, and Guangzhou are three different objects. The horizontal axis represents date, i.e., time data, and the vertical axis represents temperature values. Figure 2 The comparison focuses on the daily average temperature changes of various cities over a period of time. The daily average temperature is the performance value of temperature, i.e., the indicator data. Figure 2 The data presented is a time-series broken line representing the same indicator and the same performance value (daily average temperature) for different objects (cities).
[0038] For example, Figure 3 A time-series line chart showing different performance values of the same indicator for the same object, such as... Figure 3 As shown, the object is a database, the horizontal axis represents time data, and the vertical axis represents the number of sessions as a metric. Figure 3 The comparison focuses on the changes in the number of active sessions and the total number of sessions in the database over a period of time. The number of active sessions and the total number of sessions are the performance values of the session count, i.e., the metric data. Figure 3 The graph shows time-series curves representing different performance values (number of active sessions and total number of sessions) of the same metric for the same object (database).
[0039] S102. Based on the temporary business model and compression step size, traverse the set of business models to be compressed, update the temporary business models during the traversal process, and record the parent class time data.
[0040] Among them, the temporary business model is used to cache temporary time-series data during the compression process, and the parent time data is used to indicate the original time data corresponding to the original indicator data that meets the preset feature requirements within the unit compression range corresponding to the compression step size.
[0041] In this embodiment, firstly, during the traversal of the set of business models to be compressed, a temporary business model is needed to cache the original time-series data of the set of business models to be compressed during the compression process. This original time-series data is the temporary time-series data. Then, the set of business models to be compressed is traversed, and within the unit compression range corresponding to the compression step size, the temporary business model is updated according to the preset feature requirements, and the parent class time data is recorded. The preset feature requirements can be, for example, taking the median or maximum value of the indicator data in the set of business models to be compressed. The unit compression range can be understood as the range of each time-series data compression. For example, the unit compression range corresponding to a compression step size of 3 means that the unit compression range is 3 time-series data, that is, compression is performed once for every 3 time-series data.
[0042] S103. Based on the traversal results, determine the parent class time data set and the business model compression result set.
[0043] In this embodiment, during the traversal process, temporary time-series data and parent time data that meet the preset feature requirements can be stored in the business model compression result set and the parent time data set, respectively. After the traversal is completed, the compression result data, namely the parent time data set and the business model compression result set, can be determined.
[0044] The time-series data compression method provided in this embodiment of the invention obtains a set of business models to be compressed and determines a compression step size. The set of business models to be compressed includes original time-series data, which contains a correspondence between original time data and original indicator data. Based on a temporary business model and the compression step size, the set of business models to be compressed is traversed, and the temporary business model is updated during the traversal process. Parent time data is also recorded. The temporary business model is used to cache temporary time-series data during the compression process, and the parent time data indicates the original time data corresponding to the original indicator data that meets preset feature requirements within the unit compression range corresponding to the compression step size. Based on the traversal results, a set of parent time data and a set of business model compression results are determined. The technical solution of this invention first determines the compression step size based on the set of business models to be compressed, then traverses the set of business models to be compressed, caches the compressed data in a temporary business model, and records the parent time data. After the traversal is completed, the parent time data and the compression result of the business model can be determined. This method compresses a large amount of time-series data in an orderly manner, which not only ensures the compression efficiency of time-series data, but also records the parent time data so that users can view the original time data.
[0045] Example 2
[0046] Figure 4 This is a flowchart of a time-series data compression method provided in Embodiment 2 of the present invention. The technical solution of the present invention is further optimized based on the above optional technical solutions, and a specific compression method for compressing time-series data is given.
[0047] Optionally, obtaining the set of business models to be compressed and determining the compression step size includes: obtaining the set of business models to be compressed, determining the actual number of time-series data points, the expected number of time-series data points, and preset objects; and determining the compression step size based on the actual number of time-series data points and the expected number of time-series data points. The advantage of this setting is that it allows for orderly compression of the time-series data based on the different objects within the data, ensuring that the trend of the time-series line chart generated based on the compression result remains unaffected.
[0048] Optionally, the step of traversing the set of business models to be compressed based on the temporary business model and the compression step size, updating the temporary business model during the traversal, and recording the parent class time data includes: for each preset object, traversing the set of business models to be compressed within multiple consecutive unit compression ranges based on the temporary business model and the compression step size, updating the temporary business model during the traversal, and recording the parent class time data. The unit compression range is determined according to the compression step size, and the total range of multiple unit compression ranges corresponds to the set of business models to be compressed. The advantage of this setting is that time data is recorded while time-series data is compressed in an orderly manner, ensuring the accuracy of the original time data recording.
[0049] Optionally, after determining whether the temporary counting step size corresponding to the current preset object is less than the compression step size, the method further includes: if not, adding the temporary business model corresponding to the current preset object to the business model compression result set; and adding the parent time data of the temporary business model corresponding to the current preset object to the parent time data set. The advantage of this setting is that, during the process of traversing the set of business models to be compressed, compression results are generated step by step, ensuring the efficiency and orderliness of the compressed time-series data.
[0050] like Figure 4 As shown in Embodiment 2 of the present invention, a method for compressing time-series data specifically includes the following steps:
[0051] S201. Obtain the set of business models to be compressed, and determine the actual number of time-series data points, the expected number of time-series data points, and the preset objects.
[0052] Specifically, if the goal is to draw a time-series line chart of the same performance value for the same metric across different objects, the actual number of time-series data points can be understood as the number of business models to be compressed in the set of business models to be compressed, and the expected number of time-series data points can be understood as the expected number of time-series data points, i.e. the number of business models after compression. The specific values can be determined based on the actual situation, such as the browser's loading capacity and memory capacity. In the time-series line chart of the same performance value for the same metric across different objects, one preset object can correspond to one line.
[0053] For example, if the goal is to draw a time-series line chart of the same performance value of the same indicator for different objects, the content of the obtained set of business models to be compressed is (date, city name, temperature), the actual number of time-series data points is 360, and the expected number of time-series data points can be set to 120. Specifically, the first 9 business models to be compressed in the set of business models to be compressed are: (4 / 1, Beijing, 20), (4 / 1, Shanghai, 18), (4 / 1, Guangzhou, 25), (4 / 2, Beijing, 20.5), (4 / 2, Shanghai, 17.5), (4 / 2, Guangzhou, 24), (4 / 3, Beijing, 19), (4 / 3, Shanghai, 17), and (4 / 3, Guangzhou, 25.5). The preset objects of the business models to be compressed are Beijing, Shanghai, and Guangzhou.
[0054] Optionally, if the purpose is to draw a time series line chart of different performance values of the same object and the same indicator, the actual number of time series data points can be understood as the product of the number of business models to be compressed in the set of business models to be compressed and the number of lines. In the time series line chart of different performance values of the same object and the same indicator, one preset object can correspond to multiple lines, and the number of lines corresponds to the number of original indicators of the business models to be compressed in the set of business models to be compressed.
[0055] For example, if the goal is to draw a time-series line chart of different performance values of the same object and the same indicator, the content of the obtained set of business models to be compressed is (time, number of active database sessions, total number of database sessions). If the number of lines is 2 and the number of business models to be compressed in the set of business models to be compressed is 60, then the actual number of time-series data points is 120, and the expected number of time-series data points can be set to 40. Specifically, the first 3 business models to be compressed in the set of business models to be compressed are (13:00, 13, 15), (13:01, 12, 16), and (13:02, 10, 13). The preset object of the business models to be compressed is the database.
[0056] S202. Determine the compression step size based on the actual number of time series data points and the expected number of time series data points.
[0057] Specifically, the compression step size can be determined by dividing the actual number of time series data points by the expected number of time series data points and rounding up.
[0058] For example, if the actual number of time series data points is 67 and the expected number of time series data points is 22, then the compression step size is 4, which is the quotient of 67 / 22, 3.04, rounded up.
[0059] S203. For each preset object, based on the temporary business model and compression step size, traverse the set of business models to be compressed within a continuous range of multiple compression units, update the temporary business model during the traversal, and record the parent class time data.
[0060] The unit compression range is determined based on the compression step size, and the total range of multiple unit compression ranges corresponds to the set of business models to be compressed.
[0061] Specifically, using a temporary business model, in the set of business models to be compressed, for each preset object's business model to be compressed, the compression range is traversed in units of compression step size, and the parent class time data is recorded.
[0062] Optionally, before traversing the set of business models to be compressed based on the temporary business model and the compression step size, the method further includes: initializing the temporary counting step size corresponding to each preset object, wherein the temporary counting step size is used to cache the step size count; initializing the temporary business model corresponding to each preset object; and initializing the parent time data of the temporary business model corresponding to each preset object.
[0063] Specifically, before traversing the set of business models to be compressed, the counting step, temporary business model, and parent time data of the temporary business model can be initialized for each preset object. The initialization method can be to set the counting step, temporary time data and temporary indicator data in the temporary business model, and parent time data of the temporary business model to zero.
[0064] Optional, Figure 5 A flowchart for traversing a set of business models to be compressed, such as... Figure 5 As shown, step S203 may include:
[0065] S2031. Determine the current business model to be compressed and the current preset object within the current unit compression range. Determine whether the temporary counting step size corresponding to the current preset object is less than the compression step size. If yes, execute S2032; otherwise, execute S2039.
[0066] For example, if the goal is to draw a time-series line chart of the same performance value of the same indicator for different objects, the content recorded in the set of business models to be compressed is (date, city name, temperature). The first nine business models to be compressed in the set are: (4 / 1, Beijing, 20), (4 / 1, Shanghai, 18), (4 / 1, Guangzhou, 25), (4 / 2, Beijing, 20.5), (4 / 2, Shanghai, 17.5), (4 / 2, Guangzhou, 24), (4 / 3, Beijing, 19), (4 / 3, Shanghai, 17), and (4 / 3, Guangzhou, 25.5). The preset objects of the business model to be compressed are Beijing, Shanghai and Guangzhou, and the compression step size is 3. The counting step size, temporary time data and temporary indicator data in the temporary business model and the parent time of the temporary business model are all zero. Starting from the first business model to be compressed, the process is traversed. This business model is the current business model to be compressed, and the preset object corresponding to the current business model is the current preset object. It is determined whether the temporary counting step size corresponding to the current preset object is less than the compression step size. In this example, the temporary counting step size corresponding to Beijing is zero, which is less than the compression step size of 3.
[0067] For example, if the goal is to draw a time-series line chart of different performance values of the same object and the same indicator, the content recorded in the set of business models to be compressed is (time, number of active database sessions, total number of database sessions). The first three business models to be compressed in the set are: (13:00, 13, 15), (13:01, 12, 16), and (13:02, 10, 13). The preset object of this business model is the database, the compression step size is 3, and the counting step size corresponding to the preset object, the temporary time data and temporary indicator data in the temporary business model, and the parent time of the temporary business model are all zero. Starting from the first business model to be compressed, the process is traversed. This business model is the current business model to be compressed, and the preset object corresponding to the current business model is the current preset object. It is determined whether the temporary counting step size corresponding to the current preset object is less than the compression step size. In this example, the temporary counting step size corresponding to the database is zero, which is less than the compression step size of 3.
[0068] S2032, Update the temporary counting step size corresponding to the current preset object.
[0069] The update method is to increment the step count by 1.
[0070] Specifically, if the temporary counting step size corresponding to the current preset object is less than the compression step size, then the temporary counting step size corresponding to the current preset object is incremented by one.
[0071] S2033. Update the temporary time data in the temporary business model corresponding to the current preset object to the original time data in the current business model to be compressed.
[0072] For example, if the goal is to draw a time-series line chart of the same performance value of the same indicator for different objects, and the current business model to be compressed is (4 / 1, Beijing, 20), the current temporary business model corresponding to Beijing is (0, Beijing, 0), and the original time data in the current business model to be compressed is 4 / 1, then the temporary time data in the current temporary business model corresponding to Beijing can be updated to 4 / 1, and the current temporary business model corresponding to Beijing is (4 / 1, Beijing, 0).
[0073] For example, if the goal is to draw a time-series line chart of different performance values of the same indicator for the same object, and the current business model to be compressed is (13:00, 13, 15), the temporary business model corresponding to the current database is (0, 0, 0), and the original time data in the current business model to be compressed is 13:00, then the temporary time data in the temporary business model corresponding to the current database can be updated to 13:00, and the temporary business model corresponding to the current database becomes (13:00, 0, 0).
[0074] S2034. Determine whether there are any missing original indicator data in the current business model to be compressed. If yes, execute S2038; otherwise, execute S2035.
[0075] For example, if the goal is to draw a time series line chart of the same performance value of the same indicator for different objects, and the current business model to be compressed is: (4 / 3, Beijing, NULL) or (4 / 3, Beijing,), that is, the original indicator data in the current business model to be compressed is empty, then it can be determined that the original indicator data in the current business model to be compressed is missing, and S2038 is executed. If there is no missing data, then S2035 is executed.
[0076] For example, if the goal is to draw a time-series line chart of different performance values of the same indicator for the same object, and the current business model to be compressed is one of (13:00, NULL, 15), (13:00, 13, NULL), (13:00, NULL, NULL), (13:00, , 15), (13:00, 13,), and (13:00, ,), that is, the original indicator data in the current business model to be compressed is empty, then it can be determined that the original indicator data in the current business model to be compressed is missing, and S2038 is executed. If there is no missing data, then S2035 is executed.
[0077] S2035. Determine whether the temporary indicator data in the temporary business model corresponding to the current preset object is less than the original indicator data in the current business model to be compressed. If yes, execute S2036; otherwise, execute S2038.
[0078] For example, if we want to draw a time-series line chart of the same performance value of the same indicator for different objects, and the current business model to be compressed is (4 / 1, Beijing, 20), the current temporary business model corresponding to Beijing is (4 / 1, Beijing, 0), and the original indicator data in the current business model to be compressed is 20, then we can determine whether the temporary indicator data in the temporary business model corresponding to Beijing is less than the original indicator data in the current business model to be compressed. In this example, the temporary indicator data 0 in the temporary business model corresponding to Beijing is less than the original indicator data 20 in the current business model to be compressed.
[0079] For example, if we want to draw a time-series line chart of the same object and the same indicator with different performance values, the current business model to be compressed is (13:00, 13, 15), the temporary business model corresponding to the current database is (13:00, 0, 0), and the original indicator data in the current business model to be compressed is 13 and 15, then we can determine whether the temporary indicator data in the temporary business model corresponding to the current database is less than the original indicator data in the current business model to be compressed. In this example, the temporary indicator data 0 in the temporary business model corresponding to the database is less than the original indicator data 13 and 15 in the current business model to be compressed.
[0080] S2036. Update the temporary indicator data in the temporary business model corresponding to the current preset object to the original indicator data in the current business model to be compressed.
[0081] For example, if the goal is to draw a time-series line chart of the same performance value of the same indicator for different objects, and the current business model to be compressed is (4 / 1, Beijing, 20), and the current temporary business model corresponding to Beijing is (4 / 1, Beijing, 0), then the temporary indicator data in the current temporary business model corresponding to Beijing can be updated to 20, and the current temporary business model corresponding to Beijing can be (4 / 1, Beijing, 20).
[0082] For example, if the goal is to draw a time-series line chart of the same object and the same indicator with different performance values, and the current business model to be compressed is (13:00, 13, 15), and the temporary business model corresponding to the current database is (13:00, 0, 0), then the temporary indicator data in the temporary business model corresponding to the current database can be updated to 13 and 15, and the temporary business model corresponding to the current database becomes (13:00, 13, 15).
[0083] S2037. Update the parent time data of the temporary business model corresponding to the current preset object to the original time data in the current business model to be compressed.
[0084] For example, if the goal is to draw a time series line chart of the same performance value of the same indicator for different objects, and the current business model to be compressed is: (4 / 1, Beijing, 20), in this example, the parent time data 0 of the temporary business model corresponding to Beijing is updated to the original time data 4 / 1 in the current business model to be compressed, and then S2038 is executed.
[0085] For example, if the goal is to draw a time series line chart of different performance values of the same object and the same indicator, and the current business model to be compressed is (13:00, 13, 15), in this example, the parent time data 0 of the temporary business model corresponding to the current database is updated to the original time data 13:00 in the current business model to be compressed, and then S2038 is executed.
[0086] S2038. Determine whether the end of the set of business models to be compressed has been reached. If yes, execute S2039; otherwise, execute S2031.
[0087] For example, if the goal is to plot a time-series line chart of the same performance value for the same indicator across different objects, and the current business model to be compressed is (4 / 1, Beijing, 20), where the temporary counting step size for Beijing is 1 (less than the compression step size of 3), and if, after judgment, the current business model to be compressed is the last business model to be compressed in the set of business models to be compressed, then the set of business models to be compressed is no longer judged, and S2039 is executed directly. If the current business model to be compressed is not the last business model to be compressed in the set of business models to be compressed, then S2031 is executed.
[0088] For example, if the goal is to plot a time-series line chart of different performance values of the same metric for the same object, and the current business model to be compressed is (13:00, 13, 15), then the temporary counting step size is 1, which is less than the compression step size of 3. If, after judgment, the current business model to be compressed is the last business model to be compressed in the set of business models to be compressed, then the set of business models to be compressed is no longer judged, and S2039 is executed directly. If the current business model to be compressed is not the last business model to be compressed in the set of business models to be compressed, then S2031 is executed.
[0089] S2039. Add the temporary business model corresponding to the current preset object to the business model compression result set.
[0090] For example, if the goal is to draw a time series line chart of the same performance value of the same indicator for different objects, and after the above S2031-S2038 loop judgment, the temporary business model corresponding to Beijing is (4 / 3, Beijing, 20.5), and the temporary counting step size corresponding to Beijing is accumulated to 3, which is no longer less than the compression step size of 3, then the temporary business model (4 / 3, Beijing, 20.5) corresponding to Beijing is added to the business model compression result set.
[0091] Optionally, since the business models to be compressed in the set of business models to be compressed have a certain order, such as the business models to be compressed corresponding to the three objects of Beijing, Shanghai and Guangzhou appearing alternately in a loop, if when the temporary counting step corresponding to the first object Beijing is accumulated to 3, the temporary counting step of the business models to be compressed corresponding to Shanghai and Guangzhou has also been accumulated to 3, that is, the business models to be compressed corresponding to the three objects of Beijing, Shanghai and Guangzhou have all completed the model compression within the unit compression range, then when the temporary counting step corresponding to Beijing is accumulated to 3, or when the end of the set of business models to be compressed has been traversed, the temporary business models corresponding to the three objects of Beijing, Shanghai and Guangzhou can be added to the business model compression result set at the same time.
[0092] For example, if the goal is to draw a time-series line chart of different performance values of the same indicator for the same object, and after the above S2031-S2038 loop judgment, the temporary business model corresponding to the current database is (13:02, 13, 16), and the temporary counting step size corresponding to the current database is accumulated to 3, which is no longer less than the compression step size 3, then the temporary business model (13:02, 13, 16) corresponding to the current database is added to the business model compression result set.
[0093] S2040. Add the parent time data of the temporary business model corresponding to the current preset object to the parent time data collection.
[0094] For example, if the goal is to draw a time-series line chart of the same performance value of the same indicator for different objects, and if, after the above S2031-S2038 loop judgment, the parent time data of the temporary business model corresponding to Beijing is 4 / 2, then the parent time data 4 / 2 of the temporary business model corresponding to Beijing is added to the parent time data set.
[0095] Optionally, since the business models to be compressed in the set of business models to be compressed have a certain order, such as the business models to be compressed corresponding to the three objects of Beijing, Shanghai and Guangzhou appearing alternately in a loop, if when the temporary counting step corresponding to the first object Beijing is accumulated to 3, the temporary counting step of the business models to be compressed corresponding to Shanghai and Guangzhou has also been accumulated to 3, that is, the business models to be compressed corresponding to the three objects of Beijing, Shanghai and Guangzhou have all completed the model compression within the unit compression range, then when the temporary counting step corresponding to Beijing is accumulated to 3, or when the end of the set of business models to be compressed has been traversed, the parent time data of the temporary business models corresponding to the three objects of Beijing, Shanghai and Guangzhou can be added to the parent time data set at the same time.
[0096] For example, if the goal is to draw a time-series line chart of different performance values of the same indicator for the same object, and if, after the above S2031-S2038 loop judgment, the parent time data of the temporary business model corresponding to the current database is (13:00, 13:01), then the parent time data (13:00, 13:01) of the temporary business model corresponding to the current database is added to the parent time data set.
[0097] Furthermore, after adding the parent time data of the temporary business model corresponding to the current preset object to the parent time data set, the method further includes: setting the temporary counting step size corresponding to the current preset object, the indicator data in the temporary business model corresponding to the current preset object, and the parent time data of the temporary business model corresponding to the current preset object to zero.
[0098] Specifically, after executing S2040, it is necessary to set the temporary counting step size corresponding to the current preset object, the temporary time data and temporary indicator data in the temporary business model, and the parent time data of the temporary business model to zero.
[0099] For example, if the goal is to draw a time-series line chart of the same performance value of the same indicator for different objects, and if the preset objects are Beijing, Shanghai and Guangzhou, after executing step S2040, the parent time data of the temporary business models corresponding to Beijing, Shanghai and Guangzhou has been added to the parent time data set. Then, the temporary counting step size, the temporary time data and temporary indicator data in the temporary business models, and the parent time data of the temporary business models corresponding to the three objects of Beijing, Shanghai and Guangzhou can be set to zero.
[0100] S204. Based on the traversal results, determine the parent class time data set and the business model compression result set.
[0101] The time-series data compression method provided in this invention first determines the compression step size and other data based on the set of business models to be compressed. Then, it initializes a temporary business model and parent time data. Next, it traverses the set of business models to be compressed according to preset conditions, stores the time-series data that meets the preset conditions into the temporary business model, and records the parent time data. Then, it stores the time-series data and parent time data in the temporary business model into the business model compression result set and the parent time data set, respectively. Finally, after the traversal is completed, the parent time data and the business model compression result can be determined. This method performs orderly compression of a large amount of time-series data, which not only ensures the compression efficiency of the time-series data, but also does not affect the trend of the time-series line chart after the compressed time-series data is visualized.
[0102] Based on the above embodiments, after determining the parent time data set and the business model compression result set according to the traversal results, the method includes: providing the business model compression result set to a browser so that the browser can visualize the trend of the time series data in the business model compression result set; and providing the parent time data set to a browser so that the user can view the original time data corresponding to the indicator data in the business model compression result set.
[0103] Specifically, after compression, the compressed business model result set can be provided to the browser so that the browser can load the compressed business model result set and draw the corresponding time series data line chart. Since the time data in the business model in the compressed business model result set is the nth time data of the business model set to be compressed within the unit compression range, where n is the compression step size, the parent time data set can be provided to the browser. Users can use this to view the original time data corresponding to the indicator data in the time series data line chart.
[0104] Example 3
[0105] Figure 6 This is a schematic diagram of a time-series data compression device provided in Embodiment 3 of the present invention. Figure 6 As shown, the device includes: a compression step size determination module 301, a traversal module 302, and a compression result and parent class time determination module 303, wherein:
[0106] The compression step size determination module is used to obtain a set of business models to be compressed and determine the compression step size. The set of business models to be compressed includes original time series data, and the original time series data includes the correspondence between original time data and original indicator data.
[0107] The traversal module is used to traverse the set of business models to be compressed based on the temporary business model and the compression step size, update the temporary business model during the traversal process, and record the parent time data. The temporary business model is used to cache temporary time-series data during the compression process, and the parent time data is used to indicate the original time data corresponding to the original indicator data that meets the preset feature requirements within the unit compression range corresponding to the compression step size.
[0108] The compression result and parent time determination module is used to determine the parent time data set and the business model compression result set based on the traversal results.
[0109] The time-series data compression device provided in this embodiment of the invention first determines the compression step size based on the set of business models to be compressed, then traverses the set of business models to be compressed, caches the compressed data in a temporary business model, and records the parent time data. After the traversal is completed, the parent time data and the compression result of the business model can be determined. This device performs orderly compression of a large amount of time-series data, which not only ensures the compression efficiency of time-series data, but also records the parent time data so that users can view the original time data.
[0110] Optionally, the compression step size determination module 301 includes:
[0111] The data point count and preset object determination unit is used to obtain the set of business models to be compressed and determine the actual time-series data point count, the expected time-series data point count, and the preset objects.
[0112] The compression step size determination unit is used to determine the compression step size based on the actual number of time-series data points and the expected number of time-series data points.
[0113] Optionally, the device may also include:
[0114] The temporary counting step initialization module is used to initialize the temporary counting step corresponding to each preset object before traversing the set of business models to be compressed based on the temporary business model and the compression step, wherein the temporary counting step is used to cache the step count;
[0115] The temporary business model initialization module is used to initialize the temporary business model corresponding to each preset object.
[0116] The parent class time data initialization module is used to initialize the parent class time data of the temporary business model corresponding to each preset object.
[0117] Optionally, the step of traversing the set of business models to be compressed based on the temporary business model and the compression step size, updating the temporary business model during the traversal, and recording the parent class time data includes: for each preset object, traversing the set of business models to be compressed within multiple consecutive unit compression ranges based on the temporary business model and the compression step size, updating the temporary business model during the traversal, and recording the parent class time data, wherein the unit compression range is determined according to the compression step size, and the total range of the multiple unit compression ranges corresponds to the set of business models to be compressed.
[0118] Optionally, traversal module 302 includes:
[0119] The temporary counting step size determination unit is used to determine the current business model to be compressed and the current preset object to be traversed within the current unit compression range, and to determine whether the temporary counting step size corresponding to the current preset object is less than the compression step size.
[0120] A temporary counting step size update unit is used to update the temporary counting step size corresponding to the current preset object when the judgment result of the temporary counting step size judgment unit is yes, wherein the update method is to increment the step size count by 1;
[0121] The temporary time data update unit is used to update the temporary time data in the temporary business model corresponding to the current preset object to the original time data in the current business model to be compressed.
[0122] The temporary indicator data judgment unit is used to determine whether the temporary indicator data in the temporary business model corresponding to the current preset object is less than the original indicator data in the current business model to be compressed.
[0123] The temporary indicator data update unit is used to update the temporary indicator data in the temporary business model corresponding to the current preset object to the original indicator data in the current business model to be compressed when the judgment result of the temporary indicator data judgment unit is yes.
[0124] The parent time data update unit is used to update the parent time data of the temporary business model corresponding to the current preset object to the original time data in the current business model to be compressed.
[0125] The end traversal judgment unit is used to determine whether the end of the set of business models to be compressed has been reached.
[0126] The execution jump to the first unit is used to notify the temporary counting step size judgment unit to repeat the operation of determining the current business model to be compressed and the current preset object within the current unit compression range when the judgment result of the end traversal judgment unit is negative.
[0127] Optionally, traversing module 302 also includes:
[0128] The temporary business model adding unit is used to add the temporary business model corresponding to the current preset object to the business model compression result set when the judgment result of the temporary counting step size judgment unit is negative.
[0129] The parent time data adding unit is used to add the parent time data of the temporary business model corresponding to the current preset object to the parent time data set.
[0130] Optionally, traversing module 302 also includes:
[0131] The zeroing unit is used to set the temporary counting step size corresponding to the current preset object, the indicator data in the temporary business model corresponding to the current preset object, and the parent time data of the temporary business model corresponding to the current preset object to zero.
[0132] Optionally, traversing module 302 also includes:
[0133] The data missing judgment unit is used to determine whether the original indicator data in the current business model to be compressed is missing before determining whether the temporary indicator data in the temporary business model corresponding to the current preset object is less than the original indicator data in the current business model to be compressed.
[0134] The second unit is executed to notify the end traversal judgment unit to perform the operation of judging whether the data missing judgment unit has reached the end of the set of business models to be compressed when the judgment result of the data missing judgment unit is yes.
[0135] Optionally, the device may also include:
[0136] A compression result set providing module is used to provide the business model compression result set to the browser so that the browser can visualize the trend of time series data in the business model compression result set;
[0137] The parent time data set providing module is used to provide the parent time data set to the browser so that users can view the original time data corresponding to the indicator data in the business model compression result set.
[0138] The time-series data compression apparatus provided in the embodiments of the present invention can execute the time-series data compression method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of executing the method.
[0139] Example 4
[0140] Figure 7 A schematic diagram of an electronic device 40 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0141] like Figure 7As shown, the electronic device 40 includes at least one processor 41 and a memory, such as a read-only memory (ROM) 42 or a random access memory (RAM) 43, communicatively connected to the at least one processor 41. The memory stores computer programs executable by the at least one processor. The processor 41 can perform various appropriate actions and processes based on the computer program stored in the ROM 42 or loaded into the RAM 43 from storage unit 48. The RAM 43 may also store various programs and data required for the operation of the electronic device 40. The processor 41, ROM 42, and RAM 43 are interconnected via a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.
[0142] Multiple components in electronic device 40 are connected to I / O interface 45, including: input unit 46, such as keyboard, mouse, etc.; output unit 47, such as various types of monitors, speakers, etc.; storage unit 48, such as disk, optical disk, etc.; and communication unit 49, such as network card, modem, wireless transceiver, etc. Communication unit 49 allows electronic device 40 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0143] Processor 41 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 41 performs the various methods and processes described above, such as methods for compressing time-series data.
[0144] In some embodiments, the timing data compression method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 48. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 40 via ROM 42 and / or communication unit 49. When the computer program is loaded into RAM 43 and executed by processor 41, one or more steps of the timing data compression method described above may be performed. Alternatively, in other embodiments, processor 41 may be configured to perform the timing data compression method by any other suitable means (e.g., by means of firmware).
[0145] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0146] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0147] The computer equipment provided above can be used to execute the time-series data compression method provided in any of the above embodiments, and has corresponding functions and beneficial effects.
[0148] Example 5
[0149] In the context of this invention, a computer-readable storage medium may be a tangible medium, and the computer-executable instructions, when executed by a computer processor, are used to perform a method for compressing time-series data, the method comprising:
[0150] Obtain a set of business models to be compressed and determine the compression step size. The business models to be compressed in the set of business models to be compressed include original time series data, and the original time series data includes the correspondence between original time data and original indicator data.
[0151] Based on the temporary business model and the compression step size, the set of business models to be compressed is traversed, and the temporary business model is updated during the traversal process, and the parent time data is recorded. The temporary business model is used to cache temporary time-series data during the compression process, and the parent time data is used to indicate the original time data corresponding to the original indicator data that meets the preset feature requirements within the unit compression range corresponding to the compression step size.
[0152] Based on the traversal results, determine the parent class time data set and the business model compression result set.
[0153] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by, or in conjunction with, an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0154] The computer equipment provided above can be used to execute the time-series data compression method provided in any of the above embodiments, and has corresponding functions and beneficial effects.
[0155] It is worth noting that in the embodiments of the above-mentioned time-series data compression device, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the scope of protection of the present invention.
[0156] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.
Claims
1. A method for compressing time-series data, characterized in that, include: Obtain a set of business models to be compressed and determine the compression step size. The business models to be compressed in the set of business models to be compressed include original time series data, and the original time series data includes the correspondence between original time data and original indicator data. Based on the temporary business model and the compression step size, the set of business models to be compressed is traversed, and the temporary business model is updated during the traversal process, and the parent time data is recorded. The temporary business model is used to cache temporary time-series data during the compression process, and the parent time data is used to indicate the original time data corresponding to the original indicator data that meets the preset feature requirements within the unit compression range corresponding to the compression step size. Based on the traversal results, determine the parent class time data set and the business model compression result set.
2. The method according to claim 1, characterized in that, The step of obtaining the set of business models to be compressed and determining the compression step size includes: Obtain the set of business models to be compressed, and determine the actual number of time-series data points, the expected number of time-series data points, and the preset objects; The compression step size is determined based on the actual number of time-series data points and the expected number of time-series data points.
3. The method according to claim 2, characterized in that, Before traversing the set of business models to be compressed based on the temporary business model and the compression step size, the method further includes: Initialize a temporary counting step size for each preset object, wherein the temporary counting step size is used to cache the step size count; Initialize the temporary business model corresponding to each preset object; Initialize the parent class time data of the temporary business model corresponding to each preset object.
4. The method according to claim 3, characterized in that, The process of traversing the set of business models to be compressed based on the temporary business model and the compression step size, updating the temporary business model during the traversal, and recording the parent class time data includes: For each preset object, based on the temporary business model and the compression step size, the set of business models to be compressed is traversed within multiple consecutive unit compression ranges. During the traversal, the temporary business model is updated and the parent class time data is recorded. The unit compression range is determined according to the compression step size, and the total range of the multiple unit compression ranges corresponds to the set of business models to be compressed. Specifically, for each preset object, based on the temporary business model and the compression step size, the set of business models to be compressed is traversed within the current unit compression range, and the temporary business model is updated during the traversal, and the parent class time data is recorded, including: Determine the current business model to be compressed and the current preset object within the current unit compression range, and determine whether the temporary counting step size corresponding to the current preset object is less than the compression step size; If so, then update the temporary counting step size corresponding to the current preset object, wherein the update method is to increment the step size count by 1; Update the temporary time data in the temporary business model corresponding to the current preset object to the original time data in the current business model to be compressed. Determine whether the temporary indicator data in the temporary business model corresponding to the current preset object is less than the original indicator data in the current business model to be compressed; If so, the temporary indicator data in the temporary business model corresponding to the current preset object will be updated to the original indicator data in the current business model to be compressed. Update the parent time data of the temporary business model corresponding to the current preset object to the original time data in the current business model to be compressed; Determine whether the end of the set of business models to be compressed has been reached; If not, then repeat the operation of determining the current business model to be compressed within the current unit compression range and the current preset object.
5. The method according to claim 4, characterized in that, After determining whether the temporary counting step size corresponding to the current preset object is less than the compression step size, the method further includes: If not, the temporary business model corresponding to the current preset object is added to the business model compression result set; Add the parent time data of the temporary business model corresponding to the current preset object to the parent time data set.
6. The method according to claim 5, characterized in that, After adding the parent time data of the temporary business model corresponding to the current preset object to the parent time data set, the method further includes: Set the temporary counting step size corresponding to the current preset object, the indicator data in the temporary business model corresponding to the current preset object, and the parent time data of the temporary business model corresponding to the current preset object to zero.
7. The method according to claim 4, characterized in that, Before determining whether the temporary indicator data in the temporary business model corresponding to the current preset object is less than the original indicator data in the current business model to be compressed, the method further includes: Determine whether there are any missing original indicator data in the current business model to be compressed; If so, then perform the operation of determining whether the end of the set of business models to be compressed has been reached.
8. The method according to claim 1, characterized in that, After determining the parent time data set and the business model compression result set based on the traversal results, the following is also included: The compressed result set of the business model is provided to the browser so that the browser can visualize the trend of the time series data in the compressed result set of the business model. The parent time data set is provided to the browser so that users can view the original time data corresponding to the indicator data in the business model compression result set.
9. A compression device for time-series data, characterized in that, include: The compression step size determination module is used to obtain a set of business models to be compressed and determine the compression step size. The set of business models to be compressed includes original time series data, and the original time series data includes the correspondence between original time data and original indicator data. The traversal module is used to traverse the set of business models to be compressed based on the temporary business model and the compression step size, update the temporary business model during the traversal process, and record the parent time data. The temporary business model is used to cache temporary time-series data during the compression process, and the parent time data is used to indicate the original time data corresponding to the original indicator data that meets the preset feature requirements within the unit compression range corresponding to the compression step size. The compression result and parent time determination module is used to determine the parent time data set and the business model compression result set based on the traversal results.
10. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the compression method for timing data according to any one of claims 1-8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the method for compressing timing data according to any one of claims 1-8.