Time information compression method and device and time information decompression method and device
By selecting the reference value of time information, calculating the difference value and removing redundant bytes, generating the splicing result between the data head and the effective bytes, the problems of poor time information compression performance and limitations in the existing technology are solved, and efficient General time information compression.
Patent Information
- Application Number
- CN202311029150.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-15
- Publication Date
- 2025-02-21
AI Technical Summary
In the prior art, the compression performance of time information is poor and the applicable scenarios are limited.
By selecting the first time information as a reference from the multiple time information to be compressed, the difference between the first time information and the second time information is calculated, the redundant bytes in the difference is removed, and the data header and effective bytes are generated for performing Splice to obtain compression results.
It realizes efficient compression of time information, small amount of compressed data, improves storage efficiency, reduces storage costs, and has a wide range of applicable scenarios.
Smart Images

Figure CN119496515A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a time information compression method, a time information decompression method, a device, an electronic device, and a machine-readable medium. Background Art
[0002] Among the data stored in the database, time information is a common data form. Compression of time information is an important operation to improve database performance.
[0003] At present, compression method one can remove the high-order 0 of the time information (in hexadecimal form) and retain the remaining valid data bits of the time information to compress the prefix part of the time information; compression method two, for multiple time information with fixed time intervals, can compress the fixed interval time information by saving the timestamp difference between two adjacent time information.
[0004] However, the inventors have found through research that in the current scheme, after removing the high-order 0s in method 1, there are still many data bits remaining, resulting in poor compression performance; while method 2 relies on compressing data at fixed time intervals, and its applicable scenarios are relatively limited. Summary of the invention
[0005] The embodiments of the present application provide a time information compression method and a time information decompression method to solve the problems of poor compression performance and limited applicable scenarios in related technologies.
[0006] Correspondingly, the embodiment of the present application also provides a time information compression device and an online course time information compression device, an electronic device and a storage medium to ensure the implementation and application of the above method.
[0007] In order to solve the above problem, an embodiment of the present application discloses a method for compressing time information, the method comprising:
[0008] Selecting first time information as a reference from a plurality of time information to be compressed;
[0009] Obtaining a difference between the first time information and second time information, where the second time information is time information other than the first time information among the multiple time information;
[0010] Determine the redundant bytes in the difference, and generate a data header according to the redundant bytes;
[0011] removing redundant bytes in the difference to obtain valid bytes, and splicing the data header with the valid bytes to obtain a splicing result corresponding to the second time information;
[0012] A compression result is generated according to the first time information and a splicing result corresponding to the second time information.
[0013] The present application discloses a method for decompressing time information, the method comprising:
[0014] Obtaining a compression result of the second time information, the compression result comprising: the first time information, and a splicing result corresponding to the second time information, the first time information being time information used as a benchmark among multiple time information before compression; the second time information being time information other than the first time information among the multiple time information; the splicing result being formed by splicing valid bytes and a data header; the valid bytes being bytes remaining after redundant bytes are removed from a difference between the first time information and the second time information, and the data header being generated based on the redundant bytes;
[0015] Parsing the data header in the splicing result to obtain the redundant bytes;
[0016] Merging the redundant bytes with the valid bytes in the splicing result to obtain a difference between the first time information and the second time information;
[0017] The restored second time information is obtained according to the difference and the first time information.
[0018] The embodiment of the present application discloses a device for compressing time information, the device comprising:
[0019] A selection module, used to select first time information as a reference from a plurality of time information to be compressed, and determine second time information other than the first time information;
[0020] A difference module, used to obtain a difference between the first time information and the second time information, where the second time information is time information other than the first time information among the multiple time information;
[0021] A processing module, used for determining redundant bytes in the difference and generating a data header according to the redundant bytes;
[0022] a splicing module, configured to remove redundant bytes in the difference to obtain valid bytes, and splice the data header with the valid bytes to obtain a splicing result corresponding to the second time information;
[0023] A generation module is used to generate a compression result according to the first time information and a splicing result corresponding to the second time information.
[0024] The embodiment of the present application discloses a device for compressing online course time information, the device comprising:
[0025] an acquisition module, configured to acquire a compression result of the second time information, the compression result comprising: the first time information, and a splicing result corresponding to the second time information, the first time information being time information used as a benchmark among a plurality of time information before compression; the second time information being time information other than the first time information among the plurality of time information; the splicing result being formed by splicing valid bytes and a data header; the valid bytes being the remaining bytes after removing redundant bytes from a difference between the first time information and the second time information, and the data header being generated based on the redundant bytes;
[0026] A parsing module, used for parsing the data header in the splicing result to obtain the redundant bytes;
[0027] a merging module, configured to merge the redundant bytes with the valid bytes in the splicing result to obtain a difference between the first time information and the second time information;
[0028] The restoration module is used to obtain the restored second time information according to the difference and the first time information, thereby completing the decompression of the time information.
[0029] An embodiment of the present application further discloses an electronic device, including: a processor; and a memory, on which executable code is stored. When the executable code is executed, the processor executes one or more methods described in the embodiments of the present application.
[0030] The embodiments of the present application also disclose one or more machine-readable media on which executable codes are stored. When the executable codes are executed, the processor executes one or more methods described in the embodiments of the present application.
[0031] Compared with the related art, the embodiments of the present application have the following advantages:
[0032] The embodiment of the present application can select the first time information as a reference from multiple time information to be compressed, and then obtain the difference between the first time information and the second time information. The difference calculation can convert the same part contained in the time information into a removable redundant sub-node, remove the redundant bytes in the difference to obtain the valid bytes, and then splice the data header generated by the redundant bytes with the valid bytes to obtain the splicing result corresponding to the second time information. By storing the splicing result, the storage of the second time information is realized, and the data volume of the splicing result is greatly reduced relative to the second time information; the present application realizes efficient compression of time information through difference calculation and removal of redundant data, so that the compressed data volume is very small, the storage efficiency of time information is improved, and the storage cost is reduced. In addition, since any time information can be calculated for mutual differences, the compression scheme of calculating the difference between time information and removing redundant sub-nodes does not specifically limit the applicable time information, and the applicable scenarios of the compression scheme are more extensive and more versatile. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 It is a system architecture diagram of an embodiment of the present application;
[0034] Figure 2 This is a schematic diagram of a compression scenario of time information of an e-commerce application in an embodiment of the present application;
[0035] Figure 3 This is a schematic diagram of a compression scenario of time information of a logistics application in an embodiment of the present application;
[0036] Figure 4 This is a schematic diagram of a compression scenario of time information of a learning application in an embodiment of the present application;
[0037] Figure 5 This is a flowchart of the steps of a method for compressing time information in an embodiment of the present application;
[0038] Figure 6 This is a flowchart of the specific steps of a method for compressing time information in an embodiment of the present application;
[0039] Figure 7 is a schematic diagram of a data header according to an embodiment of the present application;
[0040] Figure 8 It is an overall flow chart of a compression scheme of an embodiment of the present application;
[0041] Fig. 9 This is a schematic diagram of an implementation example of time information compression in an embodiment of the present application;
[0042] Fig.10 is a flowchart of the steps of a method for decompressing time information in an embodiment of the present application;
[0043] Fig.11 It is an overall flow chart of a decompression solution of an embodiment of the present application;
[0044] Fig.12 is a block diagram of a time information compression device according to an embodiment of the present application;
[0045] Fig.13 is a block diagram of a time information decompression device according to an embodiment of the present application;
[0046] Fig.14 It is a schematic diagram of the structure of a device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0047] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0048] In order to enable those skilled in the art to better understand the present application, the concepts involved in the present application are explained below:
[0049] Time information: A type of information used to characterize date and time, in the form of: xx hours: xx minutes: xx seconds; xxxx year xx month xx day, etc. The application scenarios of time information are very wide, for example, the order time of goods, the delivery time of express parcels, etc. The data types supported by the time information of the embodiment of the present application include: DATE type, TIME type, TIME STAMP type; DATE TIME type, etc.; among them, the data of DATE type occupies 3 bytes for storing days; the data of TIME type occupies 3-6 bytes (including 1-3 bytes of decimal part) for storing moments; the data of TIME STAMP type occupies 4-7 bytes (including 1-3 bytes of decimal part) for storing timestamps; the data of DATE TIME type occupies 5-8 bytes (including 1-3 bytes of decimal part), and the time information of DATE TIME type is divided into two parts, the first part stores the date (year, month, day), and the second part stores the time (hour, minute, second).
[0050] Compression of time information: Reduce the amount of time information data through compression to save storage space.
[0051] Decompression of time information: the process of restoring the compressed result of time information to time information.
[0052] Differential coding: also known as difference calculation, is a widely used coding method. Specifically, the integer value of the time information to be encoded is converted into a difference (delta) with a certain base value (base). In most cases, the difference is smaller than the original value. Therefore, by storing the difference, the amount of data to be encoded can be reduced, thereby achieving the purpose of reducing storage space.
[0053] The first time information: is the time information used as a reference value in a group of time information. During the compression process, the second time information other than the first time information is respectively subjected to difference calculation with the first time information, thereby removing repeated parts in the time information (such as repeated year, month, and day parts) through difference calculation.
[0054] Second time information: is other time information in a group of time information except the first time information.
[0055] Redundant bytes: After the difference between the second time information and the first time information is expressed in hexadecimal form, the repeated parts of the time information removed by the difference calculation are represented as empty spaces (0) in the hexadecimal difference. These empty spaces can be removed as redundant bytes, leaving valid bytes of the difference. Therefore, for the time information, the valid bytes remaining after removing the redundant bytes by storing the corresponding difference can be greatly saved, which greatly saves storage space and improves compression efficiency.
[0056] Data header: used to reflect the characteristics of redundant bytes and the sign bit of the difference. The sign bit of the effective byte difference in the data header reflects the positive or negative situation of the difference result. The characteristics of redundant bytes include the number of consecutive bytes of the empty spaces removed in the difference. When decompressing later, the information obtained by parsing the data header can be used to restore the time information.
[0057] Timestamp: used to represent a target time. Its specific representation is an integer that records the number of seconds between the target time and the preset time (such as 00:00:00 on January 1, 1970).
[0058] The time information compression method in the embodiment of the present application can be applied to different compression scenarios, such as: the time information compression scenario applied to e-commerce applications, the time information compression scenario applied to logistics applications, and the time information compression scenario applied to learning applications. Taking the time information compression scenario of e-commerce applications as an example, the backend server of the e-commerce application will collect the time information of the orders generated by the e-commerce application. The time information reflects the order placement time. In order to reduce the storage space of the data and save costs, an effective method is to compress the time information. Specifically, the present application can select the first time information as a benchmark from the multiple time information to be compressed, and then obtain the first time information and the second time information (except the first time information). The difference between the first time information and the second time information (time information other than the time information), the difference calculation can convert the same part contained in the time information to 0; after removing the redundant bytes (bytes of 0) in the difference, the valid bytes are obtained, and then the data header generated by the redundant bytes is spliced with the valid bytes to obtain the splicing result corresponding to the second time information, that is, by storing the splicing result, the storage of the second time information is realized, and the data volume of the splicing result is greatly reduced relative to the second time information; finally, the first time information and the splicing result corresponding to each second time information can be generated as a compression result. The present application realizes efficient compression of time information through difference calculation and removal of redundant data, so that the amount of compressed data is very small, the storage efficiency of time information is improved, and the storage cost is reduced. In addition, since any time information can be calculated for mutual differences, the compression scheme using the calculation of the difference between time information and the removal of redundant sub-nodes does not specifically limit the applicable time information, and the applicable scenarios of the compression scheme are more extensive and more versatile.
[0059] Furthermore, when the time information needs to be used again after compression, the data header in the splicing result corresponding to the second time information can be extracted, and based on the information obtained by parsing the data header, the valid bytes in the splicing result can be restored to the second time information, thereby achieving rapid decompression of the time information and meeting the need to quickly restore the time information for use.
[0060] Reference Figure 1 , which shows a system architecture diagram of a time information processing method provided in an embodiment of the present application, wherein the server includes: a preprocessing module, a compression module, a generation module and a decompression module.
[0061] In the embodiment of the present application, the server can compress the time information through the preprocessing module, the compression module, and the generation module to obtain the compression result, and can also decompress the compression result through the decompression module to obtain the restored time information.
[0062] Among them, the preprocessing module can first select the first time information as a benchmark from the multiple time information to be compressed. The first time information is used to calculate the difference with other second time information when compressing the data. In this way, the process of differential encoding can use a fixed first time information to calculate the difference, reducing the calculation overhead. Furthermore, there can be multiple strategies for selecting the first time information as a benchmark from the multiple time information to be compressed, such as selecting the minimum value in the time information as the first time information, selecting the middle value in the time information as the first time information, selecting the average value in the time information as the first time information, etc., and the embodiments of the present application do not limit this.
[0063] After selecting the first time information as a reference, the preprocessing module can first convert the first time information and the second time information into integer forms respectively, and then calculate the difference between the first time information and the second time information (the difference is expressed in hexadecimal form). The difference calculation converts the same date or time part contained in the first time information and the second time information into 0, so as to facilitate subsequent compression. For example, assuming that the first time information is 10:10:10 on October 10, 2008, and the second time information is 10:10:20 on October 10, 2008, after the difference between the first time information and the second time information is calculated, the same part between the two: 10:10 on October 10, 2008 is offset (specifically reflected in the bytes of 0 in the difference), and the difference between 20 seconds in the first time information and 10 seconds in the second time information remains in the difference.
[0064] For the difference corresponding to the second time information obtained by the preprocessing module, the compression module can perform a specific compression operation, that is, remove the redundant bytes in the difference and retain the remaining valid bytes. The redundant bytes can be the bytes in the difference that become 0 due to the offset of the same data part. For example, assuming that the difference of a second time information is 0x00 00 00 10 00, the compression operation of the compression module is to remove the redundant bytes of the prefix part and the suffix part of the difference. The redundant bytes of the prefix part refer to 3 consecutive bytes of 0 starting from the highest bit of the difference (the bit after x), and the redundant bytes of the suffix part refer to 1 byte of 0 starting from the lowest bit of the difference (the rightmost 0). After removing the redundant bytes, the remaining valid bytes are 0x10.
[0065] After obtaining the valid bytes, the compression module can generate a data header based on the redundant bytes. In addition to recording the sign bit of the difference (reflecting the positive or negative status of the difference), the data header can also record the characteristics of the redundant bytes of the deleted prefix and suffix parts. The splicing result corresponding to the second time information obtained by splicing the data header and the valid bytes, that is, the splicing result can be used as the compression result of the second time information. Compared with the original second time information, the splicing result retains the data header and valid data bits with extremely small data volume, thereby achieving efficient compression of the second time information.
[0066] After the compression operation is completed, the generation module of the server side may generate the first time information and the splicing result corresponding to the second time information as a compression result, and the compression result may be stored in a database of the server side.
[0067] It should be noted that, in one case, the compression module can compress the first time information (i.e., calculate the difference between the first time information and the first time information) to obtain the compression result of the first time information; in another case, the compression module may not compress the first time information, but store the first time information in an associated position near the compressed data or a preset storage position, so as to facilitate the subsequent decompression and read the first time information from the position to achieve decompression. For example, in a database using a fixed-size data page, the first time information can be stored in a predefined fixed position of the data page.
[0068] When the time information is used again in the future, the decompression module on the server side can parse the data header of the compression result, obtain redundant bytes, and use the redundant bytes to restore the complete difference. Finally, the first time information is read, and the reverse operation of differential encoding is performed based on the first time information and the restored difference to obtain the restored second time information, thereby completing the rapid decompression of the time information.
[0069] It should be noted that, based on the time information compression method provided in the embodiment of the present application, several other specific scenarios that can be implemented are as follows:
[0070] In another implementation, referring to Figure 2, which shows a schematic diagram of a compression scenario of time information of an e-commerce application provided by an embodiment of the present application. The scenario includes: a user device and an e-commerce server. The e-commerce application installed in the user device will generate a lot of time information during use. For example, when placing an order, there is an order time, and the goods in the e-commerce application also have the time of listing, etc. The e-commerce server can maintain these time information through the database. Specifically, the e-commerce server can use the time information compression method mentioned above in the embodiment of the present application, and finally obtain the compression result after the time information is compressed through the reference value selection, differential encoding and removal of redundant sub-nodes in sequence, and store the compressed result in the database, which can effectively reduce the space occupied by the data and improve the storage cost. In the case that the e-commerce server needs to use the time information later, the e-commerce server can parse the data header of the compression result to obtain redundant bytes, and use the redundant bytes to restore the complete difference, and finally read the reference value, and perform the reverse operation of differential encoding based on the reference value and the restored difference to obtain the restored time information, thereby completing the rapid decompression of the time information.
[0071] In another implementation, referring to Figure 3 , which shows a schematic diagram of a compression scenario of time information of a logistics application provided by an embodiment of the present application. The scenario includes: a user device and a logistics service end. The user device will generate a lot of time information in the process of sending or receiving express delivery, such as the delivery time of the express package, the delivery time of the express package, etc. The logistics service end can maintain these time information through the database. Specifically, the logistics service end can use the time information compression method mentioned above in the embodiment of the present application, and finally obtain the compression result after the time information is compressed through the reference value selection, differential encoding and removal of redundant sub-nodes in sequence, and store the compressed result in the database, which can effectively reduce the space occupied by the data and improve the storage cost. In the case that the logistics service end needs to use the time information later, the logistics service end can parse the data header of the compression result to obtain redundant bytes, and use the redundant bytes to restore the complete difference, and finally read the reference value, and perform the reverse operation of differential encoding based on the reference value and the restored difference to obtain the restored time information, thereby completing the rapid decompression of the time information.
[0072] In another implementation, referring to Figure 4, which shows a schematic diagram of a compression scenario of time information of a learning application provided by an embodiment of the present application. The scenario includes: a user device and a learning server. The user device will generate a lot of time information in the process of using the learning application, such as the start time of the course, the check-in time of the learning task, etc. The learning server can maintain these time information through a database. Specifically, the learning server can use the time information compression method described above in the embodiment of the present application, and finally obtain the compression result after the time information is compressed through reference value selection, differential encoding and removal of redundant sub-nodes in sequence, and store the compressed result in the database, which can effectively reduce the space occupied by the data and improve the storage cost. In the case where the learning server needs to use the time information later, the learning server can parse the data header of the compression result to obtain redundant bytes, and use the redundant bytes to restore the complete difference, and finally read the reference value, and perform the reverse operation of differential encoding based on the reference value and the restored difference to obtain the restored time information, thereby completing the rapid decompression of the time information.
[0073] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0074] Reference Figure 5 , which shows a flowchart of the steps of a time information compression method provided by an embodiment of the present application, including:
[0075] Step 101: Select first time information as a reference from a plurality of time information to be compressed, and determine second time information other than the first time information.
[0076] In the embodiment of the present application, time information is a type of information used to represent date and time, such as 10:10:10 on October 10, 2008; December 1, 2022; 10:00 on December 1, etc. are all specific representations of time information.
[0077] Specifically, in order to achieve compression of time information, it is first necessary to select the first time information as a benchmark from multiple time information to be compressed. Furthermore, there may be multiple strategies for selecting the first time information as a benchmark from multiple time information to be compressed, such as selecting the minimum value in the time information as the first time information, selecting the middle value in the time information as the first time information, selecting the average value in the time information as the first time information, etc. The embodiments of the present application do not limit this.
[0078] Step 102: Obtain a difference between the first time information and the second time information.
[0079] In the embodiment of the present application, the first time information is used to calculate the difference (differential coding) with other second time information during data compression. The difference calculation is to convert the time information to be encoded into a difference with a certain basic value. In most cases, the difference is smaller than the original value. Therefore, by storing the difference, the amount of data to be encoded can be reduced, thereby achieving the purpose of reducing storage space. By selecting a fixed first time information, the embodiment of the present application can make the differential coding process use the fixed first time information to calculate the difference, thereby reducing the calculation overhead.
[0080] For example, referring to the following Table 1, which shows four groups of time values, after selecting the first row of time values 2022.02.01.08:01:10 as the first time information, the remaining three rows of time values are respectively calculated with the first time information to obtain corresponding differences: 10s, 20s, 30s. The difference represents the difference in the remaining difference parts (seconds) after removing the same parts (year, month, day, hour and minute) from the two time information. The amount of data of the difference is greatly reduced compared to the complete original time value:
[0081] Time value Difference 2022.02.01.08:01:10 0s 2022.02.01.08:01:20 10s 2022.02.01.08:01:30 20s 2022.02.01.08:01:40 30s
[0082] Table 1
[0083] Step 103: determine the redundant bytes in the difference, and generate a data header according to the redundant bytes.
[0084] In the embodiment of the present application, after obtaining the difference between the first time information and the second time information, the quantized difference of the difference part between the second time information and the reference value is obtained. Then, a specific compression operation can be performed, that is, removing redundant bytes in the difference and retaining the remaining valid bytes. First, the redundant bytes are determined. The redundant bytes can be bytes in the difference that become 0 due to the offset of the same data part. For example, assuming that the difference of a second time information is 0x00 0000 10 00, the compression operation is to remove the redundant bytes of the prefix part and the suffix part of the difference. The redundant bytes of the prefix part refer to 3 consecutive bytes of 0 starting from the highest bit of the difference (the one bit after x), and the redundant bytes of the suffix part refer to 1 byte of 0 starting from the lowest bit of the difference (the rightmost 0).
[0085] Furthermore, a data header can be generated based on the redundant bytes. In addition to recording the sign bit of the difference (reflecting the positive or negative status of the difference), the data header can also record the characteristics of the deleted redundant bytes. That is, the data header records the process related to the removal of redundant bytes performed by the compression process. The data header is the data required for the subsequent restoration of time information.
[0086] Step 104: remove redundant bytes in the difference to obtain valid bytes, and concatenate the data header with the valid bytes to obtain a concatenation result corresponding to the second time information.
[0087] In an embodiment of the present application, after the compression operation of removing the redundant bytes in the difference is performed, the remaining bytes are retained as valid bytes. For example, assuming that the difference of a second time information is 0x00 00 00 10 00, the compression operation is to remove the redundant bytes of the prefix part and the suffix part of the difference. The redundant bytes of the prefix part refer to 3 consecutive bytes of 0 starting from the highest bit of the difference (the bit after x), and the redundant bytes of the suffix part refer to 1 byte of 0 starting from the lowest bit of the difference (the rightmost 0). After removing the redundant bytes, the remaining valid bytes are 0x10.
[0088] Step 105: Generate a compression result according to the first time information and a splicing result corresponding to the second time information.
[0089] In an embodiment of the present application, the valid sub-node remaining after the redundant bytes are removed from the difference has a data volume greatly reduced compared to the complete difference. The data header generated based on the redundant bytes is further spliced with the valid bytes to obtain a splicing result corresponding to the second time information, that is, the splicing result can be stored as a compression result of the second time information. Compared with the original second time information, the splicing result retains the data header and valid data bits with extremely small data volume, thereby achieving efficient compression of the second time information. Finally, the first time information and the splicing result corresponding to the second time information are generated as a compression result, and the compression result can be stored in the database of the server.
[0090] In summary, the present application can select the first time information as a reference from multiple time information to be compressed, and then obtain the difference between the first time information and the second time information. The difference calculation can convert the same part contained in the time information into a removable redundant sub-node, remove the redundant bytes in the difference to obtain the valid bytes, and then splice the data header generated by the redundant bytes with the valid bytes to obtain the splicing result corresponding to the second time information. By storing the splicing result, the storage of the second time information is realized, and the data volume of the splicing result is greatly reduced relative to the second time information; the present application realizes efficient compression of time information through difference calculation and removal of redundant data, so that the compressed data volume is very small, the storage efficiency of time information is improved, and the storage cost is reduced. In addition, since any time information can be calculated for mutual differences, the compression scheme of calculating the difference between time information and removing redundant sub-nodes does not specifically limit the applicable time information, and the applicable scenarios of the compression scheme are more extensive and more universal.
[0091] Reference Figure 6, which shows a specific step flow chart of a time information compression method provided by an embodiment of the present application, including:
[0092] Step 201: Select first time information as a reference from multiple time information to be compressed, and determine second time information other than the first time information.
[0093] This step may specifically refer to the above step 101, which will not be described in detail here.
[0094] In one implementation, step 201 may specifically include:
[0095] Sub-step 2011: determining, from the plurality of time information, a plurality of target time information having the same data portion;
[0096] Sub-step 2012: determining the target time information that is earlier than other target time information among the multiple target time information as the first time information.
[0097] In an embodiment of the present application, for sub-steps 2011-2012, in one implementation method, a group consisting of multiple target time information containing the same data portion can be determined from multiple time information, and then target time information that is earlier than other target time information can be selected from the group as the first time information.
[0098] First of all, the time information may include time dimensions such as year, month, day, hour, minute, and second. Based on this feature, different time information may have the same value for the same time dimension. For example, the following four time information all have time dimensions of year, month, day, hour, minute, and second, and the values of the year, month, day, hour, and minute dimensions of these four time information are the same, but the difference lies in the value of the second dimension. Then, these four time information can be used as target time information to form a group, and then the first time information 2022.02.01.08:01:10, which is earlier than other time information, is selected from these four time information. 2022.02.01.08:01:10 2022.02.01.08:01:20 2022.02.01.08:01:30 2022.02.01.08:01:40
[0103] For another example, the following four time information all have time dimensions of year, month, day, hour, minute, and second, and the values under the year, month, and day dimensions of these four time information are the same, but the difference lies in the values under the hour, minute, and second dimensions. Then, these four time information can also be used as target time information to form a group, and then the first time information 2022.02.01.09:01:10, which is earlier than other time information, is selected from these four time information. 2022.02.01.09:01:10 2022.02.01.10:21:20 2022.02.01.11:41:30 2022.02.01.12:51:40
[0108] Based on the selection method of the first time information of the present implementation, an adaptive basic value selection effect can be achieved in the differential encoding process. The first time information as the reference value is selected from multiple target time information containing the same data part, so that the difference calculated between the time information and the reference value in the differential encoding process can eliminate the same data part to a greater extent, thereby leaving fewer valid bytes, thereby improving the compression efficiency of the time information.
[0109] In another implementation, step 201 may specifically include:
[0110] Sub-step 2013: determine the time information that is earlier than other time information among the multiple time information as the first time information.
[0111] In another implementation of the embodiment of the present application, time information earlier than other time information among multiple time information can be determined as the first time information. This method of selecting the reference value is fast and efficient.
[0112] In another implementation, step 201 may specifically include:
[0113] Sub-step 2014: convert the time information into an integer value.
[0114] Sub-step 2015, calculating the average value of each integer value of the multiple time information, and taking the time information corresponding to the average value as the first time information, the time information corresponding to the average value is: the time information obtained after converting the average value into a format corresponding to the time information.
[0115] In another implementation of the embodiment of the present application, for sub-steps 2014-2015, the time information can be first converted into an integer value, and then the average of the integer values of the multiple time information is calculated, and the time information obtained after the average value is converted into a format corresponding to the time information is used as the first time information. This method can also quickly select the first time information as the reference value, so that the difference between the time information and the reference value calculated during the differential encoding process can eliminate the same data part to a greater extent, thereby leaving fewer valid bytes, thereby improving the compression efficiency of the time information.
[0116] It should be noted that the embodiment of the present application may also select an intermediate value in the time information as the first time information, etc. The embodiment of the present application does not specifically limit the method for selecting the first time information.
[0117] Step 202: Convert the first time information into a first integer value, and convert the second time information into a second integer value.
[0118] In an embodiment of the present application, time information is a type of information used to represent date and time, and its forms are various, such as: xx hour: xx minute: xx second, xxxx year xx month xx day, xxxx year xx month xx day xx hour: xx minute: xx second, xxxx year xx month, xx day xx hour: xx minute, etc. Due to the diversity of forms of time information, it is difficult to directly perform unified processing on time information of different forms. An embodiment of the present application can convert the first time information into a first integer value, and convert the second time information into a second integer value, so that the time information can be subsequently processed in a unified manner based on the form of integer values, reducing the difficulty of data processing. Among them, the integer value converted from the time information can represent the early or late time information. The larger the integer value, the later the corresponding time information, and the smaller the integer value, the earlier the corresponding time information.
[0119] Optionally, step 202 may specifically include:
[0120] Sub-step 2021: convert the first time information into data in a timestamp format to obtain the first integer value, and convert the second time information into data in a timestamp format to obtain the second integer value.
[0121] In one implementation of the embodiment of the present application, the time information can be converted into a timestamp to obtain a corresponding integer value. The timestamp is used to represent a moment. The timestamp is specifically an integer that records the number of seconds. The timestamp of the current moment represents the number of seconds from 00:00:00 UTC on January 1, 1970 to the current moment, that is, the timestamp can reflect the moment through the number of seconds. For example, the moment of 10:10:10 on October 22, 2008, the corresponding timestamp can be: 1224641410. The moment of 10:10:10 on October 22, 2009, the corresponding timestamp can be: 1256177410. It can be seen that the later the time, the larger the value of the timestamp corresponding to the time.
[0122] In another implementation of the embodiment of the present application, the time information can be converted into a corresponding integer value according to a time information-integer conversion formula.
[0123] For example, for time information in the form of a date: yyyy-MM-dd-yyyy, the integer value corresponding to the time information=yyyy×16×32+MM×32+dd.
[0124] For time information in the time format: dd day hh hour mm minute ss second, the integer value corresponding to the time information = dd×24×3600+hh×3600+mm×60+ss.
[0125] For the complete time information: yyyy year MM month dd day hh hour mm minute ss second, the integer value corresponding to the time information is the concatenation of the calculation result of yyyy×10000+MM×100+dd and the calculation result of hh×10000+mm×100+ss.
[0126] Step 203: Obtain a difference between the first integer value and the second integer value.
[0127] In this step, since the first time information is converted into a first integer value and the second time information is converted into a second integer value, the data unification of the time information is achieved. Based on the difference between the first integer value and the second integer value, the difference between the first time information and the second time information can be obtained, thereby reducing the difficulty of data calculation through integer value operations.
[0128] Optionally, step 203 may specifically include:
[0129] Sub-step 2031: Obtain a difference between the first integer value and the second integer value calculated in hexadecimal format.
[0130] In an embodiment of the present application, the server may calculate the difference between the first integer value and the second integer value based on the hexadecimal format. The implementation process of this sub-step is now described by an example:
[0131] Assume that the first time information is 13:05:00 on February 16, 2023, and the second time information is 14:05:00 on February 16, 2023; the first integer value after conversion of the first time information is 1850804423710736384, and the hexadecimal form of the first integer value is: 0x19 af 60d1 40 00 00 00; the second integer value after conversion of the second time information is 1850804492430213120; the hexadecimal form of the second integer value is: 0x19 af 60e1 40 00 00 00, then the difference between the first integer value and the second integer value in hexadecimal format = (0x19 af 60e1 40 00 00 00)-(0x19 af60d1 40 00 00 00) = 0x00 00 00 10 00 00 00 00. It should be noted that, in this example, the 0s in the lower three consecutive bytes can be omitted.
[0132] Step 204: Determine the prefix part and the suffix part of the difference.
[0133] The difference is in hexadecimal format.
[0134] In an embodiment of the present application, in the hexadecimal data, the prefix part refers to the consecutive bytes from the highest bit of the hexadecimal data to the valid byte, and the suffix part refers to the consecutive bytes from the lowest bit of the hexadecimal data to the valid byte. Determining the prefix part and the suffix part of the hexadecimal difference can facilitate the subsequent deletion of redundant bytes in the hexadecimal prefix part and the suffix part, thereby realizing the compression of time information.
[0135] Step 205: Use the consecutive 0 bytes in the prefix part and the consecutive 0 bytes in the suffix part of the difference as the redundant bytes, and remove the redundant bytes in the difference to obtain valid bytes.
[0136] Due to the execution process of the above steps, the time information to be compressed is converted into a difference with a certain base value by difference calculation, so that the data part of the time information to be compressed that is the same as the base value is converted to 0. Then, in this step, the bytes converted to 0 by difference calculation in the prefix part and the suffix part of the difference can be deleted as redundant bytes, and the bytes remaining after deletion are used as valid bytes. Among them, the continuous bytes 0 in the prefix part of the difference and the continuous bytes 0 in the suffix part can be deleted as redundant bytes. For example, for a hexadecimal difference: 0x00 00 00 10 00, the redundant bytes of its prefix part are 3 bytes of 0 starting from the highest bit (00 00 00 between x and 1); the redundant bytes of the suffix part are 1 byte of 0 starting from the low and high bits (00 after 10). After removing the redundant bytes, the remaining valid bytes are 0x00. Compared with the original complete difference, the difference can be stored by storing valid bytes in the future. The valid bytes have a storage performance advantage due to their smaller data volume.
[0137] Step 206: Generate the data header according to the sign bit of the difference corresponding to the second time information, the number of consecutive byte 0s in the prefix part of the difference, and the number of consecutive byte 0s in the suffix part of the difference.
[0138] In an embodiment of the present application, a data header is information that reflects the specific operation performed on the difference during compression. The data header first stores the sign bit of the difference, that is, when the difference is a negative value, the sign bit stored in the data header is negative; when the difference is a positive value, the sign bit stored in the data header is positive; based on the data header storing the sign bit of the difference, the data header can also store the number of consecutive byte 0s deleted in the prefix part of the difference and the number of consecutive byte 0s deleted in the suffix part of the compression operation. The information contained in the data header is used to restore the difference when the time information is decompressed, and to restore the second time information based on the restored difference.
[0139] Specifically, refer to Figure 7 , the data header can be 1 byte (including 8 bits of space), and the format of the data header can be: 1-bit sign bit - 1-bit reserved bit - 3-bit data bits storing the number of consecutive byte 0s in the prefix part (representing up to 7 bytes) - 3-bit data bits storing the number of consecutive byte 0s in the suffix part (representing up to 7 bytes), and valid data bits are spliced after the data header. Among them, when the value of the sign bit is 1, it represents 0 and a positive integer; when the value of the sign bit is 0, it represents a negative number;. It should be noted that the embodiment of the present application does not specifically limit the content stored in the reserved bit.
[0140] For example, for the hexadecimal difference: 0x00 00 00 10 00, the redundant bytes of the prefix part are deleted to be 3 bytes of 0 starting from the highest bit (00 00 00 between x and 1), and the redundant bytes of the suffix part are 1 byte of 0 starting from the low and high bits (00 after 10), and the process of obtaining the valid byte 0x10, the first bit in the data header stores a 1-bit sign bit (10 represents positive, 0 represents negative, and the sign bit in this example is 1), the value of the next 1-bit reserved bit is 0, and the data bits storing the number of consecutive bytes of 0 in the prefix part of the following 3 bits are 011 (binary representation of the number 3 under 3 bits), and the data bits storing the number of consecutive bytes of 0 in the suffix part of the following 3 bits are 001 (binary representation of the number 1 under 3 bits). The final data header is 10011 001 (0x19), and the data header is spliced with the valid bytes, that is, the compressed result of the time information is 0x19 10.
[0141] It should be noted that if the difference of the 8 bytes in hexadecimal is all 0 (the time information to be compressed is equal to the base value), since the maximum number that can be represented by 3 bits is 7 (111), and the number of consecutive 0 bytes actually removed is greater than 7, the 3-bit data bits cannot directly store a value greater than 7. In order to meet the storage format in the data header, the data bits of the number of consecutive 0 bytes can be stored as 7 (111) in the prefix part of the data header, and the data bits of the number of consecutive 0 bytes can be stored as 1 (001) in the suffix part; or, The data bits of the number of consecutive byte 0s in the prefix part are 6 (110), and the data bits of the number of consecutive byte 0s in the suffix part are 2 (010); or, the data bits of the number of consecutive byte 0s in the prefix part of the data header are 5 (101), and the data bits of the number of consecutive byte 0s in the suffix part are 3 (011); or, the data bits of the number of consecutive byte 0s in the prefix part of the data header are 4 (100), and the data bits of the number of consecutive byte 0s in the suffix part are 4 (100), and so on, which will not be repeated here.
[0142] In addition, the length of the valid bytes does not need to be stored in the data header. This is because among the data types supported by the database, the date and time types are fixed-length. The fixed length minus the length of consecutive 0s in the prefix and suffix parts stored in the data header is the length of the valid bytes.
[0143] Step 207: splice the valid bytes corresponding to the second time information after the data header to obtain a splicing result corresponding to the second time information.
[0144] After the compression operation is completed, the first time information and the splicing result corresponding to the second time information can be generated as a compression result, and the compression result can be stored in the database of the server.
[0145] In a related technology, the compression process of time information includes: converting the time information into an integer, and then compressing the integer. Taking data stored in INT type as an example, its fixed size is 4 bytes. Regardless of whether the stored number is 1 or the maximum value 2147483647, it occupies 4 bytes.
[0146] 1 converted to integer: 0x0000 0000 0000 0000 0000 0000 0000 0001;
[0147] 2147483647 converted to integer: 0x1111 1111 1111 1111 1111 1111 1111 1111;
[0148] To compress an integer, you can remove the high-order 0s and store the remaining valid bytes. The specific example is as follows:
[0149] The compressed result of 1 converted to an integer: 0x0001;
[0150] The compressed integer converted to 2147483647 is: 0x1111 1111 1111 1111 1111 1111 11111111;
[0151] It can be seen that if the integer value is small, the method in the related art is very effective, but for larger integer values, there are fewer 0s in the high byte, the compression effect is not ideal, and maximum compression cannot be achieved.
[0152] The embodiment of the present application can select the first time information as a reference from multiple time information to be compressed, and then obtain the difference between the first time information and the second time information. The difference calculation can convert the same part contained in the time information into a removable redundant sub-node, and obtain the valid bytes after removing the redundant bytes in the difference. Then, the data header generated by the redundant bytes is spliced with the valid bytes to obtain the splicing result corresponding to the second time information. By storing the splicing result, the storage of the second time information is realized, and the data volume of the splicing result is greatly reduced relative to the second time information. The present application realizes efficient compression of time information through difference calculation and removal of redundant data, so that the compressed data volume is smaller, the storage efficiency of time information is improved, and the storage cost is reduced.
[0153] In addition, the present application compresses the time information by utilizing the characteristic that time information of date and time types always contains the same data part, and does not make specific limitations on the applicable time information. The compression scheme has a wider range of applicable scenarios and is more versatile.
[0154] For example, taking the following three time information as an example, these three time information are irregular, but have a common date part "2023-02-16", then the compression scheme of the embodiment of the present application can be effectively used to achieve compression. The scenarios of this situation include: user order time, access control system card swiping records, etc.
[0155] 2023-02-16 13:05:00;
[0156] 2023-02-16 13:20:30;
[0157] 2023-02-16 13:45:20;
[0158] For another example, taking the following three other time information as an example, these three time information are regularly spaced one hour apart, but they also have a common date part "2023-02-16". The compression scheme of the embodiment of the present application can be effectively used to achieve compression. The scenarios of this situation include: system logs, reminder records, etc.
[0159] 2023-02-16 13:05:00;
[0160] 2023-02-16 13:20:30;
[0161] 2023-02-16 13:45:20;
[0162] Step 208: Generate a compression result according to the first time information and the splicing result corresponding to the second time information.
[0163] This step may be specifically referred to as the above step 104, which will not be described in detail here.
[0164] In summary, refer to Figure 8 , which shows the overall flow chart of the compression scheme of the embodiment of the present application, including: X1, selecting a base value (base, i.e., the first time information); X2, selecting a time to be compressed (the second time information); X3, converting the time (the first time information and the second time information) into an integer; X4, calculating the difference (delta); X5, removing consecutive 0s in the prefix and suffix; X6, adding a data header to generate compressed data (splicing result); X7, judging whether there is any uncompressed data, if so, entering X2, if not, ending.
[0165] Finally, refer to Table 2 below, which shows the data correspondence before and after compression of the five time information of the DATE TIME type:
[0166]
[0167] Table 2
[0168] Among them, the first row of time information is the reference value (first time information). Based on the above table, it can be seen that each time information occupies 5 bytes before compression, and the compressed data occupies 1-3 bytes. The embodiment of the present application realizes efficient time information compression.
[0169] Reference Fig. 9 , which shows a schematic diagram of an implementation example of compression of time information. Assuming that the first time information selected as the benchmark is: 2023.02.16 13:05:00, the first time information in integer format is: 1850804426710736384; the first time information in hexadecimal format is: 0x19 af 60 d1 40 00 00 00; the first time information with the low-order bytes removed is: 0x19 af 60 d1 40.
[0170] Assume that the second time information to be compressed is: 2023.02.16 14:05:00; the compression process first executes S1, converting the second time information to be compressed into an integer. The second time information in integer format is: 1850804492430213120; the second time information in hexadecimal format is: 0x19 af 60 e1 40 00 00 00.
[0171] Then, S2 is executed to remove the low-order byte of the second time information. The second time information with the low-order byte removed is: 0x19af 60 e1 40. Then, S3 is executed to calculate the difference. After calculating the difference between the first time information with the low-order byte removed: 0x19 af 60 d1 40 and the second time information with the low-order byte removed: 0x19 af 60 e1 40, the difference is obtained: 0x00 00 0010 00. Then, S4 is executed to remove the redundant bytes in the difference. For the hexadecimal difference: 0x00 00 00 10 00, the redundant bytes of the prefix part are 3 bytes of 0 starting from the highest bit (00 00 00 between x and 1); the redundant bytes of the suffix part are 1 byte of 0 starting from the low and high bits (00 after 10). After removing the redundant bytes, the remaining valid bytes are 0x00. Compared with the original complete difference, the difference can be stored by storing valid bytes. The valid bytes have a storage performance advantage due to their smaller data volume.
[0172] After removing redundant bytes from the difference to obtain valid bytes, S5 is executed to generate a data header based on redundant bytes. The first bit in the data header stores a 1-bit sign bit (10 indicates positive, 00 indicates negative, and the sign bit in this example is 10), and then the 3-bit data bits storing the number of consecutive bytes 0 in the prefix part are 011 (representation of the number 3 under 3 bits), and the 3-bit data bits storing the number of consecutive bytes 0 in the suffix part are 001 (representation of the number 1 under 3 bits). The final data header is 0x19 (10 011001), and finally S6 is executed to splice the data header and valid bytes, and the splicing result is 0x19 10.
[0173] In summary, the present application can select the first time information as a reference from multiple time information to be compressed, and then obtain the difference between the first time information and the second time information. The difference calculation can convert the same part contained in the time information into a removable redundant sub-node, remove the redundant bytes in the difference to obtain the valid bytes, and then splice the data header generated by the redundant bytes with the valid bytes to obtain the splicing result corresponding to the second time information. By storing the splicing result, the storage of the second time information is realized, and the data volume of the splicing result is greatly reduced relative to the second time information; the present application realizes efficient compression of time information through difference calculation and removal of redundant data, so that the compressed data volume is very small, the storage efficiency of time information is improved, and the storage cost is reduced. In addition, since any time information can be calculated for mutual differences, the compression scheme of calculating the difference between time information and removing redundant sub-nodes does not specifically limit the applicable time information, and the applicable scenarios of the compression scheme are more extensive and more universal.
[0174] Reference Fig.10 , which shows a flowchart of the steps of a method for decompressing time information provided by an embodiment of the present application, including:
[0175] Step 301: Obtain a compression result of second time information.
[0176] Among them, the compression result includes: first time information, and a splicing result corresponding to the second time information, the first time information is the time information used as a benchmark among multiple time information before compression; the second time information is the time information other than the first time information among multiple time information; the splicing result is formed by splicing valid bytes and a data header; the valid bytes are the remaining bytes after removing redundant bytes from the difference between the first time information and the second time information, and the data header is generated based on the redundant bytes.
[0177] Step 302: parse the data header in the splicing result to obtain the redundant bytes.
[0178] Step 303: merge the redundant bytes with the valid bytes in the splicing result to obtain a difference between the first time information and the second time information.
[0179] Step 304: Obtain the restored second time information according to the difference and the first time information, thereby completing the decompression of the time information.
[0180] In an embodiment of the present application, for steps 301-304, when the time information needs to be used again after compression, the data header in the splicing result corresponding to the second time information can be extracted, and based on the information obtained by parsing the data header, the valid bytes in the splicing result can be restored to the second time information, thereby achieving rapid decompression of the time information and meeting the need for rapid restoration of the time information for use.
[0181] For example, assuming that a splicing result in the compression result includes a valid byte 0x10, the data header in the splicing result records the sign bit of the difference obtained by the difference calculation, and the redundant bytes include: 3 consecutive bytes of 0 starting from the highest bit of the prefix part, and 1 byte of 0 starting from the lowest bit of the suffix part, then the redundant bytes are first combined with the valid bytes to obtain the restored difference: 0x00 00 00 10 00; then the restored difference and the read first time information (in hexadecimal form) are used to reverse the difference calculation (if the difference calculation during compression is the first time information - the second time information = the difference, then the reverse calculation here is the first time information - the difference = the second time information; if the difference calculation during compression is the second time information - the first time information = the difference, then the reverse calculation here is the first time information + the difference = the second time information), to obtain the restored second time information.
[0182] In summary, refer to Fig.11 , which shows the overall flow chart of the decompression scheme of the embodiment of the present application, including: Y1, reading the base value (base, i.e., the first time information); Y2, selecting a time to be decompressed (the second time information); Y3, parsing the data header to obtain the number of consecutive 0 bytes in the prefix and suffix parts; Y4, reading the valid byte bits and completing the consecutive 0s in the prefix and suffix parts; Y5, using the base value to restore the original integer; Y6, converting the original integer into time (the second time information).
[0183] Optionally, step 302 may specifically include:
[0184] Sub-step 3021: parse the data header to obtain consecutive byte 0s in the prefix part and consecutive byte 0s in the suffix part that are removed for the difference during compression.
[0185] Optionally, based on sub-step 3021, step 303 may specifically include:
[0186] Sub-step 3031: merge the consecutive bytes 0 in the prefix part and the consecutive bytes 0 in the suffix part with the valid bytes in the splicing result to obtain the difference between the first time information and the second time information.
[0187] Optionally, the data header further includes: a sign bit of the difference; and step 304 may specifically include:
[0188] Sub-step 3041: perform a sum calculation of the difference and the first time information according to the sign bit of the difference to obtain the restored second time information.
[0189] In the embodiment of the present application, for sub-steps 3021, 3031, 3041, and 3042, the decompression process can actually be the inverse process of the compression process, that is, the process of restoring the second time information based on a splicing result of a second time information, firstly, the data header of the splicing result is parsed to obtain the consecutive byte 0s in the prefix part and the consecutive byte 0s in the suffix part for the difference removed during compression, and then the consecutive byte 0s in the prefix part and the consecutive byte 0s in the suffix part are merged with the valid bytes in the splicing result to obtain the restored difference, and finally, according to the sign bit of the difference obtained by parsing in the data header, the difference and the first time information are added and calculated to obtain the restored second time information.
[0190] The decompression process is described through an example:
[0191] Assume that the concatenation result of the second time information is: 0x19 10, and the read first time information is 0x19 af60d1 40. The data header 0x19 represents (10 011 001), 10 represents that the sign bit of the difference is positive, 011 represents that the number of consecutive 0 bytes in the prefix part is 3; 001 represents that the number of consecutive 0 bytes in the suffix part is 1, then the valid bytes are concatenated with the consecutive 0 bytes of the prefix part and the suffix part to obtain the restored difference 0x00 00 00 10 00, and the difference is added to the first time information to obtain the restored hexadecimal second time information = (0x00 00 00 10 00) + (0x19 af 60d1 40) = 0x19 af 60e1 40, and the hexadecimal second time information is converted into an integer and then converted into a time value to obtain 2023.02.1614:05:00, thereby completing the decompression.
[0192] In summary, the present application can select the first time information as a reference from multiple time information to be compressed, and then obtain the difference between the first time information and the second time information. The difference calculation can convert the same part contained in the time information into a removable redundant sub-node, remove the redundant bytes in the difference to obtain the valid bytes, and then splice the data header generated by the redundant bytes with the valid bytes to obtain the splicing result corresponding to the second time information. By storing the splicing result, the storage of the second time information is realized, and the data volume of the splicing result is greatly reduced relative to the second time information; the present application realizes efficient compression of time information through difference calculation and removal of redundant data, so that the compressed data volume is very small, the storage efficiency of time information is improved, and the storage cost is reduced. In addition, since any time information can be calculated for mutual differences, the compression scheme of calculating the difference between time information and removing redundant sub-nodes does not specifically limit the applicable time information, and the applicable scenarios of the compression scheme are more extensive and more universal.
[0193] Furthermore, when the time information needs to be used again after compression, the data header in the splicing result corresponding to the second time information can be extracted, and based on the information obtained by parsing the data header, the valid bytes in the splicing result can be restored to the second time information, thereby achieving rapid decompression of the time information and meeting the need to quickly restore the time information for use.
[0194] Reference Fig.12 , which shows a block diagram of a time information compression device provided by an embodiment of the present application, including:
[0195] A selection module 401 is used to select first time information as a reference from multiple time information to be compressed, and determine second time information other than the first time information;
[0196] A difference module 402 is used to obtain a difference between the first time information and the second time information, where the second time information is time information other than the first time information among the multiple time information;
[0197] The processing module 403 is used to determine the redundant bytes in the difference and generate a data header according to the redundant bytes;
[0198] A splicing module 404 is used to remove redundant bytes in the difference to obtain valid bytes, and splice the data header with the valid bytes to obtain a splicing result corresponding to the second time information;
[0199] The generating module 405 is used to generate a compression result according to the first time information and the splicing result corresponding to the second time information.
[0200] Optionally, the difference module 402 includes:
[0201] a conversion submodule, configured to convert the first time information into a first integer value, and convert the second time information into a second integer value;
[0202] The first difference submodule is used to obtain the difference between the first integer value and the second integer value.
[0203] Optionally, the difference module 402 includes:
[0204] The second difference submodule is used to obtain a difference between the first integer value and the second integer value calculated in hexadecimal format.
[0205] Optionally, the conversion submodule includes:
[0206] The conversion unit is used to convert the first time information into data in a timestamp format to obtain the first integer value, and to convert the second time information into data in a timestamp format to obtain the second integer value.
[0207] Optionally, the difference is in hexadecimal format; the processing module 403 includes:
[0208] A first determination submodule, used to determine a prefix part and a suffix part of the difference;
[0209] The identification submodule is used to use the consecutive 0 bytes in the prefix part and the consecutive 0 bytes in the suffix part of the difference as the redundant bytes.
[0210] Optionally, the processing module 403 includes:
[0211] A generating submodule, configured to generate the data header according to a sign bit of a difference value corresponding to the second time information, a number of consecutive byte 0s in a prefix part of the difference value, and a number of consecutive byte 0s in a suffix part of the difference value;
[0212] The splicing module 404 includes:
[0213] The splicing submodule is used to splice the valid bytes corresponding to the second time information after the data header to obtain a splicing result corresponding to the second time information.
[0214] Optionally, the selection module 401 includes:
[0215] A second determining submodule is used to determine a plurality of target time information having the same data portion from the plurality of time information;
[0216] The third determining submodule is configured to determine the target time information earlier than the other target time information among the plurality of target time information as the first time information.
[0217] Optionally, the selection module 401 includes:
[0218] The fourth determining submodule is used to determine the time information earlier than the other time information among the multiple time information as the first time information.
[0219] Optionally, the selection module 401 includes:
[0220] An integer submodule, used for converting the time information into an integer value;
[0221] The fifth determination submodule is used to calculate the average value of the integer values of the multiple time information, and use the time information corresponding to the average value as the first time information. The time information corresponding to the average value is: the time information obtained after converting the average value into the format corresponding to the time information.
[0222] In summary, the present application can select the first time information as a reference from multiple time information to be compressed, and then obtain the difference between the first time information and the second time information. The difference calculation can convert the same part contained in the time information into a removable redundant sub-node, remove the redundant bytes in the difference to obtain the valid bytes, and then splice the data header generated by the redundant bytes with the valid bytes to obtain the splicing result corresponding to the second time information. By storing the splicing result, the storage of the second time information is realized, and the data volume of the splicing result is greatly reduced relative to the second time information; the present application realizes efficient compression of time information through difference calculation and removal of redundant data, so that the compressed data volume is very small, the storage efficiency of time information is improved, and the storage cost is reduced. In addition, since any time information can be calculated for mutual differences, the compression scheme of calculating the difference between time information and removing redundant sub-nodes does not specifically limit the applicable time information, and the applicable scenarios of the compression scheme are more extensive and more universal.
[0223] Reference Fig.13 , which shows a block diagram of a time information decompression device provided by an embodiment of the present application, including:
[0224] The acquisition module 501 is used to acquire a compression result of the second time information, wherein the compression result includes: the first time information, and a splicing result corresponding to the second time information, wherein the first time information is the time information used as a reference among multiple time information before compression; the second time information is the time information other than the first time information among the multiple time information; the splicing result is formed by splicing valid bytes and a data header; the valid bytes are the remaining bytes after removing redundant bytes from the difference between the first time information and the second time information, and the data header is generated based on the redundant bytes;
[0225] A parsing module 502 is used to parse the data header in the splicing result to obtain the redundant bytes;
[0226] A merging module 503, configured to merge the redundant bytes with the valid bytes in the splicing result to obtain a difference between the first time information and the second time information;
[0227] The restoration module 504 is used to obtain the restored second time information according to the difference and the first time information, thereby completing the decompression of the time information.
[0228] Optionally, the parsing module 502 includes:
[0229] A parsing submodule, used for parsing the data header to obtain consecutive byte 0s in the prefix part and consecutive byte 0s in the suffix part removed for the difference during compression;
[0230] The merging module 503 includes:
[0231] A merging submodule is used to merge the consecutive byte 0s in the prefix part and the consecutive byte 0s in the suffix part with the valid bytes in the splicing result to obtain the difference between the first time information and the second time information.
[0232] Optionally, the data header further includes: a sign bit of the difference;
[0233] The restoration module 504 includes:
[0234] A calculation submodule is used to perform a sum calculation of the difference and the first time information according to a sign bit of the difference to obtain the restored second time information.
[0235] In summary, the present application can select the first time information as a reference from multiple time information to be compressed, and then obtain the difference between the first time information and the second time information. The difference calculation can convert the same part contained in the time information into a removable redundant sub-node, remove the redundant bytes in the difference to obtain the valid bytes, and then splice the data header generated by the redundant bytes with the valid bytes to obtain the splicing result corresponding to the second time information. By storing the splicing result, the storage of the second time information is realized, and the data volume of the splicing result is greatly reduced relative to the second time information; the present application realizes efficient compression of time information through difference calculation and removal of redundant data, so that the compressed data volume is very small, the storage efficiency of time information is improved, and the storage cost is reduced. In addition, since any time information can be calculated for mutual differences, the compression scheme of calculating the difference between time information and removing redundant sub-nodes does not specifically limit the applicable time information, and the applicable scenarios of the compression scheme are more extensive and more universal.
[0236] Furthermore, when the time information needs to be used again after compression, the data header in the splicing result corresponding to the second time information can be extracted, and based on the information obtained by parsing the data header, the valid bytes in the splicing result can be restored to the second time information, thereby achieving rapid decompression of the time information and meeting the need to quickly restore the time information for use.
[0237] The embodiment of the present application also provides a non-volatile readable storage medium, which stores one or more modules (programs). When the one or more modules are applied to a device, the device can execute instructions (instructions) of each method step in the embodiment of the present application.
[0238] The present application embodiment provides one or more machine-readable media on which instructions are stored, and when executed by one or more processors, an electronic device executes one or more of the methods described in the above embodiments. In the present application embodiment, the electronic device includes various types of devices such as terminal devices and server terminals (clusters).
[0239] The embodiments of the present disclosure may be implemented as a device that uses any appropriate hardware, firmware, software, or any combination thereof to perform desired configurations, and the device may include electronic devices such as terminal devices and server (cluster). Fig.14 An exemplary device 1000 that can be used to implement various embodiments described in the embodiments of the present application is schematically shown.
[0240] For one embodiment, Fig.14An exemplary apparatus 1000 is shown having one or more processors 1002, a control module (chip set) 1004 coupled to at least one of the (one or more) processors 1002, a memory 1006 coupled to the control module 1004, a non-volatile memory (NVM) / storage device 1008 coupled to the control module 1004, one or more input / output devices 1010 coupled to the control module 1004, and a network interface 1012 coupled to the control module 1004.
[0241] The processor 1002 may include one or more single-core or multi-core processors, and the processor 1002 may include any combination of general-purpose processors or special-purpose processors (such as graphics processors, application processors, baseband processors, etc.). In some embodiments, the device 1000 can be used as a terminal device, a server (cluster), and other devices described in the embodiments of the present application.
[0242] In some embodiments, the apparatus 1000 may include one or more computer-readable media (e.g., memory 1006 or NVM / storage device 1008) having instructions 1014 and one or more processors 1002 combined with the one or more computer-readable media and configured to execute the instructions 1014 to implement a module to perform the actions described in the present disclosure.
[0243] For one embodiment, the control module 1004 may include any suitable interface controller to provide any suitable interface to at least one of the processor(s) 1002 and / or any suitable device or component in communication with the control module 1004 .
[0244] The control module 1004 may include a memory controller module to provide an interface to the memory 1006. The memory controller module may be a hardware module, a software module, and / or a firmware module.
[0245] The memory 1006 may be used, for example, to load and store data and / or instructions 1014 for the device 1000. For one embodiment, the memory 1006 may include any suitable volatile memory, such as a suitable dynamic random access memory (DRAM). In some embodiments, the memory 1006 may include a double data rate type four synchronous dynamic random access memory.
[0246] For one embodiment, control module 1004 may include one or more input / output controllers to provide an interface to NVM / storage device 1008 and input / output device(s) 1010 .
[0247] For example, NVM / storage device 1008 may be used to store data and / or instructions 1014. NVM / storage device 1008 may include any suitable non-volatile memory (e.g., flash memory) and / or may include any suitable non-volatile storage device(s) (e.g., one or more hard disk drives (HDDs), one or more compact disc (CD) drives, and / or one or more digital versatile disc (DVD) drives).
[0248] NVM / storage device 1008 may include storage resources that are physically part of the device on which apparatus 1000 is installed, or it may be accessible to the device without being part of the device. For example, NVM / storage device 1008 may be accessed via input / output device(s) 1010 over a network.
[0249] (One or more) input / output devices 1010 may provide an interface for the apparatus 1000 to communicate with any other appropriate device, and the input / output device 1010 may include a communication component, an audio component, a sensor component, etc. The network interface 1012 may provide an interface for the apparatus 1000 to communicate through one or more networks, and the apparatus 1000 may wirelessly communicate with one or more components of a wireless network according to any of one or more wireless network standards and / or protocols, for example, accessing a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G, 5G, etc., or a combination thereof for wireless communication.
[0250] For one embodiment, at least one of the processor(s) 1002 may be packaged together with the logic of one or more controllers (e.g., a memory controller module) of the control module 1004. For one embodiment, at least one of the processor(s) 1002 may be packaged together with the logic of one or more controllers of the control module 1004 to form a system-in-package. For one embodiment, at least one of the processor(s) 1002 may be integrated on the same die with the logic of one or more controllers of the control module 1004. For one embodiment, at least one of the processor(s) 1002 may be integrated on the same die with the logic of one or more controllers of the control module 1004 to form a system on chip (SoC).
[0251] In various embodiments, the device 1000 may be, but is not limited to, a terminal device such as a server, a desktop computing device, or a mobile computing device (e.g., a laptop computing device, a handheld computing device, a tablet computer, a netbook, etc.). In various embodiments, the device 1000 may have more or fewer components and / or different architectures. For example, in some embodiments, the device 1000 includes one or more cameras, a keyboard, a liquid crystal display (LCD, Laser cladding deposition) screen (including a touch screen display), a non-volatile memory port, multiple antennas, a graphics chip, an application specific integrated circuit (ASIC, Application Specific Integrated Circuit) and a speaker.
[0252] Among them, the main control chip can be used as a processor or control module in the detection device, sensor data, location information, etc. are stored in a memory or NVM / storage device, the sensor group can be used as an input / output device, and the communication interface may include a network interface.
[0253] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0254] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0255] The present application embodiment is described with reference to the flowchart and / or block diagram of the method, terminal device (system) and computer program product according to the embodiment of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, and the combination of the process and / or box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device produce a device for implementing the function specified in one process or multiple processes in the flowchart and / or one box or multiple boxes in the block diagram.
[0256] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0257] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce computer-implemented processing, so that the instructions executed on the computer or other programmable terminal device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0258] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0259] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0260] The above is a detailed introduction to a time information compression method and device, electronic device, and machine-readable medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. Under the same circumstances, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for compressing time information, characterized in that: include: Selecting first time information as a reference from a plurality of time information to be compressed; Obtaining a difference between the first time information and second time information, where the second time information is time information other than the first time information among the multiple time information; Determine the redundant bytes in the difference, and generate a data header according to the redundant bytes; removing redundant bytes in the difference to obtain valid bytes, and splicing the data header with the valid bytes to obtain a splicing result corresponding to the second time information; A compression result is generated according to the first time information and a splicing result corresponding to the second time information.
2. The method according to claim 1, characterized in that Acquiring a difference between the first time information and the second time information includes: converting the first time information into a first integer value, and converting the second time information into a second integer value; A difference between the first integer value and the second integer value is obtained.
3. The method according to claim 1, characterized in that The difference is in hexadecimal format; The determining of redundant bytes in the difference comprises: determining a prefix portion and a suffix portion of the difference; The consecutive 0 bytes in the prefix part and the consecutive 0 bytes in the suffix part of the difference are used as the redundant bytes.
4. The method according to claim 3, characterized in that The step of generating a data header according to the redundant bytes comprises: Generate the data header according to the sign bit of the difference value corresponding to the second time information, the number of consecutive byte 0s in the prefix part of the difference value, and the number of consecutive byte 0s in the suffix part of the difference value; The step of splicing the data header with the valid bytes to obtain a splicing result corresponding to the second time information includes: The valid bytes corresponding to the second time information are spliced after the data header to obtain a splicing result corresponding to the second time information.
5. The method according to claim 1, characterized in that The selecting, from the plurality of time information to be compressed, the first time information as a reference comprises: Determine, from the plurality of time information, a plurality of target time information having the same data portion; The target time information that is earlier than other target time information among the multiple target time information is determined as the first time information.
6. The method according to claim 1, characterized in that The selecting, from the plurality of time information to be compressed, the first time information as a reference comprises: The time information earlier than other time information among the multiple time information is determined as the first time information.
7. The method according to claim 1, characterized in that The selecting, from the plurality of time information to be compressed, the first time information as a reference comprises: Converting the time information into an integer value; Calculate the average of the integer values of the multiple time information, and use the time information corresponding to the average as the first time information. The time information corresponding to the average is: the time information obtained after converting the average into a format corresponding to the time information.
8. A method for decompressing time information, characterized in that: include: Obtaining a compression result of the second time information, the compression result comprising: the first time information, and a splicing result corresponding to the second time information, the first time information being time information used as a benchmark among multiple time information before compression; the second time information being time information other than the first time information among the multiple time information; the splicing result being formed by splicing valid bytes and a data header; the valid bytes being bytes remaining after redundant bytes are removed from a difference between the first time information and the second time information, and the data header being generated based on the redundant bytes; Parsing the data header in the splicing result to obtain the redundant bytes; Merging the redundant bytes with the valid bytes in the splicing result to obtain a difference between the first time information and the second time information; The restored second time information is obtained according to the difference and the first time information.
9. The method according to claim 8, characterized in that The step of parsing the data header in the splicing result to obtain redundant bytes includes: Parsing the data header to obtain consecutive byte 0s in the prefix part and consecutive byte 0s in the suffix part removed for the difference during compression; The combining the redundant bytes with the valid bytes in the splicing result to obtain the difference between the first time information and the second time information includes: The continuous byte 0s in the prefix part and the continuous byte 0s in the suffix part are combined with the valid bytes in the splicing result to obtain the difference between the first time information and the second time information.
10. The method according to claim 8, characterized in that The data header further includes: a sign bit of the difference value; The step of obtaining restored second time information according to the difference and the first time information includes: According to the sign bit of the difference, the difference and the first time information are added to obtain the restored second time information.
11. A device for compressing time information, characterized in that: include: A selection module, used to select first time information as a reference from a plurality of time information to be compressed, and determine second time information other than the first time information; A difference module, used to obtain a difference between the first time information and the second time information, where the second time information is time information other than the first time information among the multiple time information; A processing module, used for determining redundant bytes in the difference and generating a data header according to the redundant bytes; a splicing module, configured to remove redundant bytes in the difference to obtain valid bytes, and splice the data header with the valid bytes to obtain a splicing result corresponding to the second time information; A generation module is used to generate a compression result according to the first time information and a splicing result corresponding to the second time information.
12. A time information decompression device, characterized in that: include: an acquisition module, configured to acquire a compression result of the second time information, the compression result comprising: the first time information, and a splicing result corresponding to the second time information, the first time information being time information used as a benchmark among a plurality of time information before compression; the second time information being time information other than the first time information among the plurality of time information; the splicing result being formed by splicing valid bytes and a data header; the valid bytes being the remaining bytes after removing redundant bytes from a difference between the first time information and the second time information, and the data header being generated based on the redundant bytes; A parsing module, used for parsing the data header in the splicing result to obtain the redundant bytes; a merging module, configured to merge the redundant bytes with the valid bytes in the splicing result to obtain a difference between the first time information and the second time information; The restoration module is used to obtain the restored second time information according to the difference and the first time information, thereby completing the decompression of the time information.
13. An electronic device, characterized in that: include: processor; and A memory having executable codes stored thereon, which, when the executable codes are executed, enable the processor to perform the method according to any one of claims 1 to 10.
14. One or more machine-readable media having executable codes stored thereon, which, when executed, cause a processor to perform the method according to any one of claims 1 to 10.