Data decompression method

By using a circular cache area to temporarily store decoded files in an embedded system, the problem of insufficient memory when decompressing large compressed packets is solved, and the effectiveness of understanding compression is improved.

CN119402455APending Publication Date: 2025-02-07JINGWEI HIRAIN (TIANJIN) RES&DEV CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411558756.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-04
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

When an embedded system decompresses large compressed packages, it is easy to cause insufficient memory, triggering system Out Of Memory errors, resulting in decompression failure.

Method used

By obtaining the compression information of the compressed file, selecting appropriate decoding rules, decoding the compressed file, and temporarily storing the decoded file using the circular buffer area to avoid saving the entire decoded data of the compressed file in memory.

Benefits of technology

It effectively reduces the memory usage of data decompression, avoids the problem of insufficient memory, and improves the effectiveness of data decompression, especially when dealing with large compressed packages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119402455A_ABST
    Figure CN119402455A_ABST
Patent Text Reader

Abstract

The invention provides a data decompression method, and the method comprises the steps: obtaining the compression information of a compressed file, and the compression information comprises a compression algorithm of the compressed file; under the condition that the compression algorithm is a first algorithm, obtaining a coding mode of the compressed file; based on the coding mode, selecting a first decoding rule matched with the coding mode to perform primary decoding on the compressed file to obtain a coding mark; and based on the mark type of the coding mark, performing secondary decoding on the compressed file by using a second decoding rule in a circular cache region to obtain a decoded file, the circular cache region being used for temporarily storing the decoded file, the second decoding rule being matched with the mark type, and the decoded file being corresponding to the original data of the compressed file before compression. According to the embodiment of the invention, the memory occupation of data decompression can be reduced, and the validity of data decompression is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data compression, and in particular to a data decompression method. Background Art

[0002] In today's Internet era, with the rapid development of information technology, people have generated massive amounts of data in their daily lives and work. Behind this surge in data, there is huge pressure on storage and transmission. Especially for devices such as embedded systems with limited memory resources, data processing has become increasingly difficult. In order to effectively meet this challenge, data compression technology has become an important means to alleviate memory pressure. Data compression is mainly divided into lossy compression and lossless compression. For many application scenarios, such as text materials, user data, and applications, lossless compression is often required to ensure data integrity.

[0003] In current technical solutions, embedded systems usually use archive file (ZippedFile, ZIP) decompression algorithms customized by lightweight libraries. These algorithms perform well when processing small compressed packages and occupy relatively little memory resources. However, when decompressing larger compressed packages, problems gradually become prominent because these solutions usually need to save the decoded data of the entire file in memory. In embedded systems with limited memory resources, this may lead to insufficient memory problems, triggering the system's Out Of Memory error, and ultimately causing decompression failure, resulting in poor effectiveness of file decompression. Summary of the invention

[0004] The present application provides a data decompression method, which can reduce the memory usage of data decompression and improve the effectiveness of data decompression.

[0005] In a first aspect, an embodiment of the present application provides a data decompression method, the method comprising:

[0006] Obtaining compression information of a compressed file, the compression information including a compression algorithm of the compressed file;

[0007] When the compression algorithm is the first algorithm, obtaining the encoding mode of the compressed file;

[0008] Based on the encoding mode, a first decoding rule matching the encoding mode is selected to decode the compressed file once to obtain an encoding mark;

[0009] Based on the tag type of the encoding tag, the compressed file is decoded twice in the circular buffer using the second decoding rule to obtain a decoded file. The circular buffer is used to temporarily store the decoded file. The second decoding rule matches the tag type. The decoded file corresponds to the original data of the compressed file before compression.

[0010] In a second aspect, the present application provides a data decompression device, the device comprising:

[0011] A first acquisition module, used to acquire compression information of a compressed file, where the compression information includes a compression algorithm of the compressed file;

[0012] A second acquisition module, used for acquiring an encoding mode of a compressed file when the compression algorithm is the first algorithm;

[0013] A first decoding module, configured to select a first decoding rule matching the encoding mode based on the encoding mode to decode the compressed file once, and obtain an encoding mark;

[0014] The second decoding module is used to perform secondary decoding on the compressed file based on the tag type of the encoding tag using the second decoding rule in the circular buffer area to obtain a decoded file. The circular buffer area is used to temporarily store the decoded file. The second decoding rule matches the tag type, and the decoded file corresponds to the original data of the compressed file before compression.

[0015] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device comprising: a processor and a memory storing computer program instructions;

[0016] When the processor executes the computer program instructions, the data decompression method as described in any one of the embodiments of the first aspect is implemented.

[0017] In a fourth aspect, an embodiment of the present application provides a computer storage medium having computer program instructions stored thereon, and when the computer program instructions are executed by a processor, a data decompression method as in any one of the embodiments in the first aspect is implemented.

[0018] In a fifth aspect, an embodiment of the present application provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes a data decompression method as in any one of the embodiments in the first aspect above.

[0019] In a data decompression method provided in an embodiment of the present application, by obtaining compression information of a compressed file, the compression information includes a compression algorithm of the compressed file; when the compression algorithm is a first algorithm, obtaining the encoding mode of the compressed file; based on the encoding mode, selecting a first decoding rule matching the encoding mode to decode the compressed file once, and obtaining an encoding tag; based on the tag type of the encoding tag, using a second decoding rule in a circular buffer to decode the compressed file twice, and obtaining a decoded file, the circular buffer is used to temporarily store the decoded file, the second decoding rule matches the tag type, and the decoded file corresponds to the original data before compression of the compressed file. In the above method, by using a circular buffer to temporarily receive the decoded original data, the problem of large memory resource occupation caused by saving the decoded data of the entire compressed file during the decompression process is effectively reduced or avoided. Compared with the traditional solution, especially when processing large compressed packets, the present application can greatly reduce memory usage through the circular buffer, effectively alleviate the problem of insufficient memory, and thus improve the effectiveness of data decompression. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0021] Figure 1 It is a flowchart of a data decompression method provided by an embodiment of the present application;

