Method and apparatus for compressing time information, and method and apparatus for decompressing time information

By selecting the reference value of time information, calculating the difference value and removing redundant bytes, generating data heads and effective bytes splicing, the problems of poor time information compression performance and limitations in the existing technology are solved, and efficient and general Time information compression.

WO2025036004A1PCT designated stage expired Publication Date: 2025-02-20ALIBABA CLOUD COMPUTING CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/103715
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-08-15
Filing Date
2024-07-04
Publication Date
2025-02-20

AI Technical Summary

Technical Problem

The prior art has poor performance in time information compression and has limited applicable scenarios, especially when removing high-bit 0 data bits, resulting in poor compression performance and relying on the compression of fixed time interval data, which is limited in applicability.

Method used

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 byte splicing are generated , obtain compression results.

Benefits of technology

It realizes efficient compression of time information, the compressed data volume is small, which improves storage efficiency and reduces storage costs. It has a wide range of applicable scenarios and is universal.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024103715_20022025_PF_FP_ABST
    Figure CN2024103715_20022025_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the embodiments of the present application are a method and apparatus for compressing time information. The method comprises: selecting first time information serving as a reference; acquiring the difference value between the first time information and second time information; determining redundant bytes in the difference value, and generating a data header on the basis of the redundant bytes; removing the redundant bytes from the difference value, so as to obtain effective bytes, splicing the data header with the effective bytes, so as to obtain a splicing result corresponding to the second time information; and on the basis of the first time information and the splicing result corresponding to the second time information, generating a compression result. In the present application, by means of calculating a difference value and removing redundant data, time information is efficiently compressed, and a storage cost is reduced. In addition, the difference value calculation can be performed on any two pieces of time information, and therefore time information for which the compression solution of calculating the difference value between time information and removing redundant bytes is suitable for is not specifically defined, such that the compression solution is applicable to more scenarios and has better universality.
Need to check novelty before this filing date? Find Prior Art

Description

Time information compression method, time information decompression method and device Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a time information compression method, time information decompression method, device, electronic device, and 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 a fixed time interval, can compress the fixed interval time information by saving the timestamp difference between two adjacent time information.

[0004] However, in the current solution, after removing the high-order 0s, method 1 still leaves many data bits, resulting in poor compression performance; while method 2 relies on compressing data at fixed time intervals, and its applicable scenarios are relatively limited.

[0005] Summary of the Invention

[0006] 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.

[0007] Correspondingly, the embodiments of the present application also provide 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.

[0008] In order to solve the above problems, an embodiment of the present application discloses a method for compressing time information, the method comprising:

[0009] Selecting first time information as a reference from a plurality of time information to be compressed;

[0010] 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;

[0011] determining a redundant byte in the difference, and generating a data header according to the redundant byte;

[0012] removing redundant bytes from the difference to obtain valid bytes, and concatenating the data header with the valid bytes to obtain a concatenation result corresponding to the second time information;

[0013] A compression result is generated according to the first time information and a splicing result corresponding to the second time information.

[0014] The present application discloses a method for decompressing time information, the method comprising:

[0015] Obtaining a compression result of the second time information, the compression result including: first time information, and a concatenation result corresponding to the second time information, wherein the first time information is time information serving as a benchmark among multiple time information before compression; the second time information is time information other than the first time information among the multiple time information; the concatenation result is formed by concatenating valid bytes and a data header; the valid bytes are bytes remaining after removing redundant bytes from a difference between the first time information and the second time information, and the data header is generated based on the redundant bytes;

[0016] Parsing the data header in the splicing result to obtain the redundant bytes;

[0017] 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;

[0018] The restored second time information is obtained according to the difference and the first time information.

[0019] The present application discloses a device for compressing time information, the device comprising:

[0020] a selection module, configured to select first time information as a reference from a plurality of time information to be compressed, and to determine second time information other than the first time information;

[0021] a difference module, configured 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 plurality of time information;

[0022] a processing module, configured to determine a redundant byte in the difference and generate a data header according to the redundant byte;

[0023] a splicing module, configured to remove redundant bytes from 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;

[0024] A generating module is used to generate a compression result according to the first time information and a splicing result corresponding to the second time information.

