Method, system and equipment for rapidly extracting multi-level compressed file and medium
By using blocking queue and multi-threading technology in multi-level compressed file decompression to replace the traditional recursive method, the problem of low efficiency and memory overflow of the traditional method is solved, and a more efficient decompression process is achieved.
Patent Information
- Application Number
- CN202410796499.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-19
- Publication Date
- 2024-10-22
AI Technical Summary
The traditional recursive method is inefficient when decompressing multi-level compressed files. Excessive recursion depth may cause memory overflow errors and cannot effectively utilize CPU computing power.
It adopts initialization blocking queue, decompression producer thread and decompression consumer thread, traverses compressed file splitting, layer-by-layer multi-thread decompression and iterative queue decompression, and uses multi-threaded concurrent operations to replace recursive algorithms to improve decompression efficiency and stability.
It improves the efficiency and stability of multi-level compressed file decompression, reduces memory overhead, avoids recursion depth limits and memory overflow errors, and makes full use of CPU computing power.
Smart Images

Figure CN118819826A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data decompression, and in particular to a method, system, device and medium for quickly extracting multi-level compressed files. Background Art
[0002] A multi-level compressed file refers to a file that has been compressed multiple times in a computer, that is, one compressed file contains other compressed files, which in turn contain other compressed files. Multi-level compressed files are widely used in privacy data encryption scenarios. In order to obtain compressed file data, data extraction from multi-level compressed files is required.
[0003] Traditional methods for decompressing multi-level compressed files are mainly based on recursive file decompression and extraction methods. In actual use, recursive file decompression and extraction methods cannot effectively utilize the computer CPU computing power, and the decompression speed is slow. If the recursive depth is too large, the function call stack may exhaust the available memory space, resulting in a stack overflow error. In addition, the use of recursion has a depth limit in some scenarios. When the recursive depth exceeds the limit, the program may crash or exception, which may lead to low efficiency when extracting data from multi-level compressed files. Summary of the invention
[0004] The present invention provides a method, system, device and medium for quickly extracting multi-level compressed files, the main purpose of which is to solve the problem of low efficiency in data extraction from multi-level compressed files in the related art.
[0005] To achieve the above-mentioned purpose, the present invention provides a method for quickly extracting multi-level compressed files, including: initializing a blocking queue, a decompression producer thread and a decompression consumer thread; using the decompression producer thread to traverse the compressed files to be decompressed and split them to obtain a main-level compressed file set and a main-level decompressed file set; using the decompression producer thread to store the main-level compressed file set in the blocking queue to obtain a decompression task queue; performing multi-threaded decompression on the decompression task queue layer by layer according to the decompression consumer thread to obtain a sub-level decompression result; iteratively enqueuing and decompressing the decompression task queue according to the main-level decompression file set and the sub-level decompression result to obtain a standard decompression result.
[0006] In order to solve the above problems, the present invention also provides a system for quickly extracting multi-level compressed files, the system comprising: a queue initialization module, used to initialize a blocking queue, a decompression producer thread and a decompression consumer thread; a traversal and splitting module, used to use the decompression producer thread to traverse and split the multi-level compressed files to be decompressed, and obtain a main-level compressed file set and a main-level decompressed file set; a task enqueuing module, used to use the decompression producer thread to store the main-level compressed file set in a blocking queue, and obtain a decompression task queue; a layer-by-layer decompression module, used to perform layer-by-layer multi-thread decompression on the decompression task queue according to the decompression consumer thread, and obtain a sub-level decompression result; an iterative decompression module, used to iteratively enqueue and decompress the decompression task queue according to the main-level decompression file set and the sub-level decompression result, and obtain a standard decompression result.
[0007] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:
[0008] at least one processor; and,
[0009] a memory communicatively connected to at least one processor; wherein,
[0010] The memory stores a computer program that can be executed by at least one processor. The computer program is executed by at least one processor so that the at least one processor can execute the above-mentioned method for quickly extracting multi-level compressed files.
[0011] In order to solve the above problem, the present invention also provides a computer-readable storage medium storing a computer program, which implements the above method for quickly extracting multi-level compressed files when executed by a processor.
[0012] The embodiment of the present invention can realize multi-threaded queue decompression tasks by initializing blocking queues, decompression producer threads and decompression consumer threads, thereby improving the stability and security of multi-level compressed file decompression, improving the overall decompression efficiency, and realizing primary decompression by traversing compressed file splitting, and screening out sub-level compressed files, so as to facilitate subsequent further decompression operations, and by storing the main level compressed file set in the blocking queue to obtain the decompression task queue, it is possible to prevent dependency errors and thread waiting during decompression, thereby improving the efficiency of decompression, and by performing layer-by-layer multi-thread decompression, it is possible to use multi-thread technology to perform concurrent decompression processing on multi-level compressed files, thereby improving the efficiency of data decompression and the utilization rate of threads, and by performing iterative queue decompression, it is possible to use an iterative algorithm to replace a recursive decompression algorithm, thereby improving the decompression performance and reducing the memory overhead during decompression, and by using the CPU computing power through blocking queues and multi-threaded concurrent operations, obtaining a more efficient decompression efficiency. Therefore, the method, system, device and medium for quickly extracting multi-level compressed files proposed by the present invention can solve the problem of low efficiency when extracting data from multi-level compressed files. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 A schematic diagram of a process for quickly extracting multi-level compressed files provided by an embodiment of the present invention;
[0014] Figure 2 A schematic diagram of a process for splitting a compressed file provided by an embodiment of the present invention;
[0015] Figure 3 A schematic diagram of a process of layer-by-layer multi-thread decompression provided by an embodiment of the present invention;
[0016] Figure 4 A functional module diagram of a system for rapidly extracting multi-level compressed files provided by an embodiment of the present invention;
[0017] Figure 5 A schematic diagram of the structure of an electronic device for implementing a method for quickly extracting multi-level compressed files provided by an embodiment of the present invention.
[0018] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0019] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0020] The embodiment of the present application provides a method for quickly extracting multi-level compressed files. The execution subject of the method for quickly extracting multi-level compressed files includes but is not limited to at least one of the electronic devices such as a server and a terminal that can be configured to execute the method provided by the embodiment of the present application. In other words, the method for quickly extracting multi-level compressed files can be executed by software or hardware installed on a terminal device or a server device. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc. The server can be an independent server, or it can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms.
[0021] Reference Figure 1 FIG. 1 is a flow chart of a method for quickly extracting multi-level compressed files provided by an embodiment of the present invention. In this embodiment, the method for quickly extracting multi-level compressed files includes:
[0022] S1, initialize the blocking queue, decompress the producer thread, and decompress the consumer thread.
[0023] In detail, a blocking queue is a queue that supports two additional operations. When the blocking queue is empty, an acquisition operation such as take will block the thread until there are available elements in the queue. When the blocking queue is full, an addition operation such as put will block the thread until there is free space in the queue.
[0024] Specifically, the decompression producer thread refers to the producer thread (ProducerThread) used for decompressing multi-level compressed files. The producer thread is used to generate or obtain the decompression tasks that need to be processed, and put the decompression tasks into the blocking queue. If the blocking queue is full, the producer thread will be blocked until there is free space in the blocking queue.
[0025] Specifically, the decompression consumer thread refers to a consumer thread (ConsumerThread) used for decompressing multi-level compressed files. The consumer thread is used to take out the decompression task from the blocking queue and process it. If the blocking queue is empty, the consumer thread will be blocked until there is an available decompression task in the blocking queue.
[0026] In an embodiment of the present invention, a blocking queue, a decompression producer thread, and a decompression consumer thread are initialized, including: initializing a task queue; performing thread initialization on the task queue according to a pre-acquired number of CPU cores to obtain an initial thread pool; performing thread allocation on the thread pool to obtain a decompression producer thread and a decompression consumer thread; and performing blocking configuration on the task queue according to the decompression producer thread and the decompression consumer thread to obtain a blocking queue.
[0027] In detail, the queue function can be used to initialize the task queue. The number of CPU cores refers to the number of independent processing units in the central processing unit. Each core can perform computing tasks independently, which means that a multi-core CPU can process multiple tasks in parallel, thereby improving the overall computing performance.
[0028] Specifically, the thread pool size function can be used to initialize threads in the task queue. Thread initialization means setting the number of threads in the initial thread pool to the number of CPU cores minus one, so that most cores are utilized while leaving a certain buffer to cope with other tasks of the system.
[0029] In detail, the join function of the threading library can be used to configure the task queue to block and obtain a blocking queue. The blocking configuration means that when the blocking queue is empty, the decompression consumer thread will be blocked until there are available elements in the queue. When the blocking queue is full, the decompression producer thread will be blocked until there is free space in the queue.
[0030] In the embodiment of the present invention, a multi-threaded queue decompression task can be implemented by initializing a blocking queue, a decompression producer thread, and a decompression consumer thread, thereby improving the stability and security of multi-level compressed file decompression and improving the overall decompression efficiency.
[0031] S2. Use the decompression producer thread to traverse the multi-level compressed files to be decompressed and split the compressed files to obtain a primary-level compressed file set and a primary-level decompressed file set.
[0032] In detail, a multi-level compressed file refers to a file that has been compressed multiple times in a computer, where one compressed file contains other compressed files, which in turn contain other compressed files. Each main-level compressed file in a main-level compressed file set refers to a sub-compressed file obtained after the first decompression of a multi-level compressed file. Each main-level decompressed file in a main-level decompressed file set refers to a non-compressed file obtained after the first decompression of a multi-level compressed file.
[0033] In the embodiment of the present invention, refer to Figure 2As shown, the above process of using the decompression producer thread to traverse the multi-level compressed files to be decompressed to split the compressed files and obtain the main-level compressed file set and the main-level decompressed file set includes the following steps:
[0034] S21, using the decompression producer thread to perform file scanning on the multi-level compressed files to be decompressed, to obtain a primary file set;
[0035] S22, selecting files in the main file set one by one as target files, extracting compression features from the target files, and obtaining target compression features;
[0036] S23, performing compression attribute detection on the target compression feature to obtain a target detection result;
[0037] S24. Compress and filter the primary file set according to all target detection results to obtain a primary compressed file set and a primary decompressed file set.
[0038] Specifically, decompression libraries such as zipfile, tarfile or rarfile may be used to perform file scanning, which refers to opening a multi-level compressed file and scanning each file in the multi-level compressed file, and collecting all scanned files into a master file set.
[0039] Specifically, compression features are extracted from the target file to obtain target compression features, including: extracting the suffix of the target file to obtain the target suffix; extracting the file header of the target file to obtain the target file header; extracting the magic number of the target file header to obtain the target magic number; and performing feature splicing and fusion on the target magic number and the target suffix to obtain the target compression features.
[0040] In detail, suffix extraction refers to extracting the suffix of the target file as the target suffix. The target suffix can be txt, zip or 7z. File header extraction refers to extracting the file header content of the target file as the target file header. The beginning part of the file header file contains information about the file content. This information usually includes file format, version, size, data encoding method and other metadata.
[0041] Specifically, magic number analysis refers to extracting the magic number in the target file header. The magic number is a specific byte sequence in the file header that is used to identify the file type. Each file format usually has a unique magic number. When the system or application reads the file, the file type can be quickly identified based on the magic number. For example, the magic number of GZ is 1F8B.
[0042] Specifically, compression attribute detection is performed on the target compression feature to obtain a target detection result, including: determining whether the target compression feature contains a compression suffix; if so, using the compression attribute as the target detection result of the target compression feature; if not, determining whether the target compression feature contains a compression magic number; if so, using the compression attribute as the target detection result of the target compression feature; if not, using the non-compression attribute as the target detection result of the target compression feature.
[0043] In detail, the compression suffix refers to the default suffix of the compressed file, such as rar, zip, tar and gz, and the compression magic number refers to the magic number in the file header of the compressed file, such as 0x504B0304, 1F8B and 0x526172211A0700.
[0044] Specifically, the compression attribute is the attribute label of the compressed file, the non-compression attribute is the attribute label of the non-compressed file, and compression filtering refers to filtering out the files whose target detection results are compression attributes from the main-level file set as main-level compressed files to form a main-level compressed file set, and filtering out the files whose target detection results are non-compression attributes in the main-level file set as main-level decompressed files to form a main-level decompressed file set.
[0045] In the embodiment of the present invention, by traversing and splitting the compressed file, primary decompression can be achieved, and the child compressed files can be screened out, which facilitates further decompression operations.
[0046] S3. Use the decompression producer thread to store the primary compressed file set into a blocking queue to obtain a decompression task queue.
[0047] In detail, each decompression task in the decompression task queue refers to a decompression task corresponding to a compressed file that needs to be further decompressed, and the decompression task includes the remaining undecompressed compressed files of the main level in the multi-level compressed files.
[0048] In an embodiment of the present invention, a decompression producer thread is used to store a main-level compressed file set in a blocking queue to obtain a decompression task queue, including: using a compression producer thread to initialize the task of the main-level compressed file set to obtain a decompression task set; and enqueuing the blocking queue according to the decompression task set to obtain a decompression task queue.
[0049] In detail, task initialization refers to initializing the enqueue task of the compression producer thread for the primary compressed file set. Task initialization includes specifying the enqueue sequence number of each primary compressed file in the primary compressed file set. The enqueue operation can be implemented using the queue.put function.
[0050] In the embodiment of the present invention, by storing the primary compressed file set in a blocking queue to obtain a decompression task queue, dependency errors and thread waiting phenomena during decompression can be prevented, thereby improving the efficiency of decompression.
[0051] S4. Perform multi-thread decompression on the decompression task queue layer by layer according to the decompression consumer thread to obtain a sub-level decompression result.
[0052] In detail, the sub-level decompression result refers to the file decompressed for the second time of the multi-level decompressed file, that is, it includes the decompressed sub-level compressed files and non-compressed files.
[0053] In the embodiment of the present invention, refer to Figure 3 As shown, the above process of performing multi-thread decompression on the decompression task queue layer by layer according to the decompression consumer thread to obtain the sub-level decompression result includes the following steps:
[0054] S31, selecting concurrent tasks from the decompression task queue according to the decompression consumer thread to obtain a target decompression task group;
[0055] S32, performing multi-thread decompression on the target decompression task group according to the decompression consumer thread to obtain a thread decompression file set;
[0056] S33, performing format verification on the thread decompression file set to obtain a verified decompression file set;
[0057] S34, updating the result of the verification decompression file set to obtain the sub-level decompression result.
[0058] In detail, concurrent task selection refers to using each thread in the decompression consumer thread to select several decompression tasks in the decompression task queue one by one as the target decompression task group, and multi-threaded decompression refers to each thread in the decompression consumer thread decompressing the corresponding decompression task in the target decompression task group to obtain the thread decompression file, and all the thread decompression files are collected into a thread decompression file set, wherein the decompression method can be tar, zip, rar and other decompression methods.
[0059] Specifically, format verification is performed on the thread decompressed file set to obtain a verified decompressed file set, including: directory initialization of the thread decompressed file set to obtain a sub-level decompression directory; compression format processing of the thread decompressed file set to obtain a format decompressed file set; integrity verification of the format decompressed file set to obtain a verified decompressed file set; directory configuration of the verified decompressed file set according to the sub-level decompression directory to obtain a verified decompressed file set.
[0060] In detail, directory initialization refers to initializing the corresponding data directory according to the hierarchical structure of each thread decompressed file in the multi-level compressed file in the thread decompression file set, compression format processing refers to format verification of the decompressed file, integrity verification refers to the verification of whether the file decompression is complete, and directory configuration refers to storing each file in the verified decompressed file set in the corresponding sub-level decompression directory.
[0061] Specifically, the result update is to generate a decompression log according to the verified decompression file set, and update the task status of each decompression task in the target decompression task group, and use the verified decompression file set and the decompression log as the sub-level decompression result.
[0062] In the embodiment of the present invention, by performing layer-by-layer multi-thread decompression, multi-thread technology can be used to perform concurrent decompression processing on multi-level compressed files, thereby improving the efficiency of data decompression and the utilization rate of threads.
[0063] S5. Iterate and decompress the decompression task queue according to the main-level decompression file set and the sub-level decompression results to obtain a standard decompression result.
[0064] In detail, the standard decompression result includes the decompressed file data in each level of the multi-level compressed file and the decompressed complete log data.
[0065] In an embodiment of the present invention, the decompression task queue is iteratively queued and decompressed according to the main-level decompression file set and the sub-level decompression results to obtain a standard decompression result, including: traversing the compressed files of the sub-level decompression results to split them, to obtain a sub-level compressed file set and a sub-level decompression file set; judging whether the sub-level compressed file set is an empty set; if not, updating the main-level compressed file using the sub-level compressed file set, and updating the blocking queue using the decompression task queue; returning to the step of storing the main-level compressed file set in the blocking queue using the decompression producer thread; if so, aggregating the main-level decompression file set and all the sub-level decompression file sets into a standard decompression result.
[0066] In detail, the method of traversing compressed file splitting is consistent with the method of traversing compressed file splitting in the above step S1. By judging whether the sub-level compressed file set is an empty set, it is possible to iteratively queue and decompress compressed files of each sub-level in the sub-level decompression result.
[0067] In an embodiment of the present invention, by performing iterative decompression, an iterative algorithm can be used instead of a recursive decompression algorithm, thereby improving decompression performance and reducing memory overhead during decompression, and utilizing the computing power of the CPU through blocking queues and multi-threaded concurrent operations to obtain more efficient decompression efficiency.
[0068] The embodiment of the present invention can realize the multi-threaded queue decompression task by initializing the blocking queue, the decompression producer thread and the decompression consumer thread, thereby improving the stability and security of the decompression of the multi-level compressed file, improving the overall decompression efficiency, and realizing primary decompression by traversing the compressed file splitting, and screening out the compressed files of the sub-level, so as to facilitate the subsequent further decompression operation, and by storing the main level compressed file set in the blocking queue, obtaining the decompression task queue, it is possible to prevent the dependency error and the phenomenon of thread waiting during decompression, and improve the decompression efficiency, and by performing layer-by-layer multi-thread decompression, it is possible to use the multi-thread technology to perform concurrent decompression processing on the multi-level compressed file, thereby improving the efficiency of data decompression and the utilization rate of threads, and by performing iterative queue decompression, it is possible to use the iterative algorithm to replace the recursive decompression algorithm, thereby improving the decompression performance and reducing the memory overhead during decompression, and by using the CPU computing power through the blocking queue and multi-thread concurrent operation, a more efficient decompression efficiency is obtained. Therefore, the method for quickly extracting multi-level compressed files proposed by the present invention can solve the problem of low efficiency when extracting data from multi-level compressed files.
[0069] like Figure 4 FIG. 1 is a functional module diagram of a system for rapidly extracting multi-level compressed files provided by an embodiment of the present invention.
[0070] The system 400 for quickly extracting multi-level compressed files of the present invention can be installed in an electronic device. According to the functions implemented, the system 400 for quickly extracting multi-level compressed files can include a queue initialization module 401, a traversal splitting module 402, a task queue module 403, a layer-by-layer decompression module 404, and an iterative decompression module 405. The module of the present invention can also be called a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, and is stored in the memory of the electronic device.
[0071] In this embodiment, the functions of each module / unit are as follows:
[0072] The queue initialization module 401 is used to initialize the blocking queue, decompress the producer thread, and decompress the consumer thread;
[0073] A traversal splitting module 102 is used to traverse and split the multi-level compressed files to be decompressed by using a decompression producer thread to obtain a primary compressed file set and a primary decompressed file set;
[0074] The task queue module 403 is used to store the primary compressed file set into the blocking queue by using the decompression producer thread to obtain a decompression task queue;
[0075] A layer-by-layer decompression module 404 is used to perform layer-by-layer multi-thread decompression on the decompression task queue according to the decompression consumer thread to obtain a sub-level decompression result;
[0076] The iterative decompression module 405 is used to iteratively decompress the decompression task queue according to the main-level decompression file set and the sub-level decompression results to obtain a standard decompression result.
[0077] In detail, each module in the system 400 for rapidly extracting multi-level compressed files in the embodiment of the present invention is used in the same manner as described above. Figure 1 The method for quickly extracting multi-level compressed files is the same technical means and can produce the same technical effect, which will not be repeated here.
[0078] like Figure 5 FIG. 1 is a schematic diagram of the structure of an electronic device for implementing a method for quickly extracting multi-level compressed files provided by an embodiment of the present invention.
[0079] The electronic device 501 may include a processor 510, a memory 511, a communication bus 512, and a communication interface 513. It may also include a computer program stored in the memory 511 and executable on the processor 510, such as a program for quickly extracting multi-level compressed files.
[0080] In some embodiments, the processor 510 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 510 is the control core (Control Unit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules stored in the memory 511 (for example, a program for quickly extracting multi-level compressed files, etc.), and calls data stored in the memory 511 to execute various functions of the electronic device and process data.
[0081] The memory 511 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (for example, SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory 511 may be an internal storage unit of an electronic device, such as a mobile hard disk of the electronic device. In other embodiments, the memory 511 may also be an external storage device of an electronic device, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Further, the memory 511 may also include both an internal storage unit of the electronic device and an external storage device. The memory 511 can not only be used to store application software and various types of data installed in the electronic device, such as the code of a program for quickly extracting multi-level compressed files, etc., but also can be used to temporarily store data that has been output or is to be output.
[0082] The communication bus 512 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory 511 and at least one processor 510, etc.
[0083] The communication interface 513 is used for communication between the above-mentioned electronic device and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface may also be a standard wired interface, a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, etc. Among them, the display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface.
[0084] The figure only shows an electronic device with components. Those skilled in the art will understand that the structure shown in the figure does not constitute a limitation on the electronic device, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0085] For example, although not shown, the electronic device may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to at least one processor 510 through a power management system, so that the power management system can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators. The electronic device may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0086] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited by this structure.
[0087] Specifically, the specific implementation method of the processor 510 for the above instructions can refer to the description of the relevant steps in the corresponding embodiment of the accompanying drawings, which will not be repeated here.
[0088] Furthermore, if the module / unit integrated in the electronic device 501 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium can include: any entity or system capable of carrying computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory).
[0089] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0090] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0091] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A method for quickly extracting multi-level compressed files, characterized in that: The method comprises: Initialize blocking queues, decompress producer threads, and decompress consumer threads; Utilize the decompression producer thread to traverse the multi-level compressed files to be decompressed and split the compressed files to obtain a primary-level compressed file set and a primary-level decompressed file set; Using the decompression producer thread to store the primary compressed file set into the blocking queue, to obtain a decompression task queue; Performing layer-by-layer multi-thread decompression on the decompression task queue according to the decompression consumer thread to obtain a sub-level decompression result; The decompression task queue is iteratively queued and decompressed according to the main-level decompression file set and the sub-level decompression result to obtain a standard decompression result.
2. The method for quickly extracting multi-level compressed files as claimed in claim 1, characterized in that: The initialization of the blocking queue, decompression of the producer thread and decompression of the consumer thread include: Initialize the task queue; Initializing threads of the task queue according to the number of CPU cores obtained in advance to obtain an initial thread pool; Performing thread allocation on the thread pool to obtain a decompression producer thread and a decompression consumer thread; The task queue is blocked and configured according to the decompression producer thread and the decompression consumer thread to obtain a blocking queue.
3. The method for quickly extracting multi-level compressed files as claimed in claim 1, characterized in that: The method of using the decompression producer thread to traverse the multi-level compressed files to be decompressed to split the compressed files to obtain a primary-level compressed file set and a primary-level decompressed file set includes: Using the decompression producer thread to scan the multi-level compressed files to be decompressed, to obtain a primary file set; Selecting files in the primary file set one by one as target files, extracting compression features of the target files, and obtaining target compression features; Performing compression attribute detection on the target compression feature to obtain a target detection result; The main-level file set is compressed and screened according to all target detection results to obtain a main-level compressed file set and a main-level decompressed file set.
4. The method for quickly extracting multi-level compressed files as claimed in claim 3, characterized in that: The step of extracting compression features from the target file to obtain target compression features includes: Extracting the suffix of the target file to obtain the target suffix; Extracting the file header of the target file to obtain the target file header; Extracting a magic number from the target file header to obtain a target magic number; The target magic number and the target suffix name are subjected to feature concatenation and fusion to obtain target compression features.
5. The method for quickly extracting multi-level compressed files as claimed in claim 3, characterized in that: The performing compression attribute detection on the target compression feature to obtain the target detection result includes: Determining whether the target compression feature includes a compression suffix; If yes, taking the compression attribute as the target detection result of the target compression feature; If not, determining whether the target compression feature includes a compression magic number; If yes, taking the compression attribute as the target detection result of the target compression feature; If not, the non-compressed attribute is used as the target detection result of the target compression feature.
6. The method for quickly extracting multi-level compressed files as claimed in claim 1, characterized in that: The method of using the decompression producer thread to store the primary compressed file set into the blocking queue to obtain a decompression task queue includes: Using the compression producer thread to initialize the tasks of the primary compressed file set to obtain a decompression task set; The blocking queue is enqueued according to the decompression task set to obtain a decompression task queue.
7. The method for quickly extracting multi-level compressed files as claimed in claim 1, characterized in that: The step of performing layer-by-layer multi-thread decompression on the decompression task queue according to the decompression consumer thread to obtain a sub-level decompression result includes: Perform concurrent task selection on the decompression task queue according to the decompression consumer thread to obtain a target decompression task group; Perform multi-thread decompression on the target decompression task group according to the decompression consumer thread to obtain a thread decompression file set; Performing format verification on the thread decompressed file set to obtain a verified decompressed file set; The verification decompression file set is updated with results to obtain a sub-level decompression result.
8. The method for quickly extracting multi-level compressed files as claimed in claim 7, characterized in that: The step of performing format verification on the thread decompressed file set to obtain a verified decompressed file set includes: Initialize the directory of the thread decompression file set to obtain a sub-level decompression directory; Performing compression format processing on the thread decompressed file set to obtain a format decompressed file set; Performing integrity check on the decompressed file set in the format to obtain a verified decompressed file set; The verification decompression file set is directory configured according to the sub-level decompression directory to obtain the verification decompression file set.
9. The method for quickly extracting multi-level compressed files as claimed in claim 1, characterized in that: The iterative decompression of the decompression task queue according to the main-level decompression file set and the sub-level decompression result to obtain a standard decompression result includes: The sub-level decompression result is traversed and compressed to split the file to obtain a sub-level compressed file set and a sub-level decompressed file set; Determine whether the sub-level compressed file set is an empty set; If not, the main-level compressed file is updated by using the sub-level compressed file set, and the blocking queue is updated by using the decompression task queue; Returning to the step of storing the primary compressed file set into the blocking queue by using the decompression producer thread; If so, the main-level decompression file set and all sub-level decompression file sets are aggregated into a standard decompression result.
10. A system for rapidly extracting multi-level compressed files, characterized in that: The system comprises: The queue initialization module is used to initialize the blocking queue, decompress the producer thread, and decompress the consumer thread; A traversal splitting module, used for traversing and splitting the multi-level compressed files to be decompressed by using the decompression producer thread to obtain a primary-level compressed file set and a primary-level decompressed file set; A task queue module, used for storing the primary compressed file set into the blocking queue by using the decompression producer thread to obtain a decompression task queue; A layer-by-layer decompression module, used for performing layer-by-layer multi-thread decompression on the decompression task queue according to the decompression consumer thread to obtain a sub-level decompression result; The iterative decompression module is used to iteratively queue and decompress the decompression task queue according to the main-level decompression file set and the sub-level decompression result to obtain a standard decompression result.
11. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method for quickly extracting multi-level compressed files as described in any one of claims 1 to 9.
12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for quickly extracting multi-level compressed files as described in any one of claims 1 to 9 is implemented.