[0022] Figure 2 It is a flowchart of another data decompression method provided by an embodiment of the present application;

[0023] Figure 3 is a schematic diagram of data block formats under different encoding modes provided by an embodiment of the present application;

[0024] Figure 4 It is a structural diagram of a circular buffer area provided by an embodiment of the present application;

[0025] Figure 5 It is a flowchart of another data decompression method provided by an embodiment of the present application;

[0026] Figure 6 It is a flowchart of a method for determining memory of a circular buffer area provided by an embodiment of the present application;

[0027] Figure 7 It is a structural schematic diagram of a data decompression device provided in an embodiment of the present application;

[0028] Figure 8It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0029] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.

[0030] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0031] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0032] Existing ZIP file decompression methods based on embedded systems are usually based on some lightweight library-defined decompression algorithms, and usually save the decoded data of the entire file in the memory during the decompression process. In embedded systems, memory resources are usually limited. The existing technology has little impact on the memory resources occupied during the decompression of a smaller compressed package, but when decompressing a large compressed package, the memory resources used to save the original data of the file will be very large, increasing the system operation burden. It is even possible that insufficient memory resources will trigger the system Out Of Memory, resulting in decompression failure.

[0033] In order to solve the problems existing in the prior art, an embodiment of the present application provides a data decompression method.

[0034] The present application embodiment provides a data decompression method. The following first introduces the data decompression method provided by the present application embodiment. Figure 1 As shown, the method specifically comprises the following steps:

[0035] S100, obtaining compression information of a compressed file, where the compression information includes a compression algorithm of the compressed file.

[0036] Optionally, in a feasible implementation of the present application, when starting to decompress a file, the compressed information of the original data (i.e., compressed information) can be read first. This compressed information is located in the local file header and file description area of ​​the compressed file in the ZIP file (i.e., compressed file).

[0037] Specifically, the compression algorithm used by the compressed file can be obtained from these file headers and file description areas. If the compression algorithm used by the file is a non-compression (Store) algorithm, it means that the file is not compressed, and the ZIP file stores the original data of the file. Therefore, the compressed file can be decompressed directly by writing the original data into the target file. If the compression algorithm used by the file is a lossless data compression (Deflate) algorithm, it means that the file was encoded and compressed during compression, and the ZIP file stores the compressed and encoded data of the file, so the compressed data needs to be decoded later.

[0038] The cyclic redundancy check-32 (CRC-32) check code of the original data of the compressed file can also be obtained from these file headers and file description areas, so that the corresponding CRC check can be performed on the decoded original data later and the results can be compared. The uncompressed size of the compressed file can also be obtained from these file headers and file description areas.

[0039] Optionally, in an embodiment of the present application, the compressed file may be stored in a specific format, including file header information. Information about the compression algorithm may be obtained by reading the file header. Different compression algorithms have specific identifiers or flags in the file header to indicate the compression algorithm used.

[0040] The compressed file may also contain an area describing the overall file information, such as the central directory record of a ZIP file. This area contains information about the compression algorithm, such as the compression method used in the compressed file.

[0041] In some cases, the file extension hints at the compression algorithm used. For example, a ".zip" extension might indicate the ZIP format, a ".gz" extension might indicate the Gzip format, and so on.

[0042] If a compressed file uses a standard compression algorithm, you can also obtain compression information by calling the interface of the corresponding compression library or tool, which may involve reading the file's metadata or file header information.

[0043] S200: When the compression algorithm is the first algorithm, obtain a coding mode of the compressed file.

[0044] Optionally, in a possible implementation of the present application, when the compression algorithm is the first algorithm (ie, the Deflate algorithm), obtaining the encoding mode of the compressed file specifically involves parsing the Deflate data block.

[0045] Specifically, the Header flag of the Deflate data block occupies three bits, of which the first bit indicates whether the Deflate data block is the last Deflate data block of the compressed file. If this bit is 1, it means it is the last data block, and if it is 0, it is not. The last two bits indicate the encoding mode, 00 means not using Huffman encoding, 01 means using static Huffman encoding mode, and 10 means using dynamic Huffman encoding mode.

[0046] If the encoding mode is 00 (Huffman encoding is not used), the original data in the Deflate data block is directly written to the circular buffer.

[0047] If the coding mode is 01 (static Huffman coding mode), a general Huffman code table is generated.

[0048] If the coding mode is 02 (dynamic Huffman coding mode), the Huffman code table of the Deflate data block is generated by using the Huffman code table information in the data block.

[0049] In this way, by parsing the Header flag of the Deflate data block and according to the value of the encoding mode, the encoding mode used by the compressed file can be obtained. This information is very important for subsequent decoding operations.

[0050] S300, based on the encoding mode, select a first decoding rule matching the encoding mode to decode the compressed file once, and obtain an encoding mark.

[0051] Optionally, in a feasible implementation of the present application, if the coding mode is 01, it indicates that the static Huffman coding mode is used, and the above-mentioned general Huffman code table is used for decoding. If the coding mode is 02, it indicates that the dynamic Huffman coding mode is used, and the Huffman code table of the Deflate data block can be generated by the Huffman code table information in the data block, and then the generated Huffman code table is used for decoding.

[0052] The decoding operation specifically involves converting the bit stream in the compressed file into the corresponding coding mark. For example, the Huffman code is decoded bit by bit or byte by byte. The result of the decoding operation is the obtained coding mark, which represents a part of the original data in the Deflate data block or other related information, which will be used in the subsequent secondary decompression process.

[0053] In general, in step S300, corresponding decoding rules need to be adopted according to the encoding mode to correctly decode the data of the compressed file into encoding marks.