[0025] The embodiment of the present application discloses a device for compressing online course time information, the device comprising:

[0026] an acquisition module, configured to acquire a compression result of the second time information, the compression result comprising: first time information, and a concatenation result corresponding to the second time information, wherein the first time information is time information serving as a benchmark among multiple time information before compression; the second time information is time information among the multiple time information other than the first time information; the concatenation result is formed by concatenating valid bytes and a data header; the valid bytes are bytes remaining after removing redundant bytes from a difference between the first time information and the second time information, and the data header is generated based on the redundant bytes;

[0027] A parsing module, configured to parse the data header in the splicing result to obtain the redundant bytes;

[0028] 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;

[0029] 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.

[0030] An embodiment of the present application further discloses an electronic device, including: a processor; and a memory storing executable code, wherein when the executable code is executed, the processor executes one or more methods described in the embodiments of the present application.

[0031] The embodiments of the present application also disclose one or more machine-readable media storing executable codes, which, when executed, enable a processor to execute one or more methods described in the embodiments of the present application.

[0032] Compared with the related art, the embodiments of the present application have the following advantages:

[0033] 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-section, 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 achieved, 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 difference, the compression scheme using the calculation of the difference between time information and the removal of redundant sub-sections does not specifically limit the applicable time information. The applicable scenarios of the compression scheme are more extensive and more universal. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] FIG1 is a system architecture diagram of an embodiment of the present application;

[0035] FIG2 is a schematic diagram of a time information compression scenario of an e-commerce application according to an embodiment of the present application;

[0036] FIG3 is a schematic diagram of a time information compression scenario for a logistics application according to an embodiment of the present application;

[0037] FIG4 is a schematic diagram of a compression scenario of time information of a learning application according to an embodiment of the present application;

[0038] FIG5 is a flowchart of a method for compressing time information according to an embodiment of the present application;

[0039] FIG6 is a flowchart showing the specific steps of a method for compressing time information according to an embodiment of the present application;

[0040] FIG7 is a schematic diagram of a data header according to an embodiment of the present application;

[0041] FIG8 is an overall flow chart of a compression solution according to an embodiment of the present application;

[0042] FIG9 is a schematic diagram of an implementation example of time information compression according to an embodiment of the present application;

[0043] FIG10 is a flowchart of a method for decompressing time information according to an embodiment of the present application;

[0044] FIG11 is an overall flow chart of a decompression solution according to an embodiment of the present application;

[0045] FIG12 is a block diagram of a time information compression device according to an embodiment of the present application;

[0046] FIG13 is a block diagram of a time information decompression device according to an embodiment of the present application;

[0047] FIG14 is a schematic structural diagram of a device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0049] To help those skilled in the art better understand this application, the concepts involved in this application are explained below:

[0050] Time information: a type of information used to represent 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 packages, etc. The data types supported by the time information of the embodiment of the present application include: DATE type, TIME type, TIMESTAMP type; DATETIME type, etc.; among them, the data of DATE type occupies 3 bytes and is used to store the number of days; the data of TIME type occupies 3-6 bytes (including a decimal part of 1-3 bytes) and is used to store the moment; the data of TIMESTAMP type occupies 4-7 bytes (including a decimal part of 1-3 bytes) and is used to store the timestamp; the data of DATETIME type occupies 5-8 bytes (including a decimal part of 1-3 bytes), and the time information of DATETIME type is divided into two parts, the first part stores the date (year, month, day), and the second part stores the time (hour, minute, and second).

[0051] Compression of time information: Reduce the amount of time information data through compression to save storage space.

[0052] Decompression of time information: the process of restoring the compressed result of time information to time information.

[0053] Differential coding: also known as difference calculation, is a widely used encoding 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.

[0054] First time information: It is the time information used as the 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 the repeated parts in the time information (such as the repeated year, month, and day parts) through the difference calculation.

[0055] Second time information: refers to other time information in a set of time information except the first time information.

[0056] 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 only the valid bytes of the difference. Therefore, for the time information, the valid bytes remaining after removing the redundant bytes can be stored by storing the corresponding difference, which greatly saves storage space and improves compression efficiency.

