Data compression method, data decompression method and data compression device
By obtaining the update timing of the business data packet and the data conversion table, utilizing the gradual change of the data, and performing compression encoding based on the data conversion table or the updated data conversion table within the current update cycle, the problems of slow data compression and high resource consumption in the existing technology are solved, and fast and efficient data compression is achieved.
Patent Information
- Application Number
- CN202211509276.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-29
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2042-11-29
AI Technical Summary
Existing data compression algorithms cannot effectively reduce the amount of data, have slow compression speeds and high processor performance requirements, making it difficult to save data transmission and storage resources.
By obtaining the update timing of the business data packet and the data conversion table, taking advantage of the gradual change of adjacent data, the data packet is compressed based on the data conversion table in the current update cycle, or compression encoding is performed after the data conversion table is updated in the update cycle to achieve fast compression.
It achieves fast data compression with low compression rate, effectively saving data transmission and storage resources.
Smart Images

Figure CN115865274B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data compression method, a data decompression method, and a data compression device. Background Art
[0002] With the development of information technology, data such as monitoring data of railway electronic equipment is becoming increasingly abundant, posing huge challenges to data storage and transmission.
[0003] Currently, data compression is commonly used to facilitate the storage and transmission of large amounts of rich data, saving data transmission and storage resources. However, existing data compression algorithms have shortcomings such as ineffective data reduction, slow compression speed, or high processor performance requirements, making it difficult to effectively save data transmission and storage resources.
[0004] Therefore, how to compress data using a data compression method with a low data compression rate and a high compression speed has become a problem that needs to be solved urgently. Summary of the Invention
[0005] Based on the above problems, the present application provides a data compression method, a data decompression method and a data compression device, which can compress business data packets quickly with a low compression rate, and can effectively save data transmission resources and storage resources.
[0006] The embodiments of this application disclose the following technical solutions:
[0007] In a first aspect, the present application provides a data compression method, the method comprising:
[0008] Obtaining the update timing of the business data package and data conversion table;
[0009] If the update timing of the data conversion table when acquiring the service data packet is less than a preset update period, compressing the service data packet based on the data conversion table within the current update period to obtain a compressed data packet;
[0010] If the update timing of the data conversion table when the service data packet is obtained is greater than or equal to a preset update period, updating the data conversion table based on the service data packet; compressing the service data packet based on a preset compression coding algorithm to obtain a compressed data packet;
[0011] The compressed data packet is output.
[0012] Optionally, before obtaining the service data packet and updating the data conversion table, the method further includes:
[0013] Get the original data;
[0014] Based on a preset data packet length, the original data is split into multiple service data packets.
[0015] Optionally, the compressed data packet includes at least one of a converted data packet, a redundant data packet and an encoded data packet.
[0016] Optionally, compressing the service data packet based on a preset compression coding algorithm to obtain a compressed data packet includes:
[0017] Encoding the service data in the service data packet based on a preset compression coding algorithm to obtain coded data;
[0018] A converted data packet is obtained based on the coded data, the service data and a length comparison result of the two.
[0019] Optionally, after obtaining the service data packet and updating the data conversion table, the method further includes:
[0020] Obtaining a statistical compression ratio of a current statistical period, where the statistical period is less than the update period;
[0021] If the statistical compression rate is greater than a preset compression rate threshold, the data conversion table is updated based on the service data packet; the service data packet is compressed based on a preset compression coding algorithm to obtain a converted data packet.
[0022] Optionally, compressing the service data packet based on the data conversion table in the current update cycle includes:
[0023] Based on a comparison result between the data conversion table in the current update cycle and the data of the service data packet, run-length encoding is performed on the service data packet to obtain an encoded data packet.
[0024] Optionally, before compressing the service data packet based on the data conversion table in the current update cycle, the method further includes:
[0025] Comparing the service data in the service data packet with the previous data in the previous data packet; the previous data packet is a data packet received before receiving the service data packet;
[0026] If the service data is identical to the previous data, the service data packet is represented based on a preset redundancy identifier to obtain a redundant data packet.
[0027] Optionally, the method further comprises, before outputting the compressed data packet:
[0028] Based on the type of the compressed data packet, a data packet type identifier is added to the compressed data packet; the data packet type identifier includes at least one of a converted data packet identifier, an encoded data packet identifier, and a redundant data packet identifier.
[0029] In a second aspect, the present application provides a data decompression method, the method comprising:
[0030] Obtaining a compressed data packet; the compressed data packet is the compressed data packet outputted in the first aspect above;
[0031] Determining a decompression rule corresponding to the compressed data packet based on the data packet type identifier carried by the compressed data packet;
[0032] Decompress the compressed data packet based on the decompression rule.
[0033] In a third aspect, the present application provides a data compression device, the device comprising: an acquisition module, a first compression module, a second compression module, and an output module;
[0034] The acquisition module is used to acquire the update timing of the service data packet and the data conversion table;
[0035] The first compression module is configured to compress the service data packet based on the data conversion table within the current update period to obtain a compressed data packet when the update timing of the data conversion table is less than a preset update period when the service data packet is acquired;
[0036] The second compression module is configured to update the data conversion table based on the service data packet when the update timing of the data conversion table is greater than or equal to the preset update period when the service data packet is obtained; and compress the service data packet based on a preset compression coding algorithm to obtain a compressed data packet;
[0037] The output module is used to output the compressed data packet.
[0038] Compared with the existing technology, this application has the following beneficial effects:
[0039] The present application provides a data compression method, wherein first, a business data packet and an update timing of a data conversion table are obtained; then, if the update timing of the data conversion table is less than a preset update period when the business data packet is obtained, the business data packet is compressed based on the data conversion table in the current update period to obtain a compressed data packet; if the update timing of the data conversion table is greater than or equal to the preset update period when the business data packet is obtained, the data conversion table is updated based on the business data packet; the business data packet is compressed based on a preset compression coding algorithm to obtain a compressed data packet; and finally, the compressed data packet is output. Thus, by utilizing the gradual change of data in adjacent business data packets and based on the update period of the data conversion table, it is determined whether to use the business data packet to update the data conversion table. If not, the business data packet can be compressed by comparing the business data in the business data packet with the data in the data conversion table and using a code to replace the relatively consistent part. The method has a fast compression speed and a small ratio of the size of the compressed data packet to the size of the business data packet. That is, the data compression rate of the business data packet is low when the method is used to compress the business data packet, which can effectively save data transmission resources and storage resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0041] Figure 1 A flow chart of a data compression method provided in an embodiment of the present application;
[0042] Figure 2 A flow chart of another data compression method provided in an embodiment of the present application;
[0043] Figure 3 A flow chart of a data decompression method provided in an embodiment of the present application;
[0044] Figure 4 A schematic diagram of a data compression device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] The embodiments of the present application provide a data compression method, a data decompression method, and a data compression device, which can effectively save data transmission resources and storage resources.
[0046] The terms used in the examples of this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms "a," "the," and "the" used in the examples of this application and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0047] Of course, the explanation of the above terms is only made for the convenience of understanding and does not have any limiting meaning.
[0048] As previously mentioned, data compression is commonly used to facilitate the storage and transmission of large amounts of rich data, saving data transmission and storage resources. However, existing data compression algorithms suffer from shortcomings such as ineffective data reduction, slow compression speeds, and high processor performance requirements, making it difficult to effectively save data transmission and storage resources.
[0049] In view of this, the present application provides a data compression method. First, a service data packet and a data conversion table update timing are obtained. Then, if the data conversion table update timing is less than a preset update period when the service data packet is obtained, the service data packet is compressed based on the data conversion table within the current update period to obtain a compressed data packet. If the data conversion table update timing is greater than or equal to the preset update period when the service data packet is obtained, the data conversion table is updated based on the service data packet. The service data packet is compressed based on a preset compression coding algorithm to obtain a compressed data packet. Finally, the compressed data packet is output. This method allows the service data packet to be compressed quickly with a low compression ratio, effectively saving data transmission and storage resources.
[0050] In order to help those skilled in the art better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0051] See also Figure 1 , which is a flow chart of a data compression method provided in an embodiment of the present application, the method comprising:
[0052] S101: Acquire the update timing of the service data packet and the data conversion table.
[0053] For example, raw data, such as monitoring data provided by a railway monitoring system, can be obtained and split into multiple service data packets based on a preset data packet length. For example, the preset data packet length may be 128 bytes. If the raw data is 326 bytes long, the raw data can be split into three service data packets, each with a length of 128 bytes, 128 bytes, and 70 bytes, respectively.
[0054] In particular, if the length of the original data is less than or equal to 128 bytes, the original data will not be split. Since the embodiment of the present application can flexibly set the data packet length, the data packet length can be set to a smaller value (for example, 128 bytes), and the original data less than this length does not need to be compressed by default. As an example, in the embodiment of the present application, if the length of the original data is less than or equal to 128 bytes, the original data will be processed through REL encoding. If the length of the original data after processing increases, the original data before processing is output; if the length of the original data after processing decreases, the original data after processing is output.
[0055] As an example, the update period of the data conversion table can be preset to T, and a timer for updating the data conversion table can be set. The data conversion table can be updated at the beginning of each update period. For example, when the update timer of the data conversion table is greater than or equal to the preset update period, it can be determined that a new update period should be entered. At this time, the data conversion table can be updated and the update timer of the data conversion table can be reset.
[0056] S102: If the update timing of the data conversion table when acquiring the service data packet is less than a preset update period, compress the service data packet based on the data conversion table in the current update period to obtain a compressed data packet.
[0057] Exemplarily, the compressed data packet may include at least one of a converted data packet, an encoded data packet, and a redundant data packet.
[0058] As an example, if the update timing of the data conversion table when obtaining a business data packet is less than the preset update period, the data conversion table within the current update period can be used as a benchmark, and based on the data comparison results between the data conversion table within the current update period and the business data packet, the business data packet can be run-length encoded, thereby achieving compression of the business data packet and obtaining a compressed data packet, which is an encoded data packet.
[0059] Specifically, the business data in the business data packet can be scanned and compared byte by byte with the data in the data conversion table. For continuous and relatively consistent data, the relatively consistent number of bytes is recorded, and the coding identifier and the relatively consistent number of bytes are used to replace the relatively consistent data; for relatively inconsistent bytes, the relatively inconsistent number of bytes and business data are used to represent them, thereby obtaining a compressed data packet, which is an encoded data packet.
[0060] Preferably, in order to avoid the length of the encoded data in the encoded data packet being greater than the length of the business data in the business data packet, it can be pre-set that only when two or more consecutive bytes are consistent can it be judged as continuous and relatively consistent data, otherwise it will be treated as relatively inconsistent.
[0061] As an example, if the data conversion table is "0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F", and the business data is "0x01 0x02 0x03 0x00 0x00 0x00 0x07 0x00 0x09 0x0A 0x00 0x0C 0x0D 0x0E 0x0F", by comparing the bytes in the data conversion table and the business data, it can be found that the "0x01 0x02 0x03" in the business data is consistent with the data conversion table, and the number of consecutive bytes is 3. Therefore, "0x83" can be used to represent these three bytes. Among them, "0x83" is an 8-bit hexadecimal number, and its binary code is "10000011". The highest bit "1" of the binary code is the encoding identifier, and the lower 7 bits of the binary code "0000011" are converted to decimal as 3, indicating that 3 bytes are compressed. Similarly, in the business data "0x00 0x00 0x00 0x07 0x00", only the byte 0x07 is consistent with the number conversion table, and the consecutive number is less than 2, so it is considered inconsistent. The data number "0x05" + business data "0x00 0x000x00 0x07 0x00" is expressed as "0x05 0x00 0x00 0x00 0x07 0x00"; "0x09 0x0A" in the business data is consistent with the data conversion table, and the consecutive number is 2, which can be expressed as "0x82"; the next "0x00" is expressed as "0x01 0x00", and "0x0C 0x0D 0x0E 0x0F" is expressed as "0x84"; the business data is encoded as "0x83 0x05 0x00 0x00 0x000x07 0x00 0x82 0x01 0x00 0x84". In this way, the service data packet can be compressed to obtain a compressed data packet, which is an encoded data packet.
[0062] S103: If the update timing of the data conversion table when obtaining the service data packet is greater than or equal to the preset update period, update the data conversion table based on the service data packet; compress the service data packet based on a preset compression coding algorithm to obtain a compressed data packet.
[0063] Exemplarily, if the update timing of the data conversion table is greater than or equal to the preset update cycle when the business data packet is obtained, it can be determined that a new update cycle should be entered, and the data conversion table can be updated based on the business data packet. Specifically, the data in the business data packet can be used as the data of the data conversion table; and for the compression of the business data packet, the business data packet can be compressed based on a preset compression coding algorithm to obtain a compressed data packet, and the obtained compressed data packet is the conversion data packet.
[0064] Optionally, the business data in the business data packet can be encoded based on a preset compression coding algorithm to obtain encoded data; and based on the encoded data, the business data, and a length comparison result of the two, a converted data packet can be obtained. Specifically, the preset compression coding algorithm can be a Run-Length Encoding (REL) algorithm, which can scan the business data packet to obtain the business data, and perform REL encoding on the business data to obtain the encoded data. The REL encoding algorithm is a compression algorithm that replaces repeated bytes with a coding combination of repeated bytes and the number of repetitions. For example, if the business data is a string of 17 half-width characters "AAAAAABBCDDEEEEEF", REL encoding will obtain "A6B2C1D2E5F1", a string of 12 half-width characters, and "A6B2C1D2E5F1" is the encoded data. After obtaining the encoded data, compare the length of the encoded data and the business data. If the length of the encoded data is greater than the length of the business data, use the business data as the data in the conversion data packet; if the length of the encoded data is less than the length of the business data, use the encoded data as the data in the data conversion packet, that is, use the smaller one of the business data and the encoded data as the data in the data conversion packet.
[0065] Optionally, after the data conversion table is updated, the update timing of the data conversion table may be reset, thereby timing each update cycle separately.
[0066] S104: Output the compressed data packet.
[0067] Optionally, before outputting the compressed data packet, a data packet type identifier may be added to the compressed data packet based on the type of the compressed data packet. The data packet type identifier includes at least one of a conversion data packet identifier, an encoding data packet identifier, and a redundant data packet identifier. Specifically, the data packet type identifier may be an identifier defined based on actual needs to distinguish different types of compressed data packets.
[0068] Additionally, you can add a checksum to the compressed data packet before outputting it. The checksum is the cumulative number of bits transmitted. When the transmission is complete, the receiver can use this value to determine whether all the data has been received. If the values match, the transmission is complete.
[0069] For example, for a compressed data packet such as a conversion data packet, a conversion data packet identifier and a checksum may be added thereto first, and then the combination of the conversion data packet identifier, the conversion data packet and the checksum may be output when the compressed data packet needs to be output.
[0070] Therefore, the embodiment of the present application utilizes the gradual change of data in adjacent business data packets and, based on the update cycle of the data conversion table, determines whether to use the business data packet to update the data conversion table. If not, the business data packet can be compressed by comparing the business data in the business data packet with the data in the data conversion table and using code to replace the more consistent parts. This method has a fast compression speed and a small ratio between the size of the compressed data packet and the size of the business data packet. That is, the business data packet is compressed by this method, and its data compression rate is low, which can more effectively save data transmission resources and storage resources.
[0071] For original data that changes gradually over time, such as monitoring data, the data volume is large and will be split into multiple business data packets. As the original data changes gradually over time, the amount of data duplication in adjacent business data packets is large. Through the data compression method provided in the embodiment of the present application, the business data packet to be processed currently is compressed based on the data conversion table closest to the business data packet to be processed currently. The ratio of the size of the obtained compressed data packet to the size of the business data packet will be very small, that is, the data compression rate is low, which can effectively save data transmission resources and storage resources; and the data that is relatively far away from the time when the data conversion table is generated has a large change relative to the data conversion table. If the same data conversion table is still used, it will be difficult to obtain a smaller data compression rate. Therefore, a suitable update cycle can be set in advance to periodically update the data conversion table based on the business data packet, so that the entire original data can be compressed quickly and effectively.
[0072] See also Figure 2 , which is another data compression method provided by an embodiment of the present application, the method comprising:
[0073] S201: Obtaining original data.
[0074] For example, the raw data may be data that changes gradually over time, such as real-time monitoring data.
[0075] S202: Split the original data into multiple service data packets based on a preset data packet length.
[0076] For example, the raw data can be split based on a preset data packet length after all raw data is acquired, or the raw data can be split based on a preset data packet length during the process of acquiring the raw data. For example, if the raw data totals 326 bytes and the preset data packet length is 128 bytes, the raw data can be split after all 326 bytes of raw data are acquired, or each 128 bytes of raw data can be split into a service data packet.
[0077] Optionally, the order of acquiring the multiple service data packets is the same as the order in which the service data in different service data packets are arranged in the original data.
[0078] S203: Obtain the statistical compression ratio of the current statistical period.
[0079] As an example, the statistical compression ratio of all compressed data packets in the current statistical period can be obtained in real time, and the step described in S204 is performed every statistical period. The statistical compression ratio can be the ratio of the sum of the compressed data packet sizes of all compressed data packets in the current statistical period to the sum of the service data packet sizes.
[0080] Preferably, the statistical period for the data compression rate should be shorter than the update period of the data conversion table. This allows for timely detection of data compression rates exceeding a preset compression rate threshold within the current update period. In this case, the current update period is terminated prematurely, and the data conversion table is updated to enter the next update period. For example, when the update period is T, the statistical period can be pre-set to T / 2.
[0081] S204: Determine whether the data compression rate is greater than a preset compression rate threshold. If so, execute steps S205 to S206; if not, execute step S207.
[0082] S205: Update the data conversion table based on the business data packet.
[0083] Exemplarily, since the data conversion table is updated, that is, a new update period and statistical period have begun, the update timing of the data conversion table and the timing of the statistical period may be reset.
[0084] S206: Compress the service data packet based on a preset compression coding algorithm to obtain a converted data packet.
[0085] S207: Determine whether the update timing of the data conversion table when acquiring the service data packet is less than the preset update period. If so, execute the step described in S208; if not, execute the steps described in S205 to S206.
[0086] S208: Compare the service data in the service data packet with the previous data in the previous data packet; the previous data packet is a data packet received before the service data packet is received.
[0087] For example, if the service data packet being processed is the i-th service data packet received, the previous data packet is the i-1-th service data packet received. For data transmission security or reliability, two identical packets are often transmitted during data transmission. By comparing the service data in the service data packet with the previous data in the previous data packet, it can be determined whether the service data in the currently received service data packet is identical to the previous data in the previous data packet.
[0088] S209: Determine whether the business data is the same as the previous data. If so, execute the step described in S210; if not, execute the step described in S211.
[0089] S210: Representing a service data packet based on a preset redundant identifier to obtain a redundant data packet.
[0090] In the embodiment of the present application, the redundant data packet is a type of compressed data packet. As an example, the redundant identifier can be a pre-set identifier for indicating the redundant data packet. The embodiment of the present application does not limit the specific form of the redundant identifier.
[0091] When the business data is the same as the previous data, the business data packet is represented by a pre-set redundant identifier. On the one hand, it can avoid repeated processing of the same business data packet, and on the other hand, it can further reduce the size of the compressed data packet, thereby more effectively saving computing resources, data transmission resources and storage resources.
[0092] S211: Based on the comparison result between the data conversion table in the current update cycle and the data of the service data packet, run-length encoding is performed on the service data packet to obtain an encoded data packet.
[0093] S212: Based on the type of the compressed data packet, add a data packet type identifier to the compressed data packet.
[0094] Exemplarily, the packet type identifier includes at least one of a converted compressed packet identifier, an encoded packet identifier, and a redundant packet identifier. The packet type identifier can be a custom identifier for distinguishing different types of compressed packets based on actual needs. The present embodiment does not limit the specific form of the packet type identifier.
[0095] Additionally, you can add a checksum to the compressed data packet before outputting it. The checksum is the cumulative number of bits transmitted. When the transmission is complete, the receiver can use this value to determine whether all the data has been received. If the values match, the transmission is complete.
[0096] For example, for a compressed data packet such as a conversion data packet, a conversion data packet identifier and a checksum may be added thereto first, and then the combination of the conversion data packet identifier, the conversion data packet and the checksum may be output when the compressed data packet needs to be output.
[0097] S213: Calculate the compression ratio.
[0098] For example, the compression ratio is the ratio of the size of the compressed data packet to the size of the service data packet. The smaller the compression ratio, the better the compression effect.
[0099] In particular, the embodiment of the present application does not limit the execution order of steps S211 and S212.
[0100] S214: Output the compressed data packet.
[0101] See also Figure 3 , which is a data decompression method provided by an embodiment of the present application, the method comprising:
[0102] S301: Obtain a compressed data packet.
[0103] Exemplarily, the compressed data packet may be any compressed data packet obtained by the data compression method provided in this application and having a data packet type identifier.
[0104] Optionally, if the compressed data packet carries a checksum, a checksum verification may be performed first when the compressed data packet is input to determine the correctness of the data.
[0105] S302: Determine a decompression rule corresponding to the compressed data packet based on the data packet type identifier carried by the compressed data packet.
[0106] As an example, if the packet type identifier carried by the compressed data packet is a conversion packet identifier, it is determined that the compressed data packet corresponds to the first decompression rule; if the packet type identifier carried by the compressed data packet is an encoding packet identifier, it is determined that the compressed data packet corresponds to the second decompression rule; if the packet type identifier carried by the compressed data packet is a redundant packet identifier, it is determined that the compressed data packet corresponds to the third decompression rule.
[0107] S303: Decompress the compressed data packet based on the decompression rule.
[0108] Exemplarily, the first decompression rule may be to first determine whether the compressed data packet is REL encoded. If so, perform REL decoding and restore it to a data conversion table. If not, directly restore it to a data conversion table, thereby achieving decompression of the compressed data packet; the second decompression rule may be to perform table lookup and decompression on the compressed data packet according to the corresponding data conversion table; the third decompression rule may be to directly use the data of the previous data packet associated with the redundant data packet to restore and decompress it.
[0109] See also Figure 4 , this figure is a schematic diagram of a data compression device provided in an embodiment of the present application, the device includes: an acquisition module 401, a first compression module 402, a second compression module 403 and an output module 404.
[0110] The acquisition module 401 is used to acquire the update timing of the service data packet and the data conversion table.
[0111] The first compression module 402 is configured to compress the service data packet based on the data conversion table in the current update period to obtain a compressed data packet when the update timing of the data conversion table is less than a preset update period when acquiring the service data packet.
[0112] The second compression module 403 is used to update the data conversion table based on the business data packet when the update timing of the data conversion table is greater than or equal to the preset update period when obtaining the business data packet; compress the business data packet based on the preset compression coding algorithm to obtain a compressed data packet.
[0113] The output module 404 is configured to output compressed data packets.
[0114] Therefore, the embodiment of the present application utilizes the gradual change of data in adjacent business data packets and, based on the update cycle of the data conversion table, determines whether to use the business data packet to update the data conversion table. If not, the business data packet can be compressed by comparing the business data in the business data packet with the data in the data conversion table and using code to replace the more consistent parts. This method has a fast compression speed and a small ratio between the size of the compressed data packet and the size of the business data packet. That is, the business data packet is compressed by this method, and its data compression rate is low, which can more effectively save data transmission resources and storage resources.
[0115] Optionally, the device may further include: a decompression module.
[0116] The decompression module is used to obtain a compressed data packet; determine a decompression rule corresponding to the compressed data packet based on a data packet type identifier carried by the compressed data packet; and decompress the compressed data packet based on the decompression rule.
[0117] It should be noted that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and equipment embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments. The device and equipment embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components indicated as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without expending creative work.
[0118] The above is merely one specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A data compression method, characterized in that: The method comprises: Acquire original data; the original data is data that changes gradually over time; Splitting the original data into multiple service data packets based on a preset data packet length; Obtaining the update timing of the business data package and data conversion table; If the update timing of the data conversion table when acquiring the service data packet is less than a preset update period, compressing the service data packet based on the data conversion table within the current update period to obtain a compressed data packet; If the update timing of the data conversion table when acquiring the service data packet is greater than or equal to the preset update period, the service data packet is used as a new data conversion table; and the service data packet is compressed based on a preset compression coding algorithm to obtain a compressed data packet; The compressed data packet is output.
2. The method according to claim 1, characterized in that The compressed data packet includes at least one of a converted data packet, a redundant data packet and an encoded data packet.
3. The method according to claim 2, characterized in that The process of compressing the service data packet based on a preset compression coding algorithm to obtain a compressed data packet includes: Encoding the service data in the service data packet based on a preset compression coding algorithm to obtain coded data; A converted data packet is obtained based on the coded data, the service data and a length comparison result of the two.
4. The method according to claim 2, characterized in that After obtaining the service data packet and updating the data conversion table, the method further includes: Obtaining a statistical compression ratio of a current statistical period, where the statistical period is less than the update period; If the statistical compression rate is greater than a preset compression rate threshold, the data conversion table is updated based on the service data packet; the service data packet is compressed based on a preset compression coding algorithm to obtain a converted data packet.
5. The method according to claim 2, characterized in that The compressing the service data packet based on the data conversion table in the current update cycle includes: Based on a comparison result between the data conversion table in the current update cycle and the data of the service data packet, run-length encoding is performed on the service data packet to obtain an encoded data packet.
6. The method according to claim 2, characterized in that Before compressing the service data packet based on the data conversion table in the current update cycle, the method further includes: Comparing the service data in the service data packet with the previous data in the previous data packet; the previous data packet is a data packet received before receiving the service data packet; If the service data is identical to the previous data, the service data packet is represented based on a preset redundancy identifier to obtain a redundant data packet.
7. The method according to any one of claims 1 to 6, characterized in that Before outputting the compressed data packet, the method further includes: Based on the type of the compressed data packet, a data packet type identifier is added to the compressed data packet; the data packet type identifier includes at least one of a converted data packet identifier, an encoded data packet identifier, and a redundant data packet identifier.
8. A data decompression method, characterized in that: The method comprises: Obtain a compressed data packet; the compressed data packet is the compressed data packet outputted by claim 7; Determining a decompression rule corresponding to the compressed data packet based on the data packet type identifier carried by the compressed data packet; Decompress the compressed data packet based on the decompression rule.
9. A data compression device, characterized in that: The device includes: an acquisition module, a first compression module, a second compression module and an output module; The acquisition module is used to acquire original data; the original data is data that changes gradually over time; split the original data into multiple business data packets based on a preset data packet length; acquire the update timing of the business data packets and the data conversion table; The first compression module is configured to compress the service data packet based on the data conversion table in the current update period to obtain a compressed data packet when the update timing of the data conversion table is less than a preset update period when the service data packet is acquired; The second compression module is configured to, when the update timing of the data conversion table is greater than or equal to a preset update period when the service data packet is acquired, use the service data packet as a new data conversion table; and compress the service data packet based on a preset compression coding algorithm to obtain a compressed data packet; The output module is used to output the compressed data packet.
Citation Information
Patent Citations
Method, device and equipment for data compression
CN114449579A