[0054] S400, based on the tag type of the encoding tag, the compressed file is decoded twice in the circular buffer using the second decoding rule to obtain a decoded file, the circular buffer is used to temporarily store the decoded file, the second decoding rule matches the tag type, and the decoded file corresponds to the original data of the compressed file before compression.

[0055] Optionally, in a possible implementation of the present application, first, it is possible to determine whether it is a Literal tag, a Length tag, a Distance tag, or an end tag according to the tag type of the encoding tag.

[0056] The Literal tag represents a part of the original data and directly corresponds to a byte in the original data. The Literal tag occupies a byte. In the decoding operation, the content of the Literal tag is directly written into the decompressed data stream (that is, directly written into the circular buffer) without further processing.

[0057] The Length tag is used to indicate the length of the matching string (i.e., the string to be copied), that is, the number of characters to be copied during decompression. In the decoding operation, the value of the Length tag determines the number of characters to be copied (i.e., the length of the string to be copied).

[0058] The Distance tag is used to indicate the distance between the starting position of the matching string and the current position. It indicates how many bytes to trace back from the current position to find the matching string. In the decoding operation, according to the distance indicated by the Distance tag, the corresponding number of characters are copied to the current position.

[0059] The combination and order of these three marker types make up the data blocks in the Deflate compression algorithm, and together they are responsible for restoring the original data when decompressed. The Literal marker directly represents a portion of the original data, while the Length and Distance markers are used to duplicate the string that appeared previously. In this way, Deflate is able to represent the original data with high compression efficiency.

[0060] For example, the original data: "Hello, Hello, World!"

[0061] Length tag: 0x0C (12, indicating that the next 12 bytes are the length of the matching string). The Length tag indicates that there are 12 characters to be copied next, that is, "Hello, Hello," .

[0062] Distance tag: 0x06 (6, indicating the distance of 6 bytes backtracking), that is, the Distance tag instructs the decoder to backtrack 6 bytes from the current position, find the starting position of the matching string, and copy the matching string. In this example, "Hello," is found after backtracking 6 bytes.

[0063] If it is an end marker, it means that the decoding of the current data block is completed and the parsing of the next data block needs to start. Subsequently, the circular buffer is updated according to the results of the decoding operation, including writing new original data, updating the position after copying the matching string, etc. Repeat the above steps until the end marker is encountered or the decoding of the entire data block is completed. The decoded data in the circular buffer is assembled into a decoded file. The content of these decoded files should correspond to the original data of the compressed file before compression.

[0064] In general, in step S400, different processing methods are adopted according to the tag type, including directly writing the original data, copying the matching string, etc., to obtain the final decoded file, which can ensure that the decompressed data is consistent with the original data.

[0065] In a data decompression method provided in an embodiment of the present application, by obtaining compression information of a compressed file, the compression information includes a compression algorithm of the compressed file; when the compression algorithm is a first algorithm, obtaining the encoding mode of the compressed file; based on the encoding mode, selecting a first decoding rule matching the encoding mode to decode the compressed file once, and obtaining an encoding tag; based on the tag type of the encoding tag, using a second decoding rule in a circular buffer to decode the compressed file twice, and obtaining a decoded file, the circular buffer is used to temporarily store the decoded file, the second decoding rule matches the tag type, and the decoded file corresponds to the original data before compression of the compressed file. In the above method, by using a circular buffer to temporarily receive the decoded original data, the problem of large memory resource occupation caused by saving the decoded data of the entire compressed file during the decompression process is effectively reduced or avoided. Compared with the traditional solution, especially when processing large compressed packets, the present application can greatly reduce memory usage through the circular buffer, effectively alleviate the problem of insufficient memory, and thus improve the effectiveness of data decompression.

[0066] In one embodiment, the above step 200 may further specifically perform the following steps:

[0067] S210, when the compression algorithm is a first algorithm, determining that the compressed file includes a plurality of first data blocks;

[0068] S220, for any target data block among the multiple first data blocks, obtain a header flag of the target data block, where the header flag includes a coding flag bit;

[0069] S230, when the coding flag is a first preset value, determining that the coding mode of the target data block is an initial coding mode;

[0070] S240, when the coding flag is a second preset value, determining that the coding mode of the target data block is a static coding mode;

[0071] S250: When the coding flag is a third preset value, determine that the coding mode of the target data block is a dynamic coding mode.

[0072] Optionally, in a specific implementation of the present application, after reading the compression information of the compressed file, the data of the compressed file compressed by the Deflate algorithm is Deflate decoded, and the Deflate decoding process adopts the Huffman decoding technology and the Lempel-Ziv 77 (Lz77) decoding algorithm using a circular buffer. The Deflate decoding flow chart of the present application is as follows: Figure 2 shown.

[0073] Specifically, first, the Header flag (i.e., header flag) of each Deflate data block in the compressed file is parsed. The above Header flag occupies three bits. If the first bit is 1, it indicates that the Deflate data block is the last Deflate data block of the file, and if it is 0, it indicates that it is not the last Deflate data block; the last two bits indicate its encoding mode, among which 00 indicates that Huffman encoding is not used (i.e., initial encoding mode), 01 indicates that static Huffman encoding mode is used (i.e., static encoding mode), and 10 indicates that dynamic Huffman encoding mode is used (i.e., dynamic encoding mode).

[0074] The format of Deflate data blocks in various encoding modes is as follows Figure 3As shown, in 00 mode, the Deflate data block includes a Header, original data length information, and original data; in 01 mode, the Deflate data block includes a Header and Deflate encoded data (i.e., first encoded data); in 02 mode, the Deflate data block includes a Header, Huffman code table information (i.e., dynamic decoding table), and Deflate encoded data (i.e., second encoded data).

[0075] In these optional embodiments, the first bit of the Header flag indicates whether it is the last Deflate data block of the file, so that the decompression process can accurately know whether it is necessary to continue parsing the next data block. This accurate end flag determination helps to improve the efficiency of decompression, especially when processing large files, it can avoid unnecessary decoding operations and save processing time and resources.