[0057] The header is used to identify redundant bytes and the sign bit of the difference. The sign bit of the difference between valid bytes in the header indicates whether the difference is positive or negative. The redundant byte signature includes the number of consecutive bytes that were removed from the difference. Later, during decompression, the information obtained from parsing the header can be used to restore the time information.

[0058] 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 January 1, 1970 00:00:00).

[0059] 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. These time information reflect the order placement time. In order to reduce the storage space of the data and save costs, an effective method is to compress these 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 and second time information (time information other than the time information), the difference calculation can convert the same part contained in the time information into 0; after removing the redundant bytes (bytes that are 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 difference, the compression scheme of calculating the difference between time information and removing redundant sub-nodes does not make specific restrictions on the applicable time information, and the applicable scenarios of the compression scheme are wider and more universal.

[0060] 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 realizing rapid decompression of the time information and meeting the need for rapid restoration of the time information for use.

[0061] 1 , which shows a system architecture diagram of a method for processing time information provided in an embodiment of the present application, the server includes: a preprocessing module, a compression module, a generation module, and a decompression module.

[0062] In an embodiment of the present application, the server can compress the time information through a preprocessing module, a compression module, and a generation module to obtain a compression result, and can also decompress the compression result through a decompression module to obtain restored time information.

[0063] 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 during data compression. In this way, the differential encoding process can use the fixed first time information to calculate the difference, reducing the computational 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. The embodiments of the present application do not limit this.

[0064] After selecting the first time information as a benchmark, 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, then 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 remaining in the difference is the difference between 20 seconds in the first time information and 10 seconds in the second time information.

[0065] 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 and suffix parts 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.

[0066] 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.

[0067] After the compression operation is completed, the generating module of the server 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.

[0068] It should be noted that, in one case, the compression module may compress the first time information (i.e., calculate the difference between the first time information and the first time information) to obtain a compressed result of the first time information; in another case, the compression module may not compress the first time information, but instead store the first time information in an associated location near the compressed data or in a preset storage location, so that the first time information can be read from this location during subsequent decompression to achieve decompression. For example, in a database using fixed-size data pages, the first time information can be stored in a predefined fixed location on the data page.

[0069] 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.

[0070] 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:

[0071] In another implementation, referring to FIG2 , a schematic diagram of a compression scenario of time information of an e-commerce application provided by an embodiment of the present application is shown. 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 a product shelf time, etc. The e-commerce server can maintain these time information through a database. Specifically, the e-commerce server can use the time information compression method described above in the embodiment of the present application, and finally obtain the compressed result after the time information is compressed through reference value selection, differential encoding, and removal of redundant sub-sections. The compressed result is stored in the database, which can effectively reduce the space occupied by the data and increase the storage cost. In the case that the e-commerce server needs to use the time information later, the e-commerce server can obtain redundant bytes by parsing the data header of the compression result, and use the redundant bytes to restore the complete difference. Finally, the reference value is read, and the reverse operation of differential encoding is performed 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 FIG3 , a schematic diagram of a compression scenario of time information of a logistics application provided by an embodiment of the present application is shown. 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 a database. Specifically, the logistics service end can use the time information compression method described above in the embodiment of the present application, and finally obtain the compressed result after the time information is compressed by selecting a reference value, performing differential coding, and removing redundant sub-nodes. The compressed result is stored in the database, which can effectively reduce the space occupied by the data and improve the storage cost. In the case where 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. Finally, the reference value is read, and the reverse operation of differential coding is performed 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] In another implementation, referring to FIG4 , it 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 this 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 compressed result after the time information is compressed by selecting a reference value, performing differential coding, and removing redundant sub-sections. The compressed result is stored 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 obtain redundant bytes by parsing the data header of the compression result, and use the redundant bytes to restore the complete difference. Finally, the reference value is read, and the reverse operation of differential coding is performed based on the reference value and the restored difference to obtain the restored time information, thereby completing the rapid decompression of the time information.

[0074] 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 relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0075] 5 , which shows a flowchart of the steps of a time information compression method provided by an embodiment of the present application, including:

[0076] 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.

[0077] In the embodiment of the present application, time information is 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.

[0078] 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 can 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.

[0079] Step 102: Obtain a difference between the first time information and the second time information.

