Processor for displaying data graph, mobile terminal and data display method
By performing type classification and time unit compression of data, the first-level and second-level cache data are formed, which solves the problem of large data storage space in industrial SCADA software and the time-consuming query, and realizes rapid data storage and query.
Patent Information
- Application Number
- CN202411947781.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-20
- Publication Date
- 2025-04-25
AI Technical Summary
The prior art is difficult to effectively manage and store a large amount of data collected in real time in industrial SCADA software, resulting in large storage space and long query time.
By classifying the data in data type and storing the data in the corresponding data table based on the data writing time and type, a first-level cache data is formed. At the same time, the data within one minute is recorded only once for the time unit information of year, month, day, time and minute, and cached in a classified and compressed manner to form secondary cache data.
It realizes efficient data storage, reduces the time-consuming of random read and write, reduces disk space usage, and improves query speed.
Smart Images

Figure CN119884116A_ABST
Abstract
Description
[0001] The original basis of this divisional application is a patent application with application number (202011127959.3), application date 2020.10.20, and invention name “A historical record storage method, device, electronic device and storage medium”. Technical Field
[0002] The present invention relates to the field of data storage technology, and in particular to a processor, a mobile terminal and a data display method for displaying a data graph. Background Art
[0003] In the field of industrial SCADA software, the collected data needs to be managed and stored at the bottom layer. Industrial data collection, in most cases, has high requirements for the real-time performance of data, and needs to save data for a long period of time in the past. The larger the system scale, the higher the number of points collected. Due to the high frequency of data collection, the amount of data that needs to be managed and stored will be very large. If the raw data is stored without any processing, it will take up a lot of storage space. When the amount of data is large, querying the raw data is also very time-consuming.
[0004] For example, Chinese patent CN108319714A discloses a column storage compression method based on HBase, including reading each column data from HBase, reordering each column data and storing it in each zone; calculating the statistics of random blocks to calculate the similarity factor S between each zone, the similarity factor S is a definition of the interval similarity, obtained by the absolute difference of the characteristic component of the statistic T of the two zones, and judging whether the column distribution is uniform or discrete; if the distribution is uniform, a mixed-level column compression method is used; if the distribution is discrete, a mixed-level zone compression method is used. Although the invention uses the similarity factor S to reorder the read data and partition the storage, the data with repeated content still exists, and the storage volume of data is not significantly reduced.
[0005] Chinese patent CN110543281A discloses a data storage implementation method, device, equipment and storage medium, including the following steps: when writing data, perform hot data detection on the data; determine whether it is hot data according to the detection result, if so, do not perform data compression and write the data to the storage disk; if not, perform compression ratio detection on the data; determine whether the compression ratio of the detected data is less than a preset compression threshold, if so, do not perform data compression and write the data to the storage disk; otherwise, perform data compression and write the compressed data to the storage disk. This invention only reduces the space for data storage by means of data compression, but does not reduce the amount of data.
[0006] Chinese patent CN110941564A discloses a storage space allocation method, device, electronic device and storage medium, the method comprising: obtaining the current data of the first data stream in multiple data streams; monitoring whether the data amount of the current frame data exceeds the first maximum storage data amount; when it is monitored that the data amount of the current frame data exceeds the first maximum storage data amount, releasing the storage space allocated to the multiple data streams in the target storage space, and re-allocating storage space for the multiple data streams starting from the second end of the target storage space according to the data amount of the current frame data and the maximum storage data amount of the storage space originally allocated to the multiple data streams, so as to save storage space without generating storage space fragments. The invention realizes the reasonable allocation of storage space according to the data size, avoids the occurrence of space fragments, and thus saves storage space. However, the invention still does not achieve true data stream deletion.
[0007] Chinese patent CN102629235B discloses a method for improving the read and write speed of DDR memory, encapsulating the original data before writing data to the DDR memory, and constructing a data packet start identifier SOF at the head of the data packet, and constructing a data packet end identifier EOF at the tail of the data packet, and then writing the data packets in batches and sequentially into the DDR memory; when reading data in batches from the DDR memory, by searching the SOF in the data stream, find the start position of the data packet to be read, and locate the end position of the data packet to be read by EOF; decapsulate the read data packet to restore the original data frame. This invention encapsulates the data according to the length and adds labels, without reasonable classification, so it cannot improve the data reading and writing speed.
[0008] Based on the existing defects, the present invention proposes a design of a data storage structure, the goal of which is to realize data storage, achieve the purpose of fast reading and writing speed, less disk space occupation, and fast query speed.
[0009] In addition, on the one hand, there are differences in understanding among those skilled in the art; on the other hand, the inventor studied a large number of documents and patents when making the present invention, but due to space limitations, not all details and contents are listed in detail. However, this does not mean that the present invention does not have the characteristics of these prior arts. On the contrary, the present invention already has all the characteristics of the prior art, and the applicant reserves the right to add relevant prior art to the background technology. Summary of the invention
[0010] In view of the shortcomings of the prior art, the present invention provides a historical record storage method, characterized in that the method at least comprises:
[0011] The data is classified by data type, and based on the data writing time and data type, the data variables are stored in at least one corresponding data table to form the first-level cache data; the present invention reclassifies the data and records them by classification, and adopts the sequential reading and writing method as much as possible to reduce the time consumption and unnecessary time expenditure caused by random reading and writing, so that the data of the same type and close in time are kept in one data file as much as possible, and the disk does not need the mechanical action of seeking. As much data as possible is written each time, the reading and writing speed will be fast. The present invention writes large blocks of data in a centralized manner instead of writing small blocks of data multiple times. At the same time, in order to improve the performance of data reading, a reasonable index structure and statistical analysis of data are considered to be designed for data writing, so as to reduce the amount of data read by data query as much as possible.
[0012] The data of a variable within one minute is recorded only once for the time unit information of year, month, day, hour and minute, and the data time within one minute is recorded in time units less than the minute level to form secondary cache data; the data within one minute is cached in a classified and compressed manner. The statistical data of the secondary cache data is counted and the data is written to the disk according to the preset storage structure. The present invention achieves good technical effects of saving disk space, storing less, and not losing information by using a reasonable data algorithm design to remove duplicate content in the data through the secondary cache that classifies and merges data.
[0013] Preferably, the method further comprises:
[0014] When the memory buffer is full and / or exceeds the set time, the memory data in the memory cache area is written to the disk. Writing to the disk in batches after the cache area is full is helpful to improve the reading and writing speed.
[0015] Preferably, the method further comprises:
[0016] Create a table name index table and update the table name index table based on the information in the data table, where:
[0017] The table name index table records at least the name of the data table, the start and end time of the data, and / or the data type. In response to a query instruction, the data table name recorded in the table name index table is determined based on the data type and the start and end time of the data, so as to query data in the data table corresponding to the data table name. By establishing a table name index table, the time range of each data and the spanning table can be accurately located, the data storage area and storage range can be determined more quickly, and multi-level parallel retrieval can be used to improve efficiency.
[0018] Preferably, the method further includes: the table name index table also includes a current table for storing data tables in current data usage status, and when the system is started, the memory objects recorded in the current table are queried and / or read. The setting of the current table can make the system only use memory objects during operation, and better improve the retrieval speed of the system querying the data table.
[0019] Preferably, the data structure in the data table includes at least a variable identifier, data generation time and binary data, the binary data field contains data generated by a variable within one minute, and the attributes of the data include at least generation time, value and / or quality stamp, wherein the time unit of the generation time is a time unit less than the minute level. The data structure of the present invention can facilitate the classification and rapid storage of data, significantly reduce the storage volume of data and not omit data information.
[0020] Preferably, the data table name includes at least data type string information and sequence number information, and the variable name of the data type string is a short integer ID identifier formed by replacement. Shortening the data type string of the data table name by bytes is beneficial to reducing space usage and improving query efficiency, and the efficiency of numerical comparison is much greater than that of string comparison.
[0021] Preferably, when the quality stamp indicates that the data is not abnormal, the data table does not record the quality stamp of the data; when the quality stamp indicates that the data is abnormal, the data table records the first data with abnormal quality within one minute; when the quality stamp indicates that the data quality is uncertain, the data table records the state of the quality stamp. The quality stamp recording method of the present invention can reduce the space occupied by the quality stamp by more than 90%, thereby saving more disk space.
[0022] The present invention also provides a historical record storage device, which at least includes a classification module and a merging module. The classification module is used to classify data by data type, and store data variables in at least one corresponding data table based on data writing time and data type to form first-level cache data; the merging module is used to merge the first-level cache data and update it into second-level cache data, wherein the time unit information of year, month, day, hour and minute is recorded only once for the data of a variable within one minute, and the data time within one minute is recorded in time units less than the minute level to form second-level cache data; the data within one minute is cached in a classified and compressed manner. The historical record storage device of the present invention stores and reads data in a set order, has a fast reading coarseness, and the same data occupies less disk space, so that more data can be stored.
[0023] The historical record storage device of the present invention further comprises a statistical module, which writes the statistical data of the secondary cache data into a disk according to a preset storage structure, wherein:
[0024] The content of data statistics shall at least include:
[0025] The number of data changes and duty cycle related to the switch buffer;
[0026] Maximum, minimum, and / or average values of data associated with shaped and real buffers.
[0027] The present invention also provides a history record storage electronic device, characterized in that it includes a memory and a processor, the memory is connected to the processor, the memory is used to store data, and the processor is used to process data according to the history record storage method of the present invention. The history record storage electronic device of the present invention reduces the time consumption and unnecessary time expenditure caused by random reading and writing by adopting a sequential reading and writing method, so that data of the same type and close in time are stored in one data file as much as possible, so that the disk does not need to seek mechanically, and as much data as possible is written each time, the reading and writing speed will be fast.
[0028] The present invention also provides a history record storage medium, on which a data storage program is stored, and when the data storage program is executed by a processor, the history record storage method of the present invention is implemented. The history record storage medium of the present invention not only has a fast reading and writing speed, but also removes duplicate content in the data by recording the time information of data within one minute in seconds, thereby achieving a good effect of saving disk space and not losing information. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 is a schematic diagram of a module of the device of the present invention;
[0030] Figure 2 is a time diagram of a duty cycle of one of the present inventions having raw data;
[0031] Figure 3 is a time schematic diagram of another duty cycle of the present invention;
[0032] Figure 4 is a time diagram of a duty cycle without data of the present invention;
[0033] Figure 5 It is a schematic diagram of data statistics content in which raw data exists in the present invention;
[0034] Figure 6 It is a schematic diagram of data statistics content without data in the present invention.
[0035] Reference numerals list
[0036] 10: classification module; 20: merging module; 30: statistics module. DETAILED DESCRIPTION
[0037] The following is a detailed description with reference to the accompanying drawings.
[0038] Example 1
[0039] The defect of the prior art is that each variable of the historical record data is recorded in a data table. When data is written, many data tables need to be maintained, which increases the disk seek time and leads to slow reading and writing speeds. The defect of the prior art is also that, for example, the value of an integer variable is recorded once per second, and each time (variable name, time, variable value, quality stamp) is recorded, including year, month, day, hour, minute, and second. Within one minute, the year, month, day, hour, and minute parts of all recorded times are repeated, and only the second part is different. Repeated content takes up a lot of disk space and results in less information storage.
[0040] In view of the defects of the prior art in that the storage space is large and the original data query is time-consuming, the present invention provides a historical record storage method and device to realize data storage, achieve the purpose of fast reading and writing speed, small disk space occupation and fast query speed.
[0041] like Figure 1 As shown, the historical record storage device of the present invention comprises at least a classification module 10 and a merging module 20. The merging module 20 establishes a communication connection with the classification module 10 for data transmission. The classification module 10 is used to classify the data by data type, and store the data variables in at least one corresponding data table based on the data write time and data type to form the first-level cache data. The merging module 20 is used to merge the first-level cache data and update it into the second-level cache data, wherein the time unit information of year, month, day, hour and minute is recorded only once for the data of a variable within one minute, and the data time within one minute is recorded in time units less than the minute level to form the second-level cache data; the data within one minute is cached in a classified and compressed manner.
[0042] The historical record storage device of the present invention further comprises a statistical module 30. The statistical module 30 establishes communication connections with the classification module 10 and the merging module 20 respectively for data transmission. The statistical module 30 is used to perform real-time statistical work.
[0043] The classification module 10, the merging module 20 and the statistical module 30 in the present invention can all be dedicated integrated chips, servers, processors or cloud servers. Preferably, the classification module 10, the merging module 20 and the statistical module can be separately set or integrated. For example, the classification module 10, the merging module 20 and the statistical module 30 are integrated into a dedicated integrated chip, processor, server or cloud server.
[0044] The data collected from industrial sites are of various types, including at least analog quantity, switch quantity, character string, etc. The data analyzed and classified into computer numerical types include at least integer data, real data, bool data, and time data.
[0045] In the raw data received by the classification module 10, the basic data members of a single data include at least a point name, a value, a timestamp, and a quality stamp. The point name is used to mark the data point. The value is the data value. The timestamp refers to the time point corresponding to the value. The quality stamp indicates the state of the raw data and whether it is credible.
[0046] Since the number of points of the original data collected at the same time is large, the classification module 10 classifies the buffer into at least four types of buffers, namely, an integer buffer, a real buffer, a string buffer and a switch buffer. The same type of buffer needs to buffer multiple tag point data.
[0047] In order to improve the efficiency of distinguishing all tag points, the classification module 10 defines the tag ID and replaces the tag name.
[0048] The basic data structure of label point data is Dictionary<id,value[]> , where the Key value ID is an integer data, and the Value type is the corresponding numeric array. Different types of data belong to different data types. The corresponding ones are int[].double[],bool[],string[]. After the classification module receives the original data, it adds the original data to the corresponding buffer according to the type to form the first-level buffer data.
[0049] Each type of buffer in the buffer can buffer data within a specified time. The specified time is 0 to 10 minutes. The specified time is preferably one minute. For second-level data, the amount of data in one minute is 60, and the amount of regular data is <= 60. When the buffer meets the conditions, the merging module 20 classifies and compresses the data within the specified time. The basic method of classification and compression is as follows:
[0050] S1: Replace the variable name and string type of the original data with a two-byte short integer ID, which helps to reduce space usage and improve query efficiency. The efficiency of numerical comparison is much greater than that of string comparison.
[0051] S2: The time part of year, month, day, hour and minute of all buffered data within the specified time is recorded only once, and only the second part of each data timestamp within the specified time is retained, which can reduce the space occupied by the timestamp data by 75%.
[0052] S3: For normal quality stamp data, no record is made, and quality stamp data is recorded only when the quality stamp is abnormal. Generally speaking, most quality stamps are normal, which can reduce the space occupied by quality stamps by more than 90%.
[0053] S4: Packing the data part into binary data improves the security of the data on the one hand and reduces the occupied space on the other hand.
[0054] With the development of smart devices and the expansion of their uses, it is more common to use mobile terminals to view stored historical records. Mobile terminals include at least smart phones, tablet computers, portable computers and other portable mobile terminal devices.
[0055] When viewing data through a mobile terminal, there is no need to look at a large amount of data itself, but often only the data trend is reflected in a simulated display. Therefore, the historical record storage device of the present invention recognizes the quality stamp of the data, and does not require special processing for data without quality problems; for data with quality problems, the problematic data is not sent directly to the mobile terminal, but is processed by a processor or server end containing a classification module, a merging module, and a statistical module, namely, a historical record storage device. Among them, the historical record storage device sends the signaling of the data processed by the processing module for the mobile terminal simulation display to the mobile terminal, so as to display the deteriorated data in a simulated manner.
[0056] Preferably, the present invention sends some necessary partial data based on the quality stamp to reflect the data trend for the processing module of the mobile terminal simulation display. In response to the request for accurate data from the mobile terminal, the history record storage device of the present invention sends more data to the processing module of the mobile terminal simulation display. Based on the deteriorated data determined by the quality stamp, the screen of the mobile terminal can display the deteriorated data by color or additional marking.
[0057] For example, due to the limitations of the screen display on the mobile terminal, data and data change trends are often displayed in the form of data graphs. At this time, the data graph is not high-definition, and only necessary data is needed to display the data change trend, which can reduce the amount of data sent by the historical data storage device to the mobile terminal. When the user zooms in on the data graph through the mobile terminal to display the high-definition quality data graph, the simulation display processing module of the mobile terminal requests the detailed data of the required part from the historical record storage module again to form a high-definition data graph. The data graph can display deterioration data in a specified color or mark when displaying the screen.
[0058] That is, the present invention can reduce the space occupied by the quality stamps stored in the historical records through the classified records of the quality stamps, and can also use the quality stamps in abnormal states to display the deterioration data, so as to realize the transmission of a small amount of data between the historical record storage device and the mobile terminal. When the user views the data graph on the mobile terminal, he can also view the data change trend and the high-definition data graph as needed. The data graph includes several types of data graphs formed in statistical ways such as data curves, bar graphs, pie charts, etc.
[0059] Preferably, for the query of trend data, especially the display of report data, curve display and chart display, etc., the statistical data of the present invention can also alleviate the problem of excessive amount of query data to a great extent.
[0060] The data structure of the original data of the present invention is shown in Table 1, which includes three fields: ID variable identification, DTime data generation time, and value binary data.
[0061] Table 1 Data structure of original data
[0062]
[0063] The ID variable is the identifier corresponding to the variable name, using the smallint type, with a value range of -32768 to 32767. The time when the DTime data is generated is datetime2(2) date type, and the storage occupies 6 bytes.
[0064] The three types of data storage structures, Int, double, and bool, are stored using binary data compression. The compression method is described as follows.
[0065] Tm (datetime2(2), 6Byte) indicates the year, month, day, hour, and minute of the binary data recorded in this row in Table 1. The part after the second is the time of the first data generated by the variable identifier within the specified time. The DTime field is the primary key and is of datetime2(2) type. The part after the second of each data time is stored in the binary data.
[0066] The value binary data field contains all the data generated by at least one variable within a specified time. For example, data older than 1 minute is saved to a new data row, and the attributes of each data include: generation time, value, and quality stamp. The time unit of the generation time is a time unit less than the minute level. For example, the generation time is seconds, milliseconds, microseconds, etc.
[0067] Table 2: Storage structure of the value binary data field
[0068]
[0069] As shown in Table 2, the value binary data at least includes three parts: the number of data n, time + data, and quality stamp. The number of data n is the first and second bytes of the binary data, and 2byte represents an integer n (0 to 65535). n represents the number of data generated in one minute.
[0070] Time occupies 2 bytes, and uses an integer between 0 and 60000 to represent the mth millisecond in 1 minute.<short,DateTime,object,int> (id, time, value, quality) data, the timestamp of the data = year, month, day, hour and minute of each row of data DTime + m milliseconds.
[0071] The data value (int type) occupies 4 bytes. (Float type floating point data is an approximate value; it cannot be accurately represented. It can approximately represent -3.40E+38 to -1.18E-38, 0, and 1.18E-38 to 3.40E+38, occupying 4 bytes, and bool occupies 1 Byte).
[0072] The merging module 20 places all quality stamps after the data.
[0073] When the quality stamp indicates that the data is not abnormal, the data table does not record the quality stamp of the data. For example, the quality stamp is not recorded for data with good quality.
[0074] When the quality stamp indicates data abnormality, the data table records the first abnormal quality data within one minute. For example, bad quality data only records the first data with bad quality.
[0075] When the quality stamp indicates that the data quality is uncertain, the data table records the state of the quality stamp. That is, when the quality is uncertain, for the quality stamp that needs to be recorded, the various uncertain states are recorded. For example, two types of quality stamps are used to represent the start and stop operations respectively. In the quality part of the present invention, each quality information occupies 3 bytes, the first and second bytes indicate that the quality information is the quality of the i-th data, and the third Byte represents the state value of the quality.
[0076] Table 3: Status values of the quality stamp of the present invention
[0077] start up 0 stop 1 Good (not recorded) 2 Bad (record the first one) 3 Uncertain 1 4 Uncertain 2 5 Uncertainty 3 6 … … Calculated value of the interpolation algorithm 255
[0078] In Table 3, 1 Byte is used to represent 0 to 255 states.
[0079] When the memory buffer is insufficient and / or exceeds the set time, the merge module writes the memory data in the memory cache area to the disk.
[0080] The statistical module 30 of the present invention performs statistics on all stored data to improve the efficiency of reading and facilitate long-term data reading and query. The statistical data at least includes the average value, maximum value, minimum value, total value, etc. within a certain period of time.
[0081] Among them, Bool, Double, and int data need to store statistical values, while string type data does not need statistics.
[0082] Preferably, the statistical content of the switch buffer by the statistical module 30 includes at least the number of changes and the duty cycle, such as Figure 2 to Figure 4 That is, the statistical module 30 counts the number of changes and the duty cycle based on the primary buffer data in the switch buffer.
[0083] Number of changes N: If the current value is different from the previous value, the number of changes N increases by 1; if the two values are the same, the number of changes N remains unchanged.
[0084] Duty cycle R:
[0085] like Figure 2 As shown, during the statistical period, if there is original data, the first data is false, and the time difference from the start time of the statistical period to the first data is calculated as the data duration with a value of true.
[0086] like Figure 3 As shown, during the statistical period, the time from the last data to the end of the statistical period is counted as the duration of the last data.
[0087] like Figure 4 As shown, if there is no data, the statistical value is calculated according to the previous original data.
[0088] Preferably, the statistical content of the shaping buffer and the real buffer by the statistical module 30 includes at least: the time when the max value and all the maximum values occur, the min value and all the minimum values occur, and the avg average value, such as Figure 5-6 That is, the statistical module 30 counts the maximum value, the minimum value and the time when the maximum value and the minimum value occur based on the primary buffer data in the shaping buffer and the real buffer.
[0089] The statistical module 30 calculates the avg average value by taking the duration of the data as the weight and calculating the weighted average.
[0090]
[0091] like Figure 5As shown in the figure, v represents the data value, and t represents the statistical period. If there is raw data, find the most recent raw data before the statistical period, and take the value of the raw data and the time of the first data in the statistical period as the weight. In the statistical period, the time of the last data to the end of the statistical period is counted as the duration of the last data.
[0092] like Figure 5 As shown, the first data in the statistical period is v, and the duration of the first data is t; the second data is v1, and the duration of the second data is t1; the third data is V2, and the duration of the third data is T2; the fourth data is V3, and the duration of the fourth data is T3; the fifth data is V4, and the duration of the fourth data is t4. T is the time of the statistical period, T = t + t1 + t2 + t3 + t4. Then
[0093]
[0094] like Figure 6 As shown, during the statistical period, if there is no data, the statistical value is calculated according to the previous original data, then Avg = v3, max = min = v3.
[0095] The statistics module 30 stores the collected statistics and writes them to a disk.
[0096] The arithmetic average avg in the prior art = (avg*n+v) / (n+1) = avg+(v-avg) / (n+1) can avoid overflow caused by avg*n. The weighted average avg of the present invention = (avg*sum of data duration + data*data duration) / (sum of data duration + data duration).
[0097] The advantage of the new weighted average calculation adopted in the present invention is that it can not only avoid data overflow during the calculation process, but also simplify the aggregation process of a large amount of data.
[0098] Preferably, the merging module 20 writes the merged secondary cache data to the disk according to a preset storage structure. Preferably, the preset storage structure at least includes: a table name index table, a variable name index table, a data table and a statistical table.
[0099] The table name index table TableInfo is used to save the name, data start and end time, and data type of each data table. When the amount of data in a single data table exceeds 2 million rows, a new data table is created, and the information of the new data table is updated to the table name index table TableInfo. In response to a query instruction, the table name index table TableInfo is queried based on the data type and start and end time range to determine at least one data table that meets the query conditions, and then data is queried from the determined data table.
[0100] Compared with the prior art solutions, the table name index table set in the present invention can accurately locate the time range of each data and the spanning table, and more quickly determine the data storage area and storage range, so that multi-level parallel retrieval can be used to improve efficiency.
[0101] The table name index table at least includes the current table MainTable, that is, the current table MainTable belongs to a type of table name index table. The current table MainTable is used to record the data table currently being worked on by the current system.
[0102] The table structure of the current table MainTable is the same as that of the table name index table TableInfo, as shown in Table 4. It is used to store the table currently being used for data and to obtain the information currently written into the data table. From the current table MainTable, we know which data table the current data is to be saved in. There is only one current table MainTable for each data type. The current table MainTable has at most 4 rows of data. When creating a new data table, the information of the current table MainTable is updated.
[0103] Table 4 The table structure of the current table MainTable
[0104]
[0105] Preferably, the MainTable table is only queried once when the system starts, and the current table information is read from the disk into the memory as the current table name object. Only memory objects are used during runtime, which is faster. Using the current table MainTable can better improve the system insertion table retrieval speed. When the table information changes, it is updated to the hard disk storage to ensure data synchronization when the system starts.
[0106] The data table of the present invention is established according to the data type. Different variable values of the same data type are stored in the same data table. Each data is fixed to store 2 million rows of records. After writing the data, if the storage capacity exceeds 2 million rows, a new data table is created. The data of the data table of the present invention is obtained through a large amount of data testing, and is comprehensively written at a value of 2 million, with optimal query performance. When the amount of data increases, a strategy of splitting tables is adopted. The data table is named in a combination of a string of the data type plus a serial number of an integer, that is: data table name = data type string + integer n.
[0107] For example: the name of the first data table of int type is int1, and the name of the second table is int2...intn.
[0108] In the present invention, three types of data, int, double and bool, are stored in binary data compression.
[0109] The statistical period of the statistical table in the present invention is preferably 1 hour, calculated according to the natural time. The statistical data of each hour of the day is saved in the temporary statistical table StatTemp. The statistical period of 1 hour in the present invention is a reasonable statistical granularity considering the comprehensive query time.
[0110] The temporary statistical table StatTemp saves the statistical data of each hour of the day. The temporary statistical table directly uses id and statistical time statDate to locate data. For data older than 1 day, the statistical data of each variable is merged into a binary data packet and stored in the statistical table. The values stored in the statistical table will be deleted from the temporary statistical table StatTemp. The statistical data is compressed into a data packet from the statistical data of each day. Therefore, it is necessary to use a temporary statistical table to store the data of the day, and then summarize and write it into the final statistical table after completion.
[0111] Preferably, the method of the temporary statistical table of the present invention for aggregating data into a statistical table comprises:
[0112] S21: DataType uses a positive integer to represent the data type: Bool-1, Double-2 and int-3. The three types of data that need to calculate statistical values are stored in the temporary statistical table StatTemp and are distinguished by DataType values.
[0113] S22: The statistical data within one hour is converted into binary and saved in the Varbinary field, as shown in Table 5.
[0114] S221: The first 16 bytes of the Varbinary field are in the order of maximum value vmax, minimum value vmin, average value vavg, and number of record rows avgrows, and each data occupies 4 bytes.
[0115] S222: The 17th and 18th bytes of the Varbinary field use shortint to represent the number of maximum values, and the 19th and 20th bytes use shortint to represent the number of minimum values.
[0116] S223: The time of the maximum value is stored from the 21st byte of the Varbinary field. Each time is represented by the data type time(2) of SQL Server 2008. Time(2) occupies 3 bytes and is accurate to 0.01 seconds. The minimum time is placed after the maximum time. The starting position of the minimum time storage = 21 + 3 * the number of maximum values.
[0117] The Double type in the temporary statistics table is stored in the StatDouble table, and the int type is stored in the StatInt table.
[0118] Table 5 Data structure of temporary statistics table
[0119]
[0120] Table 6 Data structure of statistical table
[0121]
[0122]
[0123] The data structure of the statistical table of the present invention is shown in Table 6.
[0124] The statistics table stores the final statistics. The statistics of a variable for 24 hours a day form a binary data block and are stored as one row. The statistics table is identified by the variable ID and the statistical date statDate. The statistics table has three fields: ID (shortint type), statDate (date type), and Value (varbinary type).
[0125] Different types of data correspond to different statistical tables: StatBool stores the statistical values of bool data, StatDouble stores the statistical values of double data, and StatInt stores the statistical values of int data.
[0126] The first 48 bytes of the Value / varbinary field are fixed to store the index of the statistical data for 24 hours from 0 to 23 o'clock. Each index uses a 2-byte shortint to indicate the end position of the statistical data. There may be no data for a few hours in a 24-hour day, but the index of the hour without data still exists, and the saved end position is the same as the value of the previous index.
[0127] The statistical data of each hour is stored from the 49th byte. The statistical data comes from the binary data of the corresponding period in the temporary statistical table and can be directly referenced. The length of the binary data of the statistical data of each hour is recorded, and the binary data of each hour is connected into one binary data in chronological order. The end position of the binary data of each hour is saved in the corresponding index.
[0128] When restoring data, the data can be converted into the corresponding data type. The time in the binary data is restored to a time of the time(2) type and superimposed with the statistical date statDate of the data to obtain a complete time.
[0129] The data structure of the StatBool statistical table corresponding to the Bool value is shown in Table 7.
[0130]
[0131] The method for mapping Bool values to the StatBool statistics table is as follows.
[0132] The Bool statistics table stores the final statistics of the Bool type. The statistics of a Bool variable for 24 hours a day form a binary data block and are saved as 1 row. It is identified by the variable ID and the statistical date statDate. The statistics table has 3 fields: ID (shortint type), statDate (date type), and Value (varbinary type).
[0133] The first 48 bytes of the Value / varbinary field are fixed to store the index of the statistical data for 24 hours from 0 to 23 o'clock. Each index uses a 2-byte shortint to indicate the end position of the statistical data. There may be no data for a few hours in a 24-hour day, but the index of the hour without data still exists, and the saved end position is the same as the value of the previous index.
[0134] The statistical data of each hour is stored from the 49th byte onwards. The statistical data comes from the temporary statistical table. The number of changes and duty cycle of the temporary statistical table are converted into binary data. The length of the binary data of each hour's statistical data is fixed at 8 (4 + 4) bytes. The binary data of each hour is connected into one binary data in chronological order, and the end position of the binary data of each hour is saved in the corresponding index;
[0135] When restoring data, the data can be converted into the corresponding data type. In binary data, there is no time. The binary index order represents the number of hours of statistics, which is superimposed with the statistical date statDate of the data to obtain a complete time.
[0136] Preferably, the storage mechanism of the present invention further includes a backup information table BackupInfo. The backup information table BackupInfo maintains backup information, including the path of the backup file and the time range of the backed-up original data. When data maintenance is performed, if the data to be deleted is newer than the EndTime of the last backup, a new data backup is triggered. That is, the backup data of the present invention will not overlap.
[0137] Example 2
[0138] This embodiment provides an electronic device and a storage medium for storing historical records.
[0139] An electronic device for storing historical records includes a memory and a processor, wherein the memory is connected to the processor. The memory is used to store data. The processor is used to process data according to the historical record storage method of the present invention.
[0140] A history record storage medium stores a data storage program, and when the data storage program is executed by a processor, the history record storage method of the present invention is implemented.
[0141] It should be noted that the above specific embodiments are exemplary, and those skilled in the art can come up with various solutions inspired by the disclosure of the present invention, and these solutions also belong to the disclosure scope of the present invention and fall within the protection scope of the present invention. Those skilled in the art should understand that the present invention description and its drawings are illustrative and do not constitute a limitation of the claims. The protection scope of the present invention is defined by the claims and their equivalents.
Claims
1. A processor for displaying a data graph, characterized in that The processor is configured to: After receiving the original data, add the original data to the corresponding buffer according to the type to form the first-level buffer data; Classify and compress data within a specified time period; Among them, the quality stamp of the data is identified, and the quality stamp data is recorded when the quality stamp is abnormal; based on the quality stamp, necessary data is sent to the mobile terminal to reflect the data trend; In response to a request for accurate data from the mobile terminal, degraded data is determined based on the quality stamp, so that the screen of the mobile terminal displays the degraded data in a color or additional mark manner.
2. The processor according to claim 1, characterized in that The processor is further configured to: store the data variables in the corresponding data table based on the data writing time and the data type to form the first-level cache data; All the quality stamps are placed behind the data and classified. For data with quality problems, the problematic data is not sent directly to the mobile terminal.
3. The processor according to claim 2, characterized in that The processor is further configured to: when the quality stamp indicates that the data is not abnormal, the data table does not record the quality stamp of the data; When the quality stamp indicates data abnormality, the data table records the first data of quality abnormality within one minute.
4. The processor according to claim 2 or 3, characterized in that: The processor is further configured to: when the quality stamp indicates that data quality is uncertain, the data table records the state of the quality stamp.
5. The processor according to any one of claims 1 to 4, characterized in that: The processor is further configured to: record the time unit information of year, month, day, hour and minute only once for the data of a variable within one minute, and record the data time within one minute in time units less than the minute level to form secondary cache data; Collect statistics of L2 cache data and write the data to disk according to the preset storage structure.
6. A mobile terminal, capable of being connected to a processor, characterized in that: The mobile terminal is configured as follows: receiving data signaling so as to display deteriorated data in a simulated manner; wherein the mobile terminal receives necessary data and displays the data and data change trends in the form of a data graph; In the case where the user enlarges the data graph through the mobile terminal to display the data graph of high-definition quality, the mobile terminal requests the processor again for the required detailed data, and the data graph displays the deteriorated data in a specified color or mark when displaying the screen; The deteriorated data is identified by the processor based on the quality stamp of the data, and the quality stamp data is recorded when the quality stamp is abnormal.
7. The mobile terminal according to claim 6, characterized in that: In the case where the mobile terminal receives necessary data, the necessary data is data with a quality stamp that is not abnormal as identified by the processor; For data with quality problems, the processor does not send the problematic data directly to the mobile terminal.
8. The mobile terminal according to claim 6 or 7, characterized in that: The data received by the mobile terminal is processed by the processor in the following manner: When the quality stamp indicates that the data is not abnormal, the data table does not record the quality stamp of the data; When the quality stamp indicates data abnormality, the data table records the first data with quality abnormality within one minute; When the quality stamp indicates that the data quality is uncertain, the data table records the status of the quality stamp.
9. A data display method, characterized in that: The method comprises: After receiving the original data, add the original data to the corresponding buffer according to the type to form the first-level buffer data; Classify and compress data within a specified time period; Among them, the quality stamp of the data is identified, and the quality stamp data is recorded when the quality stamp is abnormal; based on the quality stamp, necessary data is sent to the mobile terminal to reflect the data trend; In response to a request for accurate data from the mobile terminal, degraded data is determined based on the quality stamp, so that the screen of the mobile terminal displays the degraded data in a color or additional mark manner.
10. A data display method according to claim 9, characterized in that: The method further comprises: Based on the data writing time and data type, the data variables are stored in the corresponding data table to form the first-level cache data; All the quality stamps are placed behind the data and classified. For data with quality problems, the problematic data is not sent directly to the mobile terminal.
Citation Information
Patent Citations
A method of improving the reading and writing rate of ddr memory
CN102629235B
Column storage compression method based on HBase
CN108319714A
Storage and compression implementation method and device, equipment and storage medium
CN110543281A
Storage space allocation method and device, electronic equipment and storage medium
CN110941564A