[0076] The last two bits indicate the encoding mode, including not using Huffman encoding, using static Huffman encoding mode, and using dynamic Huffman encoding mode. This flexibility allows the selection of appropriate encoding methods according to different compressed data types, further improving the compression effect. For simple data, you can choose not to use Huffman encoding to reduce the overhead of the compression header; for complex data, you can choose to use static or dynamic Huffman encoding to better adapt to the characteristics of the data and further improve the compression ratio.

[0077] In addition, the design of the Deflate data block format in different encoding modes, especially the design that includes Huffman code table information in the dynamic Huffman encoding mode, enables the algorithm to more flexibly adjust the compression strategy when processing different types of data and improve adaptability.

[0078] In one embodiment, the target data block is in a static coding mode, and the target data block includes a header flag and first coded data; the above step 300 may specifically perform the following steps:

[0079] S310, for any target data block among the multiple first data blocks, when the encoding mode of the target data block is a static encoding mode, obtaining a general decoding table;

[0080] S320, decoding the first coded data based on a universal decoding table to obtain a coding mark.

[0081] In these optional embodiments, the use of a universal decoding table can avoid frequent generation of a specific decoding table during the decoding process, thereby reducing memory usage. In addition, the reuse of a universal decoding table can improve the efficiency of the decoding process and avoid the overhead of repeated calculation and construction of a decoding table.

[0082] In one embodiment, the target data block is in a dynamic encoding mode, and the target data block includes a header flag, a dynamic decoding table, and second encoding data; the above step 300 may specifically perform the following steps:

[0083] S330, for any target data block among the multiple first data blocks, when the encoding mode of the target data block is a dynamic encoding mode, parsing the dynamic decoding table to obtain a target decoding table;

[0084] S340, decoding the second coded data based on the target decoding table to obtain a coding mark.

[0085] In these optional embodiments, the parsing of the dynamic decoding table enables the decoding process to adapt to changes in decoding rules in the dynamic encoding mode, thereby improving the flexibility of the system.

[0086] In one embodiment, the target data block is in the initial encoding mode, and the target data block includes a header flag, original data, and a data length of the original data; after the above step 300, the method may further specifically perform the following steps:

[0087] S350: For any target data block among the multiple first data blocks, when the encoding mode of the target data block is the initial encoding mode, store the original data stored in the target data block in a circular buffer.

[0088] Optionally, in a specific implementation of the present application, if the Deflate data block does not use Huffman encoding (i.e., the initial encoding mode), the original data in the Deflate data block is directly written into the circular buffer; if the Deflate data block is in a static Huffman encoding mode, a general Huffman code table (i.e., a general decoding table) is generated; if the Deflate data block is in a dynamic Huffman encoding mode, the Huffman code table (i.e., a target decoding table) of the Deflate data block is generated through the Huffman code table information in the data block (i.e., the dynamic decoding table).

[0089] Secondly, Huffman decoding is performed on the compressed data (i.e., data blocks in static encoding mode or dynamic encoding mode) encoded using Huffman. The decoding result is a special mark (i.e., encoding mark) encoded by the LZ77 algorithm. Special marks include literal, length, distance, and end mark. Literal represents the original data, which occupies one byte; length represents the matching length, and distance represents the distance from the starting position of the matching string. In the deflate format, the maximum value of distance is 32K bytes, and the length and distance marks appear in pairs; the end mark indicates the end of the data block.

[0090] If the decoded special mark is an end mark, the decoding operation of the Deflate data block is terminated; if it is not an end mark, the special mark is subjected to LZ77 decoding operation using a circular buffer.

[0091] Finally, the first bit of the Header flag is used to determine whether the Deflate data block is the last data block of the file. If not, the parsing process of the next Deflate data block is started; if it is the last data block, the decoding process of the file is completed.

[0092] In these optional embodiments, by adopting different processing strategies in the initial coding mode, the static Huffman coding mode and the dynamic Huffman coding mode, a more flexible and intelligent decoding process is achieved. For the initial coding mode, the original data is directly written into the circular buffer, which reduces unnecessary decoding operations and improves the decoding efficiency. In the static Huffman coding mode, a general decoding table is generated, and in the dynamic Huffman coding mode, a target decoding table is generated by the information in the data block, which improves the parsing efficiency of the Huffman coding. Such a design takes into account the possible changes in the Huffman coding and provides greater adaptability for the decoding process.

[0093] When processing compressed data using Huffman coding, Huffman decoding technology is used to obtain special marks encoded by the LZ77 algorithm. By properly decoding these special marks, the correct restoration of the data is ensured. In particular, when the length and distance marks appear in pairs, the correct extraction of the matching string is ensured, making the decoding result more accurate.

[0094] The first bit of the Header flag is introduced to determine whether the Deflate data block is the last data block of the file, so as to automatically decide whether to start the parsing process of the next Deflate data block. Such optimization makes the entire decoding process more intelligent and adaptive, and improves the robustness of decoding.

[0095] In summary, this specific implementation adopts different strategies in different situations, and through intelligent judgment and flexible processing, makes the entire Deflate decoding process more efficient and accurate, and has better adaptability in the decoding process. This improves the performance of ZIP file decompression, reduces resource usage, and provides practical benefits for efficient and stable data decompression under limited hardware resources.

[0096] In one embodiment, the circular buffer includes a start position, a current write position, and an end position; the above step 400 may specifically perform the following steps:

[0097] S410, for any target data block among the plurality of first data blocks, when the mark type corresponding to the target data block is the first type, writing the file data stored in the encoding mark into the circular buffer based on a first interval distance between the current writing position and the end position;

[0098] S420, when the mark type corresponding to the target data block is the second type, based on the copy information stored in the encoding mark and the second interval distance between the current write position and the start position, copy the character string corresponding to the copy information in the circular buffer area.