[0080] In an embodiment of the present application, the first time information is used to calculate a difference (differential coding) with other second time information during data compression. Difference calculation converts the time information to be encoded into a difference from a certain base 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, achieving the purpose of reducing storage space. By selecting a fixed first time information, the embodiment of the present application can enable the differential coding process to use the fixed first time information to calculate the difference, reducing computational overhead.

[0081] For example, referring to Table 1 below, 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 subjected to difference calculations with the first time information to obtain corresponding difference values: 10s, 20s, and 30s. The difference value represents the difference in the remaining difference (in seconds) after removing the common parts (year, month, day, and hour and minute) of the two time information. The amount of data of the difference value is greatly reduced compared to the complete original time value:

[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 an embodiment of the present application, after obtaining the difference between the first time information and the second time information, the quantized gap of the difference 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 00 00 10 00, the compression operation is to remove the redundant bytes of the prefix and suffix parts 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).

[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 value 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-nodes remaining after the redundant bytes are removed from the difference have a data volume significantly reduced compared to the complete difference. Further, based on the data header generated by the redundant bytes, the data header and the valid bytes are spliced ​​to obtain a splicing result corresponding to the second time information. That is, the splicing result can be stored as a compressed result of the second time information. Compared with the original second time information, the splicing result retains a data header and valid data bits with an 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 benchmark 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-section, 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 very small, the storage efficiency of time information is improved, and the storage cost is reduced. In addition, since any time information can be used to calculate the difference between each other, the compression scheme of calculating the difference between time information and removing redundant sub-sections does not make specific restrictions on the applicable time information, and the applicable scenarios of the compression scheme are more extensive and more universal.

[0091] 6 , which shows a flowchart of specific steps 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 be specifically referred to the above step 101 and 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: Determine the target time information that is earlier than the 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 part can be determined from multiple time information, and then the target time information that is earlier than other target time information can be selected from the group as the first time information.

[0098] First, time information can 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. 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. Subsequently, the first time information 2022.02.01.08:01:10, which is earlier than other time information, is selected from these four time information.

[0099] 2022.02.01.08:01:10

[0100] 2022.02.01.08:01:20

[0101] 2022.02.01.08:01:30

[0102] 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. Subsequently, the first time information 2022.02.01.09:01:10, which is earlier than other time information, is selected from these four time information.

[0104] 2022.02.01.09:01:10

[0105] 2022.02.01.10:21:20

[0106] 2022.02.01.11:41:30

[0107] 2022.02.01.12:51:40

[0108] Based on the selection method of the first time information of this implementation method, 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, 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 the 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 that is 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: 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 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 value of the integer values ​​of 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 benchmark value, so that the difference between the time information and the benchmark value calculated during the differential encoding process can eliminate the same data part to a greater extent, 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 the middle 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 uniformly process time information of different forms. The 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 uniformly processed in 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 January 1, 1970 00:00:00 UTC to the current moment, that is, the timestamp can reflect the moment in seconds. For example, the time at 10:10:10 on October 22, 2008 can be: 1224641410. The time at 10:10:10 on October 22, 2009 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 the time information-integer conversion formula.

[0123] For example, for time information in the form of a date: yyyy year MM month dd day, 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 this 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 a hexadecimal format. The implementation process of this sub-step is now described using 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 the first time information is converted is 1850804423710736384, and the hexadecimal form of the first integer value is: 0x19 af 60 d1 40 00 00 00; the second integer value after the second time information is converted is 1850804492430213120; the hexadecimal form of the second integer value is: 0x19 af 60 e1 40 00 00 00, then the difference between the first integer value and the second integer value in hexadecimal format = (0x19 af 60 e1 40 00 00 00) - (0x19 af 60 d1 40 00 00 00)=0x00 00 00 10 00 00 00 00. It should be noted that, in this example, the 0s in the three consecutive lower 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] During the execution of the above steps, the time information to be compressed is converted to a difference from a base value through difference calculation, resulting in the data portion of the time information to be compressed that is identical to the base value being converted to zero. This step can then remove the bytes in the prefix and suffix of the difference that were converted to zero by the difference calculation as redundant bytes, and use the remaining bytes after the removal as valid bytes. Consecutive zero bytes in the prefix and suffix of the difference can be removed as redundant bytes. For example, for a hexadecimal difference value: 0x00 00 00 10 00, the redundant bytes in the prefix are three bytes of zeros starting with the most significant bit (00 00 00 between x and 1); the redundant bytes in the suffix are one byte of zeros starting with the least significant bit (00 after 10). After removing the redundant bytes, the remaining valid bytes are 0x00. Compared to the original complete difference value, the difference value can be subsequently stored by storing the valid bytes. The valid bytes have a smaller data size and offer storage performance advantages.

