Lossless compression decompressing system based on shared storage
By adopting a lossless compression and decompression system based on shared storage in data compression and decompression, and using multiple processors to process divided sub-files in parallel, the problem of slow single-CPU processing speed is solved and faster compression and decompression speeds are achieved. System throughput.
Patent Information
- Application Number
- CN202410723965.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-05
- Publication Date
- 2024-08-27
AI Technical Summary
Due to limited computing resources, existing single-CPU-based data compression algorithms have slow compression and decompression speeds, becoming a bottleneck for real-time processing or high-throughput application systems.
A lossless compression and decompression system based on shared storage is used to divide the file to be processed into multiple sub-files through reading threads, and use the worker thread pool running on different processors to process these sub-files in parallel, and finally merge them into Target files to achieve fast compression and decompression.
It improves the compression and decompression speed of files to be processed, solves the problem of too long serial compression and decompression of massive data, and improves the system throughput.
Smart Images

Figure CN118550889A
Abstract
Description
Technical Field
[0001] The present application relates to the field of compression technology, and in particular to a lossless compression and decompression system based on shared storage. Background Art
[0002] The goal of data compression algorithms is to convert raw data into a more compact representation by using various encoding techniques, thereby reducing the number of bits and bytes required, reducing the data space occupied, and making data more efficient and economical during transmission, storage, and processing.
[0003] Existing data compression algorithms are all designed based on single CPU (Central Processing Unit) processing. The computing resources used by single CPU processing are limited, which limits the compression and decompression speeds of data, and thus the compression and decompression speeds become the bottleneck of real-time processing or high-throughput application systems. Therefore, a compression and decompression system with faster compression and decompression speeds is urgently needed. Summary of the invention
[0004] In view of the above problems, an embodiment of the present application provides a lossless compression and decompression system based on shared storage to overcome the above problems or at least partially solve the above problems.
[0005] The embodiment of the present application discloses a lossless compression and decompression system based on shared storage, including:
[0006] A reading thread, used for reading a plurality of sub-files corresponding to a file to be processed into a first buffer area, wherein the file to be processed includes a file to be compressed and a file to be decompressed;
[0007] A first buffer area, used for caching the plurality of sub-files;
[0008] A worker thread pool, the worker thread pool running on different processors, for processing a plurality of sub-files read from the first buffer area into a plurality of target sub-files, and writing the plurality of target sub-files into a second buffer area;
[0009] A second buffer area, used for caching the multiple target sub-files;
[0010] The writing thread is used to read the multiple target sub-files from the second buffer area, and merge the multiple target sub-files to obtain a target file, where the target file includes a compressed file and a decompressed file.
[0011] Optionally, when the file to be processed is a file to be compressed, the reading thread includes:
[0012] The first cutting thread is used to cut the file to be compressed according to a preset size and add a data mark position to each cutting result of the file to be compressed to obtain a plurality of sub-files to be compressed;
[0013] The first reading thread is used to read the multiple sub-files to be compressed into the first buffer area.
[0014] Optionally, when the file to be processed is a file to be decompressed, the reading thread includes:
[0015] The second cutting thread is used to cut the file to be decompressed according to the data flag position, and add the data flag position to each cutting result of the file to be decompressed to obtain multiple sub-files to be decompressed, and the sub-files to be decompressed carry a check code;
[0016] The second reading thread is used to read the multiple sub-files to be decompressed into the first buffer area.
[0017] Optionally, the working thread pool includes a compression thread pool, and each compression thread in the compression thread pool includes:
[0018] A first reading thread, used for reading the sub-file to be compressed from the first buffer area;
[0019] A compression calculation thread, used for compressing the sub-file to be compressed to obtain a compressed sub-file;
[0020] A verification thread is used to verify whether the data volume of the compressed sub-file is less than the data volume of the corresponding sub-file to be compressed, determine the cache data of the compressed sub-file according to the verification result, and add a verification code to the compressed sub-file to obtain a compressed sub-file carrying a verification code, wherein the verification code includes a compression verification code and an original verification code;
[0021] The first writing thread is used to write the compressed sub-file carrying the verification code into the second buffer area.
[0022] Optionally, the verification thread includes:
[0023] A first check sub-thread is used to add a compression check code to the compressed sub-file when the data volume of the compressed sub-file is less than the data volume of the sub-file to be compressed;
[0024] The second check sub-thread is used to add an original check code to the compressed sub-file when the data volume of the compressed sub-file is not less than the data volume of the sub-file to be compressed.
[0025] Optionally, the working thread pool includes a decompression thread pool, and each decompression thread in the decompression thread pool includes:
[0026] A second reading thread is used to read the sub-file to be decompressed from the first buffer area;
[0027] A check code reading thread, used for reading the check code carried by the sub-file to be decompressed;
[0028] A decompression calculation thread, used for decompressing the sub-file to be decompressed according to the verification code to obtain a decompressed sub-file;
[0029] The second writing thread is used to write the decompressed sub-file into the second buffer area.
[0030] Optionally, the decompression calculation thread includes:
[0031] A first decompression sub-thread is used for decompressing the sub-file to be decompressed to obtain a decompressed sub-file when the check code is a compression check code;
[0032] The second decompression sub-thread is used to use the sub-file to be decompressed as the decompressed sub-file when the verification code is the original verification code.
[0033] Optionally, the write thread includes:
[0034] A third reading thread is used to read a plurality of compressed sub-files carrying verification codes from the second buffer area;
[0035] The first merging thread is used to merge the multiple compressed sub-files carrying the check codes according to the data flags of the multiple compressed sub-files carrying the check codes to obtain a compressed file.
[0036] Optionally, the write thread includes:
[0037] A fourth reading thread, used for reading a plurality of decompressed sub-files from the second buffer area;
[0038] The second merging thread is used to merge the multiple decompressed sub-files according to the data flags of the multiple decompressed sub-files to obtain a decompressed file.
[0039] Optionally, the system further comprises:
[0040] A configuration module is used to configure the compression algorithm of each worker thread in the worker thread pool so that the worker thread pool processes the multiple sub-files read from the first cache area into multiple target sub-files according to the configured compression algorithm, and writes the multiple target sub-files into the second cache area.
[0041] The embodiments of the present application include the following advantages:
[0042] An embodiment of the present application provides a lossless compression and decompression system based on shared storage, including: a reading thread, used to read multiple sub-files corresponding to a file to be processed into a first cache area, wherein the file to be processed includes a file to be compressed and a file to be decompressed; a first cache area, used to cache the multiple sub-files; a working thread pool, wherein the working thread pool runs on different processors, and is used to process the multiple sub-files read from the first cache area into multiple target sub-files, and write the multiple target sub-files into a second cache area; a second cache area, used to cache the multiple target sub-files; a writing thread, used to read the multiple target sub-files from the second cache area, and merge the multiple target sub-files to obtain a target file, wherein the target file includes a compressed file and a decompressed file.
[0043] The embodiment of the present application is based on the lossless compression technology combined with parallel processing technology and shared storage, and uses a read thread, a write thread and a work thread pool to work together to achieve fast compression and decompression processing of the files to be processed. The multiple sub-files corresponding to the files to be processed are read into the first cache area by the read thread, and then the multiple sub-files can be processed in parallel by the work thread pool running on different processors to obtain multiple target sub-files, and the multiple target sub-files are merged into a target file by the write thread. Since the work thread pool runs on different processors, multiple processors are used to process the same file to be processed in parallel, and more computing resources and memory are reasonably used to perform compression and decompression operations, thereby improving the compression speed and decompression speed of the files to be processed, and solving the problem of too long time in serial compression and decompression of massive data. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. 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.
[0045] Figure 1 It is a structural schematic diagram of a lossless compression and decompression system based on shared storage provided in an embodiment of the present application;
[0046] Figure 2 It is a schematic diagram of the principle of compression processing provided by an embodiment of the present application;
[0047] Figure 3 It is a schematic diagram of the principle of decompression processing provided by an embodiment of the present application;
[0048] Figure 4 This is a data compression implementation flow chart of a lossless compression and decompression system based on shared storage provided in an embodiment of the present application;
[0049] Figure 5 This is a data decompression implementation flow chart of a lossless compression and decompression system based on shared storage provided in an embodiment of the present application. DETAILED DESCRIPTION
[0050] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and understandable, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0051] Considering the existing data compression algorithm designed based on single CPU processing, the computing resources used by single CPU processing are limited, which limits the compression speed and decompression speed of data, and then the compression speed and decompression speed become the bottleneck of real-time processing or high-throughput application systems. To this end, the embodiment of the present application provides a lossless compression and decompression system based on shared storage, which divides the file to be compressed into multiple sub-files, each sub-file is compressed on different processors, and finally the compressed sub-files are merged into a large file. During decompression, multiple sub-files corresponding to the file to be decompressed are read, distributed to different processors for decompression, and finally the decompressed sub-files after decompression are merged into a complete decompressed file. Because the files to be processed (files to be compressed and files to be decompressed) are divided into multiple sub-files, more computing resources and memory are used to perform compression and decompression operations, thereby improving the compression speed and decompression speed of the files to be processed and the throughput of the entire system. Please see below for specific description.
[0052] The embodiment of the present application provides a lossless compression and decompression system based on shared storage, referring to Figure 1 As shown, Figure 1 : is a structural schematic diagram of a lossless compression and decompression system based on shared storage provided in an embodiment of the present application, and the lossless compression and decompression system based on shared storage includes:
[0053] A reading thread, used for reading a plurality of sub-files corresponding to a file to be processed into a first buffer area, wherein the file to be processed includes a file to be compressed and a file to be decompressed;
[0054] A first buffer area, used for caching the plurality of sub-files;
[0055] A worker thread pool, the worker thread pool running on different processors, for processing a plurality of sub-files read from the first buffer area into a plurality of target sub-files, and writing the plurality of target sub-files into a second buffer area;
[0056] A second buffer area, used for caching the multiple target sub-files;
[0057] The writing thread is used to read the multiple target sub-files from the second buffer area, and merge the multiple target sub-files to obtain a target file, where the target file includes a compressed file and a decompressed file.
[0058] In an embodiment of the present application, based on the lossless compression technology combined with parallel processing technology and shared storage, a read thread, a write thread and a worker thread pool are used to work together to realize the rapid compression or decompression of the file to be processed. The read thread is a read thread running on the CPU, and the read thread divides the file to be processed and reads the divided multiple sub-files into the first buffer area. Among them, the sub-files can be obtained by dividing according to a preset size or by dividing according to data bits. Specifically, for the file to be compressed, the file to be compressed is divided according to the preset size to obtain multiple sub-files corresponding to the file to be compressed (i.e., multiple sub-files to be compressed); for the file to be decompressed, the data to be decompressed is divided according to the preset data bits to obtain multiple sub-files corresponding to the file to be decompressed (i.e., multiple sub-files to be decompressed).
[0059] The first cache area is a part of the memory space. The multiple sub-files read by the reading thread are cached through the first cache area. The multiple sub-files are cached in the first cache area. Since the sub-files in the first cache area can be read by multiple working threads in the working thread pool and compressed or decompressed, shared storage of multiple sub-files (i.e., files to be processed) is achieved.
[0060] The work thread pool includes multiple work threads, and the work threads compress or decompress the sub-files read from the first buffer area based on the configured compression algorithm to obtain the target sub-file. Among them, the target sub-file includes a compressed sub-file and a decompressed sub-file. In addition, the work threads in the work thread pool are not in a one-to-one correspondence with the sub-files. The number of work threads is related to the number of processors (that is, the number of CPU cores), and the number of sub-files is related to the configuration, that is, the number of sub-files is related to the preset sub-file cutting size or the sub-file cutting data. In the specific implementation, the idle work threads in the work thread pool obtain sub-files from the first buffer area, and multiple work threads process multiple sub-files in parallel. At the same time, after the work thread processes the assigned sub-files, other sub-files are assigned to the work thread to continue processing. If there is no sub-file in the first buffer area, the work thread waits, and continues to read the sub-file when it is detected that there is a sub-file in the first buffer area. If the first buffer area is closed (for example, the first buffer area is closed due to an abnormality), the work thread exits the waiting and closes the work thread.
[0061] The second cache area is a part of the memory space. The multiple target sub-files written by the working thread are cached through the second cache area. Since the multiple target sub-files are written to the second cache area by different working threads, shared storage of the multiple target sub-files is achieved, and then the write thread pool can obtain multiple target sub-files from the second cache area for merging.
[0062] The writing thread is a writing thread running on the CPU, and the writing thread merges multiple target sub-files in the second buffer area to obtain the target file. Specifically, in order to achieve lossless compression and ensure the accuracy of compressed and decompressed files, when the reading thread reads multiple sub-files corresponding to the to-be-processed file into the first buffer area, each sub-file read in is marked with a data flag, and then after obtaining the target sub-file, the target sub-file is merged according to the data flag of the target sub-file.
[0063] For example, Figure 2 This is a schematic diagram of the principle of compression processing provided by an embodiment of the present application. In specific implementation, when the file to be processed is a file to be compressed, the reading thread reads multiple sub-files corresponding to the file to be compressed (i.e., the sub-files to be compressed) into the first cache area, and then the working thread pool reads the multiple sub-files corresponding to the file to be compressed from the first cache area, and processes them into multiple compressed sub-files according to a pre-configured compression algorithm, and writes the multiple compressed sub-files into the second cache area, and finally the writing thread reads the multiple compressed sub-files from the second cache area, and merges the multiple compressed sub-files to obtain a compressed file.
[0064] For example, Figure 3 This is a schematic diagram of the principle of decompression processing provided by an embodiment of the present application. In specific implementation, when the file to be processed is a file to be decompressed, the reading thread reads multiple sub-files corresponding to the file to be decompressed (i.e., the sub-files to be decompressed) into the first cache area, and then the working thread pool reads the multiple sub-files corresponding to the file to be decompressed from the first cache area, and processes them into multiple decompressed sub-files according to the pre-configured compression algorithm, and writes the multiple decompressed sub-files into the second cache area, and finally the writing thread reads the multiple decompressed sub-files from the second cache area, and merges the multiple decompressed sub-files to obtain a decompressed file.
[0065] In summary, based on the lossless compression and decompression system based on shared storage provided by the embodiment of the present application, the reading thread reads multiple sub-files corresponding to the to-be-processed file into the first cache area, and can use the working thread pool running on different processors to process the multiple sub-files in parallel to obtain multiple target sub-files, and merge the multiple target sub-files into a target file through the writing thread. Since the working thread pool runs on different processors, multiple processors are used to process the same to-be-processed file in parallel at the same time, and more computing resources and memory are reasonably used to perform compression and decompression operations, thereby improving the compression speed and decompression speed of the to-be-processed file, and solving the problem of too long time in serial compression and decompression of massive data.
[0066] In an optional embodiment, the system further includes:
[0067] A configuration module is used to configure the compression algorithm of each worker thread in the worker thread pool so that the worker thread pool processes the multiple sub-files read from the first cache area into multiple target sub-files according to the configured compression algorithm, and writes the multiple target sub-files into the second cache area.
[0068] In the embodiment of the present application, the compression algorithm used by the working thread is flexibly configured. The corresponding compression algorithm is configured for the working thread through the configuration module, and the compression algorithm configured for the working thread can also be modified through the configuration module.
[0069] Specifically, the compression algorithm can be a compression algorithm such as GZIP, ZSTD, Snappy, LZ4, etc. Among them, GZIP is a combination of LZ77 compression (LZ77 is a compression algorithm that uses a dictionary for data compression) and Huffman compression algorithm; Snappy is a fast data compression and decompression library written based on the idea of LZ77. The goal of this compression algorithm is not the maximum compression rate or compatibility with other compression libraries, but a very high speed and reasonable compression rate; LZ4 is a LZ77 that uses a 16k hash table to store dictionaries and simplify retrieval, and the compression is relatively poor; ZSTD is a fast compression algorithm that provides a very high compression ratio, and it also provides a special mode for small data, called dictionary compression. It supports the generation of dictionary files in a training manner, which can greatly improve the compression rate of small data packets compared to traditional compression methods. It should be noted that the lossless compression and decompression system based on shared storage in the embodiment of the present application is applicable to a variety of different compression algorithms, and the embodiment of the present application does not make specific restrictions on this.
[0070] In a specific implementation, a configuration module is used to configure multiple compression algorithms for a working thread. When the working thread processes a sub-file, a compression algorithm with good compression effect can be selected for compression and decompression according to the data type of the sub-file.
[0071] In an optional embodiment, when the to-be-processed file is a to-be-compressed file, the reading thread includes:
[0072] The first cutting thread is used to cut the file to be compressed according to a preset size and add a data mark position to each cutting result of the file to be compressed to obtain a plurality of sub-files to be compressed;
[0073] The first reading thread is used to read the multiple sub-files to be compressed into the first buffer area.
[0074] In an embodiment of the present application, the file to be compressed is cut according to a preset size based on the first cutting thread in the reading thread, wherein the preset size can be set according to the processing capacity of the working thread. For example, if the preset size is 100KB (i.e., Kilobyte), the file to be compressed is cut into multiple cut sub-files according to 100KB. At the same time, in order to ensure the correct compression of the file to be compressed, a data flag is added to the cutting result according to the data bit corresponding to each cutting result, and multiple sub-files to be compressed are obtained, so that the compressed sub-files can be merged based on the data flag to obtain the correct compressed file. After obtaining multiple sub-files to be compressed, the first reading thread is used to read the multiple sub-files to be compressed into the first buffer area, so that the subsequent working thread pool reads the multiple sub-files to be compressed from the first buffer area for compression processing.
[0075] Further, the working thread pool includes a compression thread pool, and each compression thread in the compression thread pool includes:
[0076] A first reading thread, used for reading the sub-file to be compressed from the first buffer area;
[0077] A compression calculation thread, used for compressing the sub-file to be compressed to obtain a compressed sub-file;
[0078] A verification thread is used to verify whether the data volume of the compressed sub-file is less than the data volume of the corresponding sub-file to be compressed, determine the cache data of the compressed sub-file according to the verification result, and add a verification code to the compressed sub-file to obtain a compressed sub-file carrying a verification code, wherein the verification code includes a compression verification code and an original verification code;
[0079] The first writing thread is used to write the compressed sub-file carrying the verification code into the second buffer area.
[0080] Wherein, the verification thread includes:
[0081] A first check sub-thread is used to add a compression check code to the compressed sub-file when the data volume of the compressed sub-file is less than the data volume of the sub-file to be compressed;
[0082] The second check sub-thread is used to add an original check code to the compressed sub-file when the data volume of the compressed sub-file is not less than the data volume of the sub-file to be compressed.
[0083] In the embodiment of the present application, the compression thread pool includes multiple compression threads, and the compression thread pool is used to compress multiple sub-files to be compressed to obtain multiple compressed sub-files. Specifically, multiple sub-files to be compressed corresponding to the sub-files to be compressed are stored in the first buffer area, and the idle threads in the compression thread pool are used to read the sub-files to be compressed from the first buffer area, and the read sub-files to be compressed are compressed to obtain corresponding compressed sub-files. Since the compression thread pool runs on different processors, it is possible to use different processors to perform parallel processing on multiple sub-files to be compressed, thereby improving the compression speed of the files to be compressed.
[0084] For each sub-file to be compressed, after the compression calculation thread compresses the sub-file to be compressed into a compressed sub-file, the verification thread is used to verify the data volume of the compressed sub-file, and then the cache data of the compressed sub-file is determined according to the verification result, and a verification code is added to the compressed sub-file, so that when the compressed sub-file is decompressed, the compressed sub-file is decompressed according to the verification code. Specifically, when the data volume of the compressed sub-file is less than the data volume of the sub-file to be compressed, it means that the data volume of the sub-file to be compressed is reduced by the compression process, and then a compression verification code is added to the compressed sub-file, and the data corresponding to the compressed sub-file is written into the second cache area; when the data volume of the compressed sub-file is not less than the data volume of the sub-file to be compressed, it means that the data volume of the sub-file to be compressed is not reduced by the compression process, and then the original verification code is added to the compressed sub-file, and the original data corresponding to the compressed sub-file (i.e., the corresponding sub-file data to be compressed) is written into the second cache area. When the compressed sub-file carrying the verification code is subsequently decompressed, the compressed sub-file carrying the compression verification code is decompressed to obtain the decompressed sub-file; while for the compressed file carrying the original verification code, there is no need to perform a decompression operation, and the compressed sub-file is directly used as the decompressed sub-file.
[0085] Furthermore, the write thread includes:
[0086] A third reading thread is used to read a plurality of compressed sub-files carrying verification codes from the second buffer area;
[0087] The first merging thread is used to merge the multiple compressed sub-files carrying the check codes according to the data flags of the multiple compressed sub-files carrying the check codes to obtain a compressed file.
[0088] In the embodiment of the present application, in order to ensure the correctness of compression of the file to be compressed, corresponding data flags are added to the multiple cutting results obtained by the first cutting thread, that is, the sub-file to be compressed carries the data flag. After the sub-file to be compressed is processed into a compressed sub-file carrying a check code, each compressed sub-file with a check code also carries a data flag. Therefore, after the third reading thread reads multiple compressed sub-files carrying the check code from the second buffer area, the multiple compressed sub-files carrying the check code are merged according to the data flag of each compressed sub-file carrying the check code to obtain a correct compressed file.
[0089] For example, Figure 4 This is a data compression implementation flow chart of a lossless compression and decompression system based on shared storage provided by an embodiment of the present application. First, a file to be compressed is input into the lossless compression and decompression system based on shared storage, and a reading thread, a working thread pool, and a writing thread are started. Then, the file to be compressed is cut into multiple cut sub-files according to a preset size by using the reading thread, and data flags are added to the multiple cut sub-files respectively to obtain multiple sub-files to be compressed, and the multiple sub-files to be compressed are read into the first buffer area for caching. Next, a compression thread pool in the working thread pool is used to read multiple sub-files to be compressed from the first buffer area, and the sub-files to be compressed are compressed according to the compression algorithm configured by itself to obtain a compressed sub-file, and then the data volume of the compressed sub-file is verified to be less than the data volume of the corresponding sub-file to be compressed. In the case where the data volume of the compressed sub-file is less than the data volume of the sub-file to be compressed, the data of the compressed sub-file is used as cache data, and a compression check code is added to the compressed sub-file and written into the second buffer area; in the case where the data volume of the compressed sub-file is not less than the data volume of the sub-file to be compressed, the sub-file to be compressed (i.e., the original data) corresponding to the compressed sub-file is used as cache data, and the original check code is added to the compressed sub-file and written into the second buffer area. Finally, a writing thread is used to read the compressed sub-file carrying the check code from the second buffer area, and according to the data flag bits of the multiple compressed sub-files carrying the check code, the multiple compressed sub-files carrying the check code are merged to obtain a compressed file.
[0090] In an optional embodiment, when the to-be-processed file is a to-be-decompressed file, the reading thread includes:
[0091] The second cutting thread is used to cut the file to be decompressed according to the data flag position, and add the data flag position to each cutting result of the file to be decompressed to obtain multiple sub-files to be decompressed, and the sub-files to be decompressed carry a check code;
[0092] The second reading thread is used to read the multiple sub-files to be decompressed into the first buffer area.
[0093] In the embodiment of the present application, the file to be decompressed is cut according to the data flag based on the second cutting thread in the reading thread, wherein the data flag can be the data flag used when the file to be decompressed is compressed. In order to ensure the correct compression of the file to be decompressed, a data flag is added to each cutting result, thereby obtaining multiple sub-files to be decompressed, so that the decompressed sub-files can be merged based on the data flag to obtain the correct decompressed file. After obtaining multiple sub-files to be decompressed, the second reading thread is used to read the multiple sub-files to be decompressed into the first buffer area, so that the subsequent working thread pool reads the multiple sub-files to be decompressed from the first buffer area for decompression processing.
[0094] Further, the working thread pool includes a decompression thread pool, and each decompression thread in the decompression thread pool includes:
[0095] A second reading thread is used to read the sub-file to be decompressed from the first buffer area;
[0096] A check code reading thread, used for reading the check code carried by the sub-file to be decompressed;
[0097] A decompression calculation thread, used for decompressing the sub-file to be decompressed according to the verification code to obtain a decompressed sub-file;
[0098] The second writing thread is used to write the decompressed sub-file into the second buffer area.
[0099] Wherein, the decompression calculation thread includes:
[0100] A first decompression sub-thread is used for decompressing the sub-file to be decompressed to obtain a decompressed sub-file when the check code is a compression check code;
[0101] The second decompression sub-thread is used to use the sub-file to be decompressed as the decompressed sub-file when the verification code is the original verification code.
[0102] In an embodiment of the present application, the decompression thread pool includes multiple decompression threads, and the decompression thread pool is used to decompress multiple sub-files to be decompressed to obtain multiple decompressed sub-files. Specifically, the multiple sub-files to be decompressed corresponding to the files to be decompressed are stored in the first buffer area, and the idle threads in the decompression thread pool are used to read the sub-files to be decompressed from the first buffer area, and the read sub-files to be decompressed are decompressed to obtain corresponding decompressed sub-files. Since the multiple decompression threads in the decompression thread pool run on different processors, it is possible to use different processors to perform parallel processing on the multiple sub-files to be decompressed, thereby improving the decompression speed of the files to be decompressed.
[0103] For each sub-file to be decompressed, after the second reading thread reads the sub-file to be decompressed from the first buffer area, the verification code reading thread is used to read the verification code carried by the sub-file to be decompressed, and then the decompression calculation thread decompresses the sub-file to be decompressed according to the verification code. Specifically, when the verification code is a compressed verification code, it means that the cached data of the sub-file to be decompressed is data obtained through compression processing, and then the sub-file to be decompressed is decompressed to obtain a decompressed sub-file; when the verification code is an original verification code, it means that the cached data of the sub-file to be decompressed is data that has not been compressed, and there is no need to perform a decompression operation at this time, and then the sub-file to be decompressed is directly used as the decompressed sub-file.
[0104] Furthermore, the write thread includes:
[0105] A fourth reading thread, used for reading a plurality of decompressed sub-files from the second buffer area;
[0106] The second merging thread is used to merge the multiple decompressed sub-files according to the data flags of the multiple decompressed sub-files to obtain a decompressed file.
[0107] In the embodiment of the present application, in order to ensure the correctness of decompression of the file to be decompressed, corresponding data flags are added to the multiple cutting results obtained by the second cutting thread, that is, the sub-file to be decompressed carries a data flag. After the sub-file to be decompressed is processed into a decompressed sub-file, each decompressed sub-file also carries a data flag. Therefore, after the fourth reading thread reads multiple decompressed sub-files from the second buffer area, the multiple decompressed sub-files are merged according to the data flag of each decompressed sub-file to obtain a correct decompressed file.
[0108] For example, Figure 5This is a data decompression implementation flow chart of a lossless compression and decompression system based on shared storage provided by an embodiment of the present application. First, a file to be decompressed is input into the lossless compression and decompression system based on shared storage, and a reading thread, a working thread pool, and a writing thread are started. Then, the reading thread is used to cut the file to be decompressed according to the data flag, and a data flag is added to each cutting result of the file to be decompressed to obtain multiple sub-files to be decompressed, and the sub-file to be decompressed carries a check code, which is a check code added when the file to be decompressed is compressed, and the multiple sub-files to be decompressed are read into the first buffer area. Next, the decompression thread pool in the working thread pool is used to read multiple sub-files to be decompressed from the first buffer area, and the check code of each sub-file to be decompressed is read. When the check code is a compression check code, the compressed sub-file is decompressed to obtain a decompressed sub-file; when the check code is an original check code, the compressed sub-file is used as a decompressed sub-file; and the decompressed sub-file is written into the second buffer area. Finally, the decompressed sub-files are read from the second buffer area by using the writing thread, and the multiple decompressed sub-files are merged according to the data flags of the multiple decompressed sub-files to obtain the decompressed file.
[0109] An embodiment of the present application provides a lossless compression and decompression system based on shared storage, including: a reading thread, used to read multiple sub-files corresponding to a file to be processed into a first cache area, wherein the file to be processed includes a file to be compressed and a file to be decompressed; a first cache area, used to cache the multiple sub-files; a working thread pool, wherein the working thread pool runs on different processors, and is used to process the multiple sub-files read from the first cache area into multiple target sub-files, and write the multiple target sub-files into a second cache area; a second cache area, used to cache the multiple target sub-files; a writing thread, used to read the multiple target sub-files from the second cache area, and merge the multiple target sub-files to obtain a target file, wherein the target file includes a compressed file and a decompressed file.
[0110] The embodiment of the present application is based on the lossless compression technology combined with parallel processing technology and shared storage, and uses a read thread, a write thread and a work thread pool to work together to achieve fast compression and decompression processing of the files to be processed. The multiple sub-files corresponding to the files to be processed are read into the first cache area by the read thread, and then the multiple sub-files can be processed in parallel by the work thread pool running on different processors to obtain multiple target sub-files, and the multiple target sub-files are merged into a target file by the write thread. Since the work thread pool runs on different processors, multiple processors are used to process the same file to be processed in parallel, and more computing resources and memory are reasonably used to perform compression and decompression operations, thereby improving the compression speed and decompression speed of the files to be processed, and solving the problem of too long time in serial compression and decompression of massive data.
[0111] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0112] The embodiments of the present application are described with reference to the system flow chart and / or block diagram according to the embodiments of the present application. It should be understood that each process and / or block in the flow chart and / or block diagram, as well as the combination of the processes and / or blocks in the flow chart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flow chart. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0113] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0114] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0115] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0116] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0117] The above is a detailed introduction to a lossless compression and decompression system based on shared storage provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A lossless compression and decompression system based on shared storage, characterized in that: include: A reading thread, used for reading a plurality of sub-files corresponding to a file to be processed into a first buffer area, wherein the file to be processed includes a file to be compressed and a file to be decompressed; A first buffer area, used for caching the plurality of sub-files; A worker thread pool, the worker thread pool running on different processors, for processing a plurality of sub-files read from the first buffer area into a plurality of target sub-files, and writing the plurality of target sub-files into a second buffer area; A second buffer area, used for caching the multiple target sub-files; The writing thread is used to read the multiple target sub-files from the second buffer area, and merge the multiple target sub-files to obtain a target file, where the target file includes a compressed file and a decompressed file.
2. A lossless compression and decompression system based on shared storage according to claim 1, characterized in that: In the case where the file to be processed is a file to be compressed, the reading thread includes: The first cutting thread is used to cut the file to be compressed according to a preset size and add a data mark position to each cutting result of the file to be compressed to obtain a plurality of sub-files to be compressed; The first reading thread is used to read the multiple sub-files to be compressed into the first buffer area.
3. The lossless compression and decompression system based on shared storage according to claim 1, characterized in that: In the case where the file to be processed is a file to be decompressed, the reading thread includes: The second cutting thread is used to cut the file to be decompressed according to the data flag position, and add the data flag position to each cutting result of the file to be decompressed to obtain multiple sub-files to be decompressed, and the sub-files to be decompressed carry a check code; The second reading thread is used to read the multiple sub-files to be decompressed into the first buffer area.
4. The lossless compression and decompression system based on shared storage according to claim 2, characterized in that: The working thread pool includes a compression thread pool, and each compression thread in the compression thread pool includes: A first reading thread, used for reading the sub-file to be compressed from the first buffer area; A compression calculation thread, used for compressing the sub-file to be compressed to obtain a compressed sub-file; A verification thread is used to verify whether the data volume of the compressed sub-file is less than the data volume of the corresponding sub-file to be compressed, determine the cache data of the compressed sub-file according to the verification result, and add a verification code to the compressed sub-file to obtain a compressed sub-file carrying a verification code, wherein the verification code includes a compression verification code and an original verification code; The first writing thread is used to write the compressed sub-file carrying the verification code into the second buffer area.
5. A lossless compression and decompression system based on shared storage according to claim 4, characterized in that: The verification thread includes: A first check sub-thread is used to add a compression check code to the compressed sub-file when the data volume of the compressed sub-file is less than the data volume of the sub-file to be compressed; The second check sub-thread is used to add an original check code to the compressed sub-file when the data volume of the compressed sub-file is not less than the data volume of the sub-file to be compressed.
6. The lossless compression and decompression system based on shared storage according to claim 3, characterized in that: The working thread pool includes a decompression thread pool, and each decompression thread in the decompression thread pool includes: A second reading thread is used to read the sub-file to be decompressed from the first buffer area; A check code reading thread, used for reading the check code carried by the sub-file to be decompressed; A decompression calculation thread, used for decompressing the sub-file to be decompressed according to the verification code to obtain a decompressed sub-file; The second writing thread is used to write the decompressed sub-file into the second buffer area.
7. The lossless compression and decompression system based on shared storage according to claim 6, characterized in that: The decompression calculation thread includes: A first decompression sub-thread is used for decompressing the sub-file to be decompressed to obtain a decompressed sub-file when the check code is a compression check code; The second decompression sub-thread is used to use the sub-file to be decompressed as the decompressed sub-file when the verification code is the original verification code.
8. The lossless compression and decompression system based on shared storage according to claim 4, characterized in that: The write thread includes: A third reading thread is used to read a plurality of compressed sub-files carrying verification codes from the second buffer area; The first merging thread is used to merge the multiple compressed sub-files carrying the check codes according to the data flags of the multiple compressed sub-files carrying the check codes to obtain a compressed file.
9. The lossless compression and decompression system based on shared storage according to claim 6, characterized in that: The write thread includes: A fourth reading thread, used for reading a plurality of decompressed sub-files from the second buffer area; The second merging thread is used to merge the multiple decompressed sub-files according to the data flags of the multiple decompressed sub-files to obtain a decompressed file.
10. The lossless compression and decompression system based on shared storage according to claim 1, characterized in that: The system further comprises: A configuration module is used to configure the compression algorithm of each worker thread in the worker thread pool so that the worker thread pool processes the multiple sub-files read from the first cache area into multiple target sub-files according to the configured compression algorithm, and writes the multiple target sub-files into the second cache area.
Citation Information
Cited By
Method and system for extracting compressed packet sub-file according to screening rule and medium
CN118897826A
Method and system for rapidly analyzing compressed file content
CN119336718A