[0099] In these optional embodiments, the design of the start position, current write position and end position of the circular buffer area fully considers the processing needs of different types of tags, thereby making it possible to perform data writing and copying operations more flexibly and efficiently in different situations.

[0100] Different processing strategies are adopted based on the different types of markers in S410 and S420. For the first type of marker, a file data writing operation based on the interval distance is adopted; and for the second type of marker, the string is copied using the copy information, thereby improving the efficient extraction of the matching string.

[0101] The S410 and S420 use a clever distance calculation method when writing file data and copying strings. This helps improve the efficiency of data writing, reduces unnecessary movement and calculation operations, and speeds up the decompression process.

[0102] By processing data in the circular buffer, the storage of the decoded data of the entire file in the memory is avoided or reduced, effectively reducing the resource usage of the circular buffer. This is particularly critical for embedded systems with limited memory resources, and can effectively avoid or reduce the decompression failure caused by insufficient memory resources.

[0103] In general, the efficiency and stability of decompression are improved through the circular buffer design and flexible processing of different tag types. Specifically, it is more efficient in data writing, string copying, etc., reducing memory usage, thereby improving the effectiveness of decompression.

[0104] In one embodiment, the above step 410 may specifically perform the following steps:

[0105] S411, for any target data block among the multiple first data blocks, when the mark type corresponding to the target data block is the first type, if the current writing position is not the end position, writing the file data stored in the encoding mark to the current writing position;

[0106] S412 moves the current writing position toward the end position by a first byte size, where the first byte size is the byte size of the file data;

[0107] S413, when the current writing position is the end position, storing the decoded data currently stored in the circular buffer into the decoded file;

[0108] S414, write the file data to the start position, and move the current write position toward the end position by the size of a first byte.

[0109] Optionally, in a specific implementation of the present application, when the Huffman decoding result, that is, the encoding mark is not the end mark, LZ77 decoding is performed using a circular buffer. The specific implementation process is as follows:

[0110] If the Huffman decoding result is a literal tag, the one-byte original data is written into the circular buffer. The structural diagram of the circular buffer is as follows: Figure 4 As shown in FIG. 1 , the circular buffer includes a starting position (start), a writing position (write), and an ending position (end). The processing process of the circular buffer after writing each byte of data is as follows: Figure 5 As shown:

[0111] When a byte of data is written to the circular buffer, the byte data is saved at the write position at that time, and then the byte data will be subjected to the bit operation of the cyclic redundancy check (CRC) check. Then the buffer will determine whether the write position is the end position of the buffer. If the write position is not the end position at this time, then the write position will be offset backward by one byte. If the write position is the end position of the circular buffer at this time, then all the data saved in the circular buffer will be written to the target file (i.e., the decoded file), and the write position will be reset to the start position of the circular buffer.

[0112] In these optional embodiments, a circular buffer structure is adopted, and only the currently decoded data, rather than the decoded data of the entire file, needs to be saved in the buffer, which reduces the demand for memory, especially when processing large files, and can better adapt to memory-constrained environments such as embedded systems.

[0113] The raw data is processed byte by byte, so that the system can gradually generate decompressed data without waiting for the entire file to be decoded. This is advantageous for application scenarios that require real-time or gradual decoding.

[0114] Performing a CRC check when writing to the circular buffer helps ensure the integrity of the data written to the target file. This provides a layer of security to detect data errors or tampering during the decompression process.

[0115] In one embodiment, the copy information includes the string length of the copied string and the third interval distance between the starting position of the copied string and the starting point to be copied; the above step 420 may specifically perform the following steps:

[0116] S421, when the mark type corresponding to the target data block is the second type, if the second interval distance is greater than or equal to the third interval distance, the current write position is moved forward by the third interval distance toward the start position to determine the position as the first copy starting point;

[0117] S422, copying the first target character string stored in the first copy starting point to the current write position, the length of the first target character string being the character string length;

[0118] S423, when the second interval distance is smaller than the third interval distance, obtaining an interval difference between the third interval distance and the second interval distance;

[0119] S424, moving the end position in the previous loop buffer area forward by the interval difference in the direction of the start position in the previous loop buffer area to determine it as the second replication start point;

[0120] S425, copying the second target character string stored in the second copy starting point to the current write position, the length of the second target character string being the character string length.

[0121] Optionally, in a specific implementation of the present application, if the Huffman decoding result is a length+distance tag, it means that a character string with a length of length is about to be copied from the circular buffer to the current write position.

[0122] If (write-start)>distance at this time, the starting point of the copied string is the (write-distance) position; if (write-start)<distance, the starting point of the copied string is the (end+write-start-distance+1) position. During the copying process, each byte of data is copied and written into the circular buffer; if the position of the copied character is the end position at this time, the next character position to be copied is the start position.

[0123] For example, suppose there is a string of ABCDEFEFGHEF, suppose the size of the circular buffer is 12 bytes, the starting position of the current buffer is 'D' (i.e., the fourth character) in the example string, the current write position is the seventh position in the example string, the length at this time is 2, the distance is 2, then (write-start) = (7-4) = 3, which is greater than the distance, so the starting point of the copy is (write-distance) = (7-2) = 5, which is the fifth byte 'E'; if the current write is the eleventh position of the example string, the length at this time is 2, the distance is 4, then (write-start) = (11-4) = 7, which is greater than the distance, so the starting point of the copy is (write-distance) = (11-4) = 7, which is the seventh byte 'E', and then the character 'EF' with a length of 2 is copied into the current position.

[0124] In these optional embodiments, by implementing a circular buffer mechanism, the written data can be effectively reused during the decompression process to avoid occupying too many memory resources. This is particularly important for environments with limited memory such as embedded systems, which can reduce the memory requirements of the decompression operation and improve the stability and efficiency of the system. When the position of the copied character reaches the end position of the circular buffer, the next character is copied from the start position, forming a circular effect. This helps to make full use of the decompressed data during decompression, avoid repeated storage of the same information, and improve the efficiency of the decompression algorithm.