[0137] Step 206: Generate the data header according to the sign bit of the difference value corresponding to the second time information, the number of consecutive 0 bytes in the prefix part of the difference value, and the number of consecutive 0 bytes in the suffix part of the difference value.

[0138] In an embodiment of the present application, the 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 negative, the sign bit stored in the data header is negative; when the difference is positive, 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, referring to FIG7 , the data header can be 1 byte (containing 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 0 bytes in the prefix part (representing a maximum of 7 bytes) - 3-bit data bits storing the number of consecutive 0 bytes in the suffix part (representing a maximum of 7 bytes), with valid data bits spliced ​​after the data header. A sign bit value of 1 represents 0 and a positive integer; a sign bit value of 0 represents a negative number. It should be noted that the embodiments of the present application do not specifically limit the content stored in the reserved bit.

[0140] For example, in the process of converting the hexadecimal difference value 0x00 00 00 10 00, the redundant bytes in the prefix are deleted to the three bytes of zeros starting from the most significant bit (00 00 00 between x and 1), and the redundant bytes in the suffix are deleted to the one byte of zeros starting from the least significant bit (00 after 10). To obtain the valid byte 0x10, the first bit in the data header stores a one-bit sign bit (10 indicates positive, 0 indicates negative, and the sign bit is 1 in this example). The next one-bit reserved bit is 0. The next three bits store the number of consecutive zero bytes in the prefix, which is 011 (the binary representation of the number 3 using three bits), and the next three bits store the number of consecutive zero bytes in the suffix, which is 001 (the binary representation of the number 1 using three bits). The final data header is 10 011 001 (0x19). The data header and the valid bytes are concatenated, and the compressed time information is 0x19 10.

[0141] It should be noted that if the difference between 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 bytes 0 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 bytes 0 can be stored as 7 (111) in the prefix part of the data header, and the data bits of the number of consecutive bytes 0 can be stored as 1 (001) in the suffix part; or, the data bits of the number of consecutive bytes 0 can be stored in the header. 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); alternatively, 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); alternatively, 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 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 a database on the server side.