[0125] In one embodiment, the compressed information includes an initial verification code of the compressed file; after the above step 400, the method may further specifically perform the following steps:

[0126] S401, based on a preset verification algorithm, performing a verification operation on the decoded file to obtain a verification result;

[0127] S402, comparing the verification result with the initial verification code to obtain a comparison result;

[0128] S403: When the comparison result indicates that the verification result is the same as the initial verification code, it is determined that the compressed file is compressed successfully.

[0129] Optionally, in a specific implementation of the present application, after the decoding process is completed, the data of byte length starting from the start position stored in the circular buffer at this time is written into the target file. At this time, all the original data are all written into the target file, indicating that the compressed file is decompressed. At the same time, it is necessary to compare the CRC check result in the decoding process with the CRC check code of the original data stored in the compression information of the ZIP file (i.e., the compressed file). If the results are the same, it means that the decompression is successful, and if they are different, it means that the decompression fails and the file data is changed.

[0130] In these optional embodiments, comparing the CRC checksum helps to verify the consistency of the decompressed data with the original data, ensuring that the decompression process does not introduce data damage or errors, and improving the reliability of the decompression algorithm. The comparison of the CRC checksum helps to detect whether potential errors have occurred in the decompression process, such as bit flips in transmission or failures of storage media. This helps to improve the security of data and prevent data loss or damage caused by decompression errors. If the CRC checksum results are the same, it means that the decompression is successful, the file data is consistent with the original data, and the user can trust the decompressed file. This helps to ensure the accuracy and effectiveness of the decompression.

[0131] In one embodiment, the compression information further includes the memory size of the original data; after the above step 100, the method may further specifically perform the following steps:

[0132] S101, when the memory size is greater than or equal to the preset memory, setting the storage memory of the circular buffer area to the preset memory;

[0133] S102: When the memory size is smaller than the preset memory, the storage memory of the circular buffer is set to the memory size.

[0134] Optionally, in a specific implementation of the present application, the size of the circular buffer is also related to the size of the memory occupied during the decompression process. If it is necessary to minimize the memory occupied, the smaller the circular buffer is, the better, while ensuring the success of the decompression. The flowchart of the present application on how to determine the minimum value of the circular buffer while ensuring the success of the decompression is as follows: Figure 6 shown.

[0135] The above implementation steps are explained as follows: First, the uncompressed size of the file is obtained, that is, the memory size of the original data; then, the uncompressed size of the file is compared with the 32K byte size. If the uncompressed size of the file is greater than 32K bytes, since the circular buffer needs to support the function of copying the string before the distance distance during the LZ77 decoding process, and the maximum value of distance is 32K bytes, in order to ensure successful decompression, the circular buffer size must be greater than or equal to 32K bytes. In order to minimize the memory usage, the circular buffer size at this time is set to 32K bytes. If the uncompressed size of the file is less than 32K bytes, the size of the circular buffer is set to the uncompressed size of the file.

[0136] In these optional embodiments, under the premise of ensuring successful decompression, the memory usage during the decompression process can be minimized by dynamically determining the size of the circular buffer. For larger files, the circular buffer is set to 32K bytes to support the maximum distance value, and for smaller files, the size of the circular buffer is flexibly set according to the file size to reduce memory usage.

[0137] Taking into account the change in file size, the size of the circular buffer is dynamically adjusted, making the decompression algorithm more versatile and able to adapt to files of different sizes while ensuring the success of decompression. By adjusting the size of the circular buffer according to the file size, it helps to improve the decompression performance, avoid unnecessary memory waste, and make the decompression process more efficient. In addition, the use of the circular buffer in this application can greatly reduce the memory resources occupied during the decompression of files.

[0138] Figure 7 A schematic structural diagram of a data decompression device provided in another embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.

[0139] Reference Figure 7 , the data decompression device may include:

[0140] A first acquisition module 701 is used to acquire compression information of a compressed file, where the compression information includes a compression algorithm of the compressed file;

[0141] The second acquisition module 702 is used to acquire the encoding mode of the compressed file when the compression algorithm is the first algorithm;

[0142] The first decoding module 703 is used to select a first decoding rule matching the encoding mode based on the encoding mode to decode the compressed file once to obtain an encoding mark;

[0143] The second decoding module 704 is used to perform secondary decoding on the compressed file based on the tag type of the encoding tag using the second decoding rule in the circular buffer area to obtain a decoded file. The circular buffer area is used to temporarily store the decoded file. The second decoding rule matches the tag type, and the decoded file corresponds to the original data of the compressed file before compression.

[0144] In one embodiment, the second acquisition module 702 may include:

[0145] A first determination submodule, configured to determine, when the compression algorithm is a first algorithm, that the compressed file includes a plurality of first data blocks;

[0146] A first acquisition submodule, configured to acquire a header flag of any target data block among the plurality of first data blocks, wherein the header flag includes a coding flag bit;

[0147] A second determination submodule, configured to determine that the encoding mode of the target data block is an initial encoding mode when the encoding flag is a first preset value;

[0148] A third determination submodule, configured to determine that the encoding mode of the target data block is a static encoding mode when the encoding flag is a second preset value;

[0149] The fourth determining submodule is used to determine that the encoding mode of the target data block is a dynamic encoding mode when the encoding flag is a third preset value.

[0150] In one embodiment, the target data block is in a static coding mode, and the target data block includes a header flag and first coded data; the first decoding module 703 may include:

[0151] A second acquisition submodule is used to acquire a universal decoding table for any target data block among the plurality of first data blocks when the encoding mode of the target data block is a static encoding mode;

[0152] The first decoding submodule is used to decode the first coded data based on the universal decoding table to obtain a coding mark.

[0153] In one embodiment, the target data block is in a dynamic encoding mode, and the target data block includes a header flag, a dynamic decoding table, and second encoding data; the first decoding module 703 may include:

[0154] A first parsing submodule is used to parse the dynamic decoding table for any target data block among the plurality of first data blocks, when the encoding mode of the target data block is a dynamic encoding mode, to obtain a target decoding table;

[0155] The second decoding submodule is used to decode the second coded data based on the target decoding table to obtain a coding mark.

[0156] In one embodiment, the target data block is in the initial encoding mode, and the target data block includes a header mark, original data, and a data length of the original data; the data decompression device may further include:

[0157] The storage module is used for storing the original data stored in any one target data block among the plurality of first data blocks in a circular buffer area when the encoding mode of the target data block is the initial encoding mode.

[0158] In one embodiment, the circular buffer includes a start position, a current write position, and an end position; the second decoding module 704 may include:

[0159] A first storage submodule is configured to write the file data stored in the encoding mark into the circular buffer area based on a first interval distance between a current writing position and an end position for any target data block among the plurality of first data blocks, when the mark type corresponding to the target data block is of the first type;

[0160] The second storage submodule is used to copy the character string corresponding to the copy information in the circular buffer area based on the copy information stored in the encoding mark and the second interval distance between the current write position and the start position when the mark type corresponding to the target data block is the second type.

[0161] In one embodiment, the first storage submodule may include:

[0162] A first storage unit is configured to write the file data stored in the coding mark to the current writing position for any one target data block among the plurality of first data blocks, if the mark type corresponding to the target data block is the first type and if the current writing position is not the end position;

[0163] A first moving unit, used for moving the current writing position toward the end position by a first byte size, where the first byte size is the byte size of the file data;

[0164] A second storage unit is used to store the decoded data currently stored in the circular buffer into the decoded file when the current write position is the end position;

[0165] The second moving unit is used to write the file data into the starting position and move the current writing position toward the ending position by a first byte size.

[0166] In one embodiment, the copy information includes the string length of the copied string and a third interval distance between the starting position of the copied string and the starting point to be copied; the second storage submodule may include:

[0167] a third moving unit, configured to, when the mark type corresponding to the target data block is the second type and the second interval distance is greater than or equal to the third interval distance, move the current writing position forward in the direction of the starting position by the third interval distance to determine the position as the first copy starting point;

[0168] A third storage unit is used to copy the first target character string stored in the first copy starting point to the current write position, the length of the first target character string being the character string length;

[0169] A first acquiring unit, configured to acquire, when the second interval distance is smaller than the third interval distance, an interval difference between the third interval distance and the second interval distance;

[0170] A fourth moving unit, used for moving the end position in the previous loop buffer area forward by the interval difference in the direction of the start position in the previous loop buffer area to determine the position as the second replication start point;

[0171] The copying unit is used to copy the second target character string stored in the second copy starting point to the current writing position, and the length of the second target character string is the character string length.

[0172] In one embodiment, the compressed information includes an initial checksum of the compressed file; the data decompression device may further include:

[0173] The verification module is used to perform a verification operation on the decoded file based on a preset verification algorithm to obtain a verification result;

[0174] A comparison module is used to compare the verification result with the initial verification code to obtain a comparison result;

[0175] The determination module is used to determine that the compressed file is compressed successfully when the comparison result indicates that the verification result is the same as the initial verification code.

[0176] In one embodiment, the compression information further includes the memory size of the original data; and the data decompression device may further include:

[0177] A first setting module, used for setting the storage memory of the circular buffer area to the preset memory when the memory size is greater than or equal to the preset memory;

[0178] The second setting module is used to set the storage memory of the circular buffer area to the memory size when the memory size is smaller than the preset memory.

[0179] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application, and are devices corresponding to the above-mentioned battery thermal runaway warning method. All implementation methods in the above-mentioned method embodiment are applicable to the embodiments of the device. Its specific functions and technical effects can be found in the method embodiment part, which will not be repeated here.

[0180] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0181] Figure 8 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application is shown.

[0182] The device may include a processor 801 and a memory 802 storing program instructions.

[0183] When the processor 801 executes the program, the steps in any of the above method embodiments are implemented.

[0184] Exemplarily, the program may be divided into one or more modules / units, one or more modules / units are stored in the memory 802 and executed by the processor 801 to complete the present application. One or more modules / units may be a series of program instruction segments capable of completing a specific function, and the instruction segments are used to describe the execution process of the program in the device.

[0185] Specifically, the processor 801 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0186] The memory 802 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 802 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 802 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 802 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 802 is a non-volatile solid-state memory.

[0187] The memory may include read-only memory (ROM), random access memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical or other physical / tangible memory storage devices. Thus, typically, the memory includes one or more tangible (non-transitory) readable storage media (e.g., memory devices) encoded with software including computer executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present disclosure.

[0188] The processor 801 implements any one of the methods in the above embodiments by reading and executing program instructions stored in the memory 802 .

[0189] In one example, the electronic device may further include a communication interface 803 and a bus 810. The processor 801, the memory 802, and the communication interface 803 are connected via the bus 810 and communicate with each other.

[0190] The communication interface 803 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.

[0191] Bus 810 includes hardware, software or both, and the parts of online data flow billing equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front-end bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 810 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the application considers any suitable bus or interconnection.

[0192] In addition, in combination with the method in the above embodiment, the embodiment of the present application can provide a storage medium for implementation. The storage medium stores program instructions; when the program instructions are executed by a processor, any one of the methods in the above embodiment is implemented.

[0193] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0194] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0195] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0196] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.

[0197] The functional modules shown in the above block diagram can be implemented as hardware, software, firmware or their combination. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), suitable firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. Programs or code segments can be stored in machine-readable media, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable media" can include any medium that can store or transmit information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. Code segments can be downloaded via computer grids such as the Internet, intranets, etc.

[0198] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.

[0199] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.

[0200] The above are only specific implementation methods of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.