[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 converting 1 to an integer is 0x0001.

[0150] The compressed integer converted to 2147483647 is: 0x1111 1111 1111 1111 1111 1111 1111 1111;

[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 benchmark 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, this application compresses 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 restrictions on the applicable time information. The compression scheme has a wider range of applicable scenarios and is more universal.

[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 based on the first time information and the splicing result corresponding to the second time information.

[0163] This step may be specifically referred to the above step 104 and will not be described in detail here.

[0164] In summary, referring to Figure 8, it shows the overall flow chart of the compression scheme of an 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 (second time information); X3, converting the time (first time information and 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 between the five time information of the DATETIME type before and after compression:

[0166] Table 2

[0167] 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.

[0168] Referring to Figure 9, it 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 byte removed is: 0x19 af 60 d1 40.

[0169] 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.

[0170] Then, S2 is executed to remove the low-order byte of the second time information. The second time information without the low-order byte is: 0x19 af 60 e1 40. Then, S3 is executed to calculate the difference. The difference between the first time information without the low-order byte: 0x19 af 60 d1 40 and the second time information without the low-order byte: 0x19 af 60 e1 40 is calculated to obtain: 0x00 00 00 10 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 in the prefix part are 3 bytes of 0 starting from the highest bit (00 00 00 between x and 1); the redundant bytes in 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 subsequently by storing the valid bytes. The valid bytes have a storage performance advantage due to their smaller data volume.

[0171] After removing the redundant bytes from the difference to obtain the valid bytes, S5 is executed to generate a data header based on the redundant bytes. The first bit in the data header stores a 1-bit sign bit (10 indicates positive, 00 indicates negative; in this example, the sign bit is 10). The following 3 bits store the number of consecutive 0 bytes in the prefix portion, which is 011 (representing the number 3 under 3 bits), and the 3 bits store the number of consecutive 0 bytes in the suffix portion, which is 001 (representing the number 1 under 3 bits). The final data header is 0x19 (10 011 001). Finally, S6 is executed to concatenate the data header and the valid bytes, obtaining a concatenated result of 0x19 10.

[0172] In summary, the present application can select the first time information as a benchmark 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-section, 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 very small, the storage efficiency of time information is improved, and the storage cost is reduced. In addition, since any time information can be used to calculate the difference between each other, the compression scheme of calculating the difference between time information and removing redundant sub-sections does not make specific restrictions on the applicable time information, and the applicable scenarios of the compression scheme are more extensive and more universal.

[0173] 10 , which shows a flowchart of the steps of a method for decompressing time information provided in an embodiment of the present application, including:

[0174] Step 301: Obtain a compression result of the second time information.

[0175] In which, 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.

[0176] Step 302: parse the data header in the splicing result to obtain the redundant bytes.

[0177] 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.

[0178] Step 304: Obtain restored second time information based on the difference and the first time information, thereby completing decompression of the time information.

[0179] 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.

[0180] 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 calculated, and the redundant bytes include: 3 consecutive bytes of 0 starting from the highest bit in the prefix part, and 1 byte of 0 starting from the lowest bit in the suffix part, then the redundant bytes are first merged 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 perform reverse calculation of the difference (if the difference calculation during compression is first time information - second time information = difference, then the reverse calculation here is first time information - difference = second time information; if the difference calculation during compression is second time information - first time information = difference, then the reverse calculation here is first time information + difference = second time information) to obtain the restored second time information.

[0181] In summary, referring to Figure 11, it shows the overall flow chart of the decompression scheme of an 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 (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 (second time information).

[0182] Optionally, step 302 may specifically include:

[0183] 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.

[0184] Optionally, based on sub-step 3021, step 303 may specifically include:

[0185] Sub-step 3031: Combine 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.

[0186] Optionally, the data header further includes: a sign bit of the difference; and step 304 may specifically include:

[0187] Sub-step 3041: performing 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.

[0188] In an 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. First, the data header of the splicing result is parsed to obtain the consecutive bytes 0 in the prefix part and the consecutive bytes 0 in the suffix part for the difference removed during compression. Then, the consecutive bytes 0 in the prefix part and the consecutive bytes 0 in the suffix part are merged with the valid bytes in the splicing result to obtain the restored difference. Finally, the difference and the first time information are added according to the sign bit of the difference obtained by parsing in the data header to obtain the restored second time information.

[0189] The decompression process is described through an example:

[0190] Assume that the concatenation result of the second time information is: 0x19 10, and the read first time information is 0x19af 60 d1 40. The data header 0x19 represents (10 011 001), 10 indicates that the sign bit of the difference is positive, 011 indicates that the number of consecutive 0 bytes in the prefix part is 3; and 001 indicates that the number of consecutive 0 bytes in the suffix part is 1. After splicing the valid bytes with the consecutive 0 bytes in the prefix and suffix parts, the restored difference 0x00 00 00 10 00 is obtained. This difference is added to the first time information to obtain the restored hexadecimal second time information = (0x00 00 00 10 00) + (0x19af 60 d1 40) = 0x19af 60 e1 40. The hexadecimal second time information is converted into an integer and then converted into a time value to obtain 2023.02.16 14:05:00, thereby completing the decompression.

[0191] In summary, the present application can select the first time information as a benchmark 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-section, 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 very small, the storage efficiency of time information is improved, and the storage cost is reduced. In addition, since any time information can be used to calculate the difference between each other, the compression scheme of calculating the difference between time information and removing redundant sub-sections does not make specific restrictions on the applicable time information, and the applicable scenarios of the compression scheme are more extensive and more universal.

[0192] 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 realizing rapid decompression of the time information and meeting the need for rapid restoration of the time information for use.

[0193] 12 , which shows a block diagram of a time information compression device provided by an embodiment of the present application, including:

[0194] The selection module 401 is configured 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;

[0195] A difference module 402 is configured to obtain a difference between the first time information and the second time information, where the second time information is time information in the plurality of time information except the first time information;

[0196] The processing module 403 is configured to determine the redundant bytes in the difference and generate a data header according to the redundant bytes;

[0197] A splicing module 404 is configured to remove redundant bytes from 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;

[0198] The generating module 405 is configured to generate a compression result according to the first time information and a splicing result corresponding to the second time information.

[0199] Optionally, the difference module 402 includes:

[0200] 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;

[0201] A first difference submodule is configured to obtain a difference between the first integer value and the second integer value.

[0202] Optionally, the difference module 402 includes:

[0203] The second difference submodule is configured to obtain a difference between the first integer value and the second integer value calculated in hexadecimal format.

[0204] Optionally, the conversion submodule includes:

[0205] The conversion unit is configured 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.

[0206] Optionally, the difference is in hexadecimal format; the processing module 403 includes:

[0207] A first determining submodule is configured to determine a prefix portion and a suffix portion of the difference;

[0208] The identification submodule is configured to use consecutive 0 bytes in the prefix part and consecutive 0 bytes in the suffix part of the difference as the redundant bytes.

[0209] Optionally, the processing module 403 includes:

[0210] 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 0 bytes in a prefix portion of the difference value, and a number of consecutive 0 bytes in a suffix portion of the difference value;

[0211] The splicing module 404 includes:

[0212] The splicing submodule is configured 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.

[0213] Optionally, the selection module 401 includes:

[0214] A second determining submodule is configured to determine, from the plurality of time information, a plurality of target time information having the same data portion;

[0215] The third determining submodule is configured to determine the target time information that is earlier than the other target time information among the multiple target time information as the first time information.

[0216] Optionally, the selection module 401 includes:

[0217] The fourth determining submodule is configured to determine the time information that is earlier than the other time information among the multiple time information as the first time information.

[0218] Optionally, the selection module 401 includes:

[0219] an integer submodule configured to convert the time information into an integer value;

[0220] The fifth determination submodule is configured to calculate the average 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.

[0221] In summary, the present application can select the first time information as a benchmark 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-section, 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 very small, the storage efficiency of time information is improved, and the storage cost is reduced. In addition, since any time information can be used to calculate the difference between each other, the compression scheme of calculating the difference between time information and removing redundant sub-sections does not make specific restrictions on the applicable time information, and the applicable scenarios of the compression scheme are more extensive and more universal.

[0222] 13 , which shows a block diagram of a time information decompression device provided by an embodiment of the present application, including:

[0223] An acquisition module 501 is configured to acquire a compression result of second time information, the compression result including: first time information, which is time information serving as a reference among multiple time information before compression; and second time information, which is time information other than the first time information among the multiple time information. The concatenation result is formed by concatenating valid bytes and a data header. The valid bytes are the bytes remaining after removing redundant bytes from the difference between the first and second time information, and the data header is generated based on the redundant bytes.

[0224] The parsing module 502 is configured to parse the data header in the splicing result to obtain the redundant bytes;

[0225] A merging module 503 is 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;

[0226] The restoration module 504 is configured to obtain the restored second time information according to the difference and the first time information, thereby completing the decompression of the time information.

[0227] Optionally, the parsing module 502 includes:

[0228] a parsing submodule configured to parse the data header to obtain consecutive 0 bytes in the prefix portion and consecutive 0 bytes in the suffix portion removed for the difference during compression;

[0229] The merging module 503 includes:

[0230] The merging submodule is configured 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.

[0231] Optionally, the data header further includes: a sign bit of the difference;

[0232] The restoration module 504 includes:

[0233] The calculation submodule is configured to perform a sum calculation on the difference and the first time information according to a sign bit of the difference to obtain the restored second time information.

[0234] In summary, the present application can select the first time information as a benchmark 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-section, 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 very small, the storage efficiency of time information is improved, and the storage cost is reduced. In addition, since any time information can be used to calculate the difference between each other, the compression scheme of calculating the difference between time information and removing redundant sub-sections does not make specific restrictions on the applicable time information, and the applicable scenarios of the compression scheme are more extensive and more universal.

[0235] 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 realizing rapid decompression of the time information and meeting the need for rapid restoration of the time information for use.

[0236] An embodiment of the present application further 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.

[0237] The present application provides one or more machine-readable media storing instructions that, when executed by one or more processors, cause an electronic device to perform one or more of the methods described in the above embodiments. In the present application, the electronic device includes various types of devices such as terminal devices and server (cluster).

[0238] The embodiments of the present disclosure may be implemented as a device configured as desired using any appropriate hardware, firmware, software, or any combination thereof, and the device may include electronic devices such as terminal devices, server terminals (clusters), etc. FIG14 schematically illustrates an exemplary device 1000 that can be used to implement various embodiments described in the embodiments of the present application.

[0239] For one embodiment, Figure 14 shows an exemplary apparatus 1000 having one or more processors 1002, a control module (chip set) 1004 coupled to at least one of the processor(s) 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.

[0240] 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 dedicated processors (e.g., graphics processors, application processors, baseband processors, etc.). In some embodiments, the apparatus 1000 can serve as a terminal device, a server (cluster), or other device described in the embodiments of the present application.

[0241] In some embodiments, the apparatus 1000 may include one or more computer-readable media (e.g., memory 1006 or NVM / storage 1008) having instructions 1014 and one or more processors 1002 configured in conjunction with the one or more computer-readable media to execute the instructions 1014 to implement a module to perform the actions described in the present disclosure.

[0242] 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 .

[0243] 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.

[0244] The memory 1006 may be configured, for example, to load and store data and / or instructions 1014 for the apparatus 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 double data rate type four synchronous dynamic random access memory.

[0245] For one embodiment, the control module 1004 may include one or more input / output controllers to provide an interface to the NVM / storage device 1008 and the input / output device(s) 1010 .

[0246] For example, the NVM / storage device 1008 may be configured to store data and / or instructions 1014. The 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).

[0247] NVM / storage device 1008 may include storage resources that are physically part of a device on which apparatus 1000 is installed, or that may be accessible to the device without being part of the device. For example, NVM / storage device 1008 may be accessible over a network via input / output device(s) 1010.

[0248] (One or more) input / output devices 1010 may provide an interface for apparatus 1000 to communicate with any other appropriate device. Input / output devices 1010 may include communication components, audio components, sensor components, etc. Network interface 1012 may provide an interface for apparatus 1000 to communicate via one or more networks. 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.

[0249] 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).

[0250] In various embodiments, the apparatus 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 apparatus 1000 may have more or fewer components and / or a different architecture. For example, in some embodiments, the apparatus 1000 includes one or more cameras, a keyboard, a liquid crystal display (LCD) screen (including a touch screen display), a non-volatile memory port, multiple antennas, a graphics chip, an application-specific integrated circuit (ASIC), and a speaker.

[0251] 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 the 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.

[0252] 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.

[0253] 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.

[0254] The present application embodiment is described with reference to the flow chart 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 flow chart and / or block diagram, and the combination of the process and / or box in the flow chart 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 flow chart and / or one box or multiple boxes in the block diagram.

[0255] 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.

[0256] 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.

[0257] Although preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic inventive concepts. 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 invention.

[0258] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.

[0259] The above is a detailed introduction to the 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 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, based on the ideas of the present application, there will be changes in the specific implementation methods 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, comprising: 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, wherein: 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, wherein: 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, wherein: 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, wherein: 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, wherein: 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, wherein: 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, comprising: 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, wherein: 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, wherein: 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, comprising: A selection module, configured 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, configured 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, configured to determine the redundant bytes in the difference and generate 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; The generating module is configured 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, comprising: 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 the time information used as a benchmark among the multiple time information before compression; the second time information being the 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 the remaining bytes after removing redundant bytes from the 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, configured to parse 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 configured 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 comprising: processor; and A memory storing executable codes, which, when executed, enable the processor to perform the method according to any one of claims 1 to 10.

14. One or more machine-readable media storing executable codes, which, when executed, cause a processor to perform the method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Scientific calculation-orientated floating-point data parallel lossless compression method

    CN105022631A

  • Data compression method and device, computer readable medium and electronic equipment

    CN110198171A

  • Time series data storage method and device, computer equipment and storage medium

    CN110633277A

  • Real-time electrocardio data lossless compression method

    CN111035381A

  • Data compression method and device and data decompression method and device

    CN116208168A