Claims

1. A data decompression method, characterized in that: The method comprises: Acquire compression information of a compressed file, wherein the compression information includes a compression algorithm for compressing the compressed file; When the compression algorithm is the first algorithm, obtaining the encoding mode of the compressed file; Based on the encoding mode, selecting a first decoding rule matching the encoding mode to decode the compressed file once to obtain an encoding mark; Based on the tag type of the encoding tag, the compressed file is decoded twice in a circular buffer using a second decoding rule to obtain a decoded file. The circular buffer is used to temporarily store the decoded file. The second decoding rule matches the tag type. The decoded file corresponds to the original data of the compressed file before compression.

2. The method according to claim 1, characterized in that When the compression algorithm is the first algorithm, obtaining the encoding mode of the compressed file includes: When the compression algorithm is a first algorithm, determining that the compressed file includes a plurality of first data blocks; For any target data block among the plurality of first data blocks, obtaining a header flag of the target data block, wherein the header flag includes a coding flag bit; When the encoding flag is a first preset value, determining that the encoding mode of the target data block is an initial encoding mode; When the encoding flag is a second preset value, determining that the encoding mode of the target data block is a static encoding mode; When the encoding flag is a third preset value, it is determined that the encoding mode of the target data block is a dynamic encoding mode.

3. The method according to claim 2, characterized in that In the static encoding mode, the target data block includes the header flag and the first encoded data; The step of selecting a first decoding rule matching the encoding mode to decode the compressed file based on the encoding mode to obtain an encoding mark includes: For any one of the target data blocks among the multiple first data blocks, when the encoding mode of the target data block is the static encoding mode, obtaining a general decoding table; The first coded data is decoded based on the universal decoding table to obtain the coded tag.

4. The method according to claim 2, characterized in that: In the dynamic encoding mode, the target data block includes the header flag, the dynamic decoding table and the second encoding data; The step of selecting a first decoding rule matching the encoding mode to decode the compressed file based on the encoding mode to obtain an encoding mark includes: For any one of the target data blocks among the plurality of first data blocks, when the encoding mode of the target data block is the dynamic encoding mode, parsing the dynamic decoding table to obtain a target decoding table; The second coded data is decoded based on the target decoding table to obtain the coded tag.

5. The method according to claim 2, characterized in that: In the initial encoding mode, the target data block includes the header flag, the original data and the data length of the original data; When the compression algorithm is the first algorithm, after obtaining the encoding mode of the compressed file, the method further includes: For any one of the target data blocks among the multiple first data blocks, when the encoding mode of the target data block is the initial encoding mode, the original data stored in the target data block is stored in the circular buffer.

6. The method according to claim 2, characterized in that The circular buffer includes a start position, a current write position and an end position; The method of performing secondary decoding on the compressed file based on the tag type of the coding tag in a circular buffer using a second decoding rule to obtain a decoded file includes: For any one of the target data blocks among the plurality of first data blocks, when the mark type corresponding to the target data block is the first type, based on a first interval distance between the current writing position and the end position, writing the file data stored in the encoding mark into the circular buffer; When the mark type corresponding to the target data block is the second type, based on the copy information stored in the encoding mark and the second interval distance between the current write position and the start position, the character string corresponding to the copy information is copied into the circular buffer area.

7. The method according to claim 6, characterized in that The step of writing, for any one of the target data blocks among the plurality of first data blocks, the file data stored in the encoding mark into the circular buffer based on a first interval distance between the current writing position and the end position when the mark type corresponding to the target data block is the first type, comprises: For any one of the target data blocks among the multiple first data blocks, when the mark type corresponding to the target data block is the first type, if the current writing position is not the end position, writing the file data stored in the encoding mark into the current writing position; Move the current writing position toward the end position by a first byte size, where the first byte size is the byte size of the file data; When the current write position is the end position, storing the decoded data currently stored in the circular buffer into the decoded file; The file data is written into the start position, and the current write position is moved toward the end position by the first byte size.

8. The method according to claim 6, characterized in that The copy information includes the character string length of the copied character string, and a third interval distance between the starting position of the copied character string and the starting point to be copied; In a case where the mark type corresponding to the target data block is the second type, based on the copy information stored in the encoding mark and a second interval distance between the current write position and the start position, copying the character string corresponding to the copy information into the circular buffer area includes: In the case where the mark type corresponding to the target data block is the second type, if the second interval distance is greater than or equal to the third interval distance, the current write position is moved forward by the third interval distance in the direction of the start position to determine the position as the first copy starting point; Copying a first target character string stored in the first copy starting point to the current write position, wherein the length of the first target character string is the character string length; When the second interval distance is smaller than the third interval distance, obtaining an interval difference between the third interval distance and the second interval distance; The end position in the previous cycle buffer is moved forward in the direction of the start position in the previous cycle buffer by the distance difference and determined as the second replication start point; A second target character string stored in the second copy starting point is copied to the current write position, and the length of the second target character string is the character string length.

9. The method according to claim 1, characterized in that: The compression information includes an initial checksum of the compressed file; After the compressed file is decoded again in a circular buffer using a second decoding rule based on the tag type of the coding tag to obtain a decoded file, the method further includes: Based on a preset verification algorithm, a verification operation is performed on the decoded file to obtain a verification result; Compare the verification result with the initial verification code to obtain a comparison result; When the comparison result indicates that the verification result is the same as the initial verification code, it is determined that the compressed file is compressed successfully.

10. The method according to claim 1, characterized in that The compression information also includes the memory size of the original data; After obtaining the compression information of the compressed file, the method further includes: When the memory size is greater than or equal to the preset memory, setting the storage memory of the circular buffer area to the preset memory; When the memory size is smaller than the preset memory, the storage memory of the circular buffer is set to the memory size.

Citation Information

Cited By

  • Meteorological service monitoring data compression and transmission method and system based on cloud edge collaboration

    CN120692325A