Method, device, equipment, storage medium and program product for generating difference files

By dynamically expanding and compressing the exact matching area in the binary differential algorithm and determining the approximate matching area, the problem of excessive size of the differential file is solved, and the software upgrade performance and data processing efficiency are improved.

CN118467013BActive Publication Date: 2024-11-05镁佳(北京)科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410568067.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-09
Publication Date
2024-11-05
Estimated Expiration
2044-05-09

AI Technical Summary

Technical Problem

When generating differential files, the existing binary differential algorithms have a large size due to the blindness and roughness of the fixed extension matching area, which affects the software upgrade performance.

Method used

By finding the exact matching area with a length greater than the preset byte in the original file and the target file, and dynamically expanding it according to the actual data content and length, determining the approximate matching area is reduced to reduce the generation of redundant data, and using the preset compression algorithm to compress the differential data To optimize the size of the differential file.

Benefits of technology

Improves the efficiency and accuracy of differential file generation, reduces calculation and processing time, reduces data transmission and storage costs, and optimizes the patch generation process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118467013B_ABST
    Figure CN118467013B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of software upgrade, and discloses a method, device, equipment, storage medium and program product for generating a difference file. The method comprises: obtaining and comparing an original file and a target file to find a fully matched area whose length is greater than a preset byte; expanding the fully matched area to obtain a new data extension area and an old data extension area; processing the new data area and the old data area to obtain the amount of space saved and the amount of additional data corresponding to the fully matched area after expansion; determining the approximate matching area corresponding to the fully matched area according to the comparison result of the amount of space saved and the amount of additional data; extracting the approximate matching area to obtain the target difference data between the original file and the target file, and storing the target difference data as a difference file. By implementing the technical solution of the present invention, the optimal approximate matching area can be dynamically determined, redundant data can be reduced, and the patch generation process can be optimized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software upgrade, and in particular to a method, device, equipment, storage medium and program product for generating a difference file. Background Art

[0002] Binary difference algorithms play an important role in the software upgrade process. Binary difference algorithms compare two versions of files and generate difference files or patch files that describe the differences between them. These difference files only contain the changed parts between the files. Compared with the complete new version files, the difference files are usually much smaller, which can reduce data transmission and storage overhead.

[0003] In order to generate a difference file, the current binary difference algorithm usually searches for similar parts between the original file and the target file, namely the matching area. In order to ensure the accuracy and completeness of the match, a fixed range is generally extended to both sides of the matching area. This method is blind and rough, which may lead to a large difference file size and affect the upgrade performance. Summary of the invention

[0004] In view of this, the present invention provides a method, apparatus, device, storage medium and program product for generating a difference file to solve the problem of excessive redundant data caused by fixed extension of a matching area.

[0005] In a first aspect, the present invention provides a method for generating a difference file, comprising: obtaining an original file and a target file; comparing the original file and the target file to find a completely matched area in the original file and the target file whose length is greater than a preset byte; wherein the completely matched area is a continuous byte sequence existing in both the original file and the target file, and has the same content and length; extending the completely matched areas in the original file and the target file to obtain a new data extended area after the expansion of the completely matched area in the target file and an old data extended area after the expansion of the completely matched area in the original file; processing the new data extended area and the old data extended area to obtain the corresponding amount of space saved and the amount of additional data after the expansion of the completely matched area; determining the approximate matching area corresponding to the completely matched area in the original file and the target file according to the comparison result of the amount of space saved and the amount of additional data; wherein the approximate matching area is used to characterize an area that is partially similar or approximately similar between the original file and the target file; extracting the approximate matching area to obtain target difference data between the original file and the target file, and storing the target difference data as a difference file.

[0006] The method for generating a difference file provided by the embodiment of the present invention can accurately determine the fully matched area in the original file and the target file, and expand it so as to better capture the similarity between the files, thereby ensuring the accuracy and integrity of the difference file. By searching for a fully matched area with a length greater than a preset byte in the original file and the target file and expanding it, the efficiency of generating the difference file can be effectively improved, and the calculation and processing time can be reduced. The fully matched area in the original file and the target file is expanded to obtain a new data extension area and an old data extension area. The expansion process is dynamically performed according to the actual data content and length, which can ensure that as many similar areas as possible are covered while minimizing the generation of redundant data. The new data area and the old data area are processed to obtain the corresponding space saving amount and additional data amount after the fully matched area is expanded. By comparing the size of the space saving amount and the additional data amount, the optimal approximate matching area can be dynamically determined to minimize the size of the difference file, thereby optimizing the patch generation process. Extracting the target difference data between the original file and the target file according to the determined approximate matching area is performed according to the actual matching situation and the degree of difference, which can effectively reduce the storage of redundant data while retaining important difference information, thereby optimizing the generation process of the difference file.

[0007] In an optional embodiment, the complete match area includes a first complete match area corresponding to the target file and a second complete match area corresponding to the original file; the complete match areas in the original file and the target file are expanded to obtain a new data extension area after the complete match area in the target file is expanded and an old data extension area after the complete match area in the original file is expanded, including: starting from the complete match area, gradually expanding forward and backward according to a preset step size until reaching the boundary of the adjacent complete match area; determining the area in the target file that is gradually expanded starting from the first complete match area as the new data extension area; determining the area in the original file that is gradually expanded starting from the second complete match area as the old data extension area.

[0008] The method for generating a difference file provided by the embodiment of the present invention ensures accurate identification and expansion of similar areas by gradually expanding the area based on the complete matching area according to a preset step length, so that the expanded area can cover similar contents in the target file and the original file as much as possible. By expanding the complete matching area, a larger range of similar areas can be identified, thereby improving the efficiency and accuracy of matching, and helping to reduce the amount of redundant data in subsequent processing steps. By using a preset step length for expansion, the scope of expansion can be flexibly adjusted according to actual conditions, thereby better adapting to the characteristics of different files and improving the applicability and adjustability of the algorithm.

[0009] In an optional embodiment, the new data extension area and the old data extension area are processed to obtain the amount of space saved and the amount of additional data corresponding to the expansion of the fully matched area, including: compressing the first data corresponding to the new data extension area according to a preset compression algorithm to obtain a first length of the compressed first data; determining the first length as the corresponding benefit each time the expansion is performed based on the fully matched area; the benefit is used to characterize the amount of space saved by expanding the matching area; subtracting the second data corresponding to the new data extension area and the first fully matched area and the third data corresponding to the old data extension area and the second fully matched area byte by byte to obtain the difference between the second data and the third data; compressing the difference according to the compression algorithm to obtain a second length after the difference is compressed; determining the second length as the corresponding cost each time the expansion is performed based on the fully matched area; the cost is used to characterize the amount of additional data generated each time the expansion is performed based on the fully matched area.

[0010] The method for generating a differential file provided by an embodiment of the present invention effectively reduces the storage space of data by compressing the new data extension area with a preset compression algorithm, thereby saving storage resources. By estimating the length of the first data after compression and using it as the benefit during expansion, the amount of space saved by expanding the matching area can be quantitatively characterized, which helps to evaluate the economic benefits of the expansion operation. By compressing the difference, the difference between the new data extension area and the old data extension area is effectively reduced, thereby reducing the amount of additional data generated, which helps to reduce data transmission and storage costs. By estimating the length of the difference after compression and using it as the cost of each expansion operation, the amount of additional data generated by each expansion operation can be quantitatively characterized, which helps to control the cost of the expansion operation.

[0011] In an optional implementation, the compression algorithm is the LZ4 compression algorithm.

[0012] The method for generating a differential file provided by an embodiment of the present invention, the LZ4 compression algorithm has the characteristics of fast compression speed and low latency, and consumes relatively few computing resources during the compression and decompression process, so it has significant advantages in processing data expansion and saving space.

[0013] In an optional embodiment, when the amount of space saved is less than the amount of additional data, the approximate matching area corresponding to the complete matching area in the original file and the target file is determined, including: stopping the expansion of the current matching area; wherein the current matching area is the area currently expanded based on the complete matching area; and determining the current matching area as the approximate matching area.

[0014] The method for generating a differential file provided by an embodiment of the present invention can avoid unnecessary calculations and processing by stopping the expansion of the current matching area when the amount of space saved is less than the amount of additional data, thereby saving computing resources and improving efficiency. Avoiding additional expansion of unnecessary data areas effectively reduces data redundancy and unnecessary increase in data volume, which helps to improve the efficiency of data storage and transmission. By accurately determining the approximate matching area, it can be ensured that while saving space, the data integrity of the original file and the target file will not be affected, thereby improving the reliability of data processing. The method of dynamically determining the matching area based on the comparison of the amount of space saved and the amount of additional data makes the algorithm more flexible and adaptive, and can be optimized according to different data characteristics and requirements.

[0015] In an optional embodiment, when the amount of space saved is greater than the amount of additional data, the approximate matching area corresponding to the complete matching area in the original file and the target file is determined, including: accepting the expansion of the current matching area, and continuing the next expansion until the amount of space saved corresponding to the expansion of the current matching area is less than the amount of additional data; stopping the expansion of the target matching area; wherein the target matching area is the area after expansion based on the complete matching area corresponding to the amount of space saved being less than the amount of additional data; and determining the target matching area as the approximate matching area.

[0016] The method for generating a difference file provided by an embodiment of the present invention can maximize the use of complete matching information and achieve effective data compression and space saving by accepting the expansion of the current matching area until the corresponding amount of space saved is less than the amount of additional data. In the process of expanding the current matching area, the consistency of the target matching area and the corresponding area in the original file is maintained, ensuring the integrity and accuracy of the data. By stopping the expansion of the target matching area, unnecessary data duplication and redundancy are avoided, the size of the compressed data is effectively reduced, and the efficiency of data storage and transmission is improved. By dynamically expanding and adjusting the matching area when the amount of space saved is greater than the amount of additional data, the performance and compression effect of the algorithm are optimized, making it more suitable for different data processing scenarios.

[0017] In an optional embodiment, the approximate matching area includes a first approximate matching area corresponding to the target file and a second approximate matching area corresponding to the original file; the approximate matching area is extracted to obtain difference data between the original file and the target file, including: byte by byte subtracting new matching data corresponding to the first approximate matching area from old matching data corresponding to the second approximate matching area to obtain first difference data; and data after compressing the first difference data is determined as target difference data between the original file and the target file.

[0018] The method for generating a difference file provided by an embodiment of the present invention extracts the approximate matching area and subtracts the new and old matching data byte by byte to obtain the first difference data, thereby ensuring accurate extraction of the difference between the original file and the target file. The first difference data is compressed and determined as difference data, which effectively reduces the size of the difference data and saves storage space and transmission bandwidth. By extracting and comparing the first approximate matching area and the second approximate matching area, the data consistency between the original file and the target file is ensured, and the reliability of data processing is improved.

[0019] In an optional implementation, the new matching data and the old matching data are compared, and the non-matching data between the new matching data and the old matching data are compressed to obtain second difference data; wherein the non-matching data is data that has no similarity between the new matching data and the old matching data; and the second difference data is determined as the target difference data between the original file and the target file.

[0020] The method for generating a difference file provided by an embodiment of the present invention can accurately determine the non-matching data between the new matching data and the old matching data, that is, the missing or changed parts, by comparing the new matching data and the old matching data, thereby ensuring the accuracy of the difference data. The non-matching data is compressed, effectively reducing the size of the difference data, saving storage space and transmission bandwidth, and improving the efficiency of data processing. By comparing the new and old matching data, the data consistency between the original file and the target file is ensured, the occurrence of errors and inconsistencies is avoided, and the reliability of data processing is improved. By extracting the non-matching data, the differences between the original file and the target file, including the newly added, deleted and modified parts, can be fully captured, thereby ensuring the comprehensiveness and accuracy of data processing.

[0021] In a second aspect, the present invention provides a device for generating a difference file, comprising: an acquisition module, used to acquire an original file and a target file; a comparison module, used to compare the original file and the target file to find a completely matched area in the original file and the target file whose length is greater than a preset byte; wherein the completely matched area is a continuous byte sequence existing in both the original file and the target file, and has the same content and length; an extension module, used to extend the completely matched areas in the original file and the target file to obtain a new data extension area after the completely matched area in the target file is extended and an old data extension area after the completely matched area in the original file is extended; a processing module, used to process the new data extension area and the old data extension area to obtain the corresponding space saving amount and additional data amount after the completely matched area is extended; a determination module, used to determine the approximate matching area corresponding to the completely matched area in the original file and the target file according to the comparison result of the space saving amount and the additional data amount; wherein the approximate matching area is used to characterize an area that is partially similar or approximately similar between the original file and the target file; a storage module, used to extract the approximate matching area, obtain the target difference data between the original file and the target file, and store the target difference data as a difference file.

[0022] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the method for generating a difference file of the above-mentioned first aspect or any corresponding embodiment thereof by executing the computer instructions.

[0023] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for generating a difference file according to the first aspect or any corresponding embodiment thereof.

[0024] In a fifth aspect, the present invention provides a computer program product, including computer instructions, wherein the computer instructions are used to enable a computer to execute the method for generating a difference file according to the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0026] Figure 1 is a schematic flow chart of a method for generating a difference file according to an embodiment of the present invention;

[0027] Figure 2 is a schematic diagram of an approximate matching area according to an embodiment of the present invention;

[0028] Figure 3 is a flow chart of another method for generating a difference file according to an embodiment of the present invention;

[0029] Figure 4 is a flow chart of another method for generating a difference file according to an embodiment of the present invention;

[0030] Figure 5 is a structural block diagram of a device for generating a difference file according to an embodiment of the present invention;

[0031] Figure 6 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0032] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0033] In the software upgrade process, the binary difference algorithm plays a vital role in generating difference files, thereby reducing data transmission and storage overhead. However, the existing BsDiff algorithm has some limitations, mainly in the way of fixedly extending the 50% matching area, which may lead to blindness and roughness, thus affecting the size of the generated difference files and the upgrade performance.

[0034] Specifically, the method of fixedly expanding the matching area by 50% may lead to excessive expansion of the matching area, resulting in a larger difference file size, which increases the data transmission and storage overhead. A large difference file size will increase the transmission time and storage requirements during the upgrade process, thereby affecting the upgrade performance, especially when the network bandwidth is limited or the storage resources are tight.

[0035] In view of this, the technical solution of the present invention generates a smaller difference file through an adaptive expansion matching mechanism. Compared with the existing BsDiff algorithm, the difference file size is reduced by about 10% on average. This solution uses a gradual expansion based on the percentage of the length of the complete matching area and a cost-benefit estimation based on a preset compression algorithm to dynamically determine the optimal approximate matching area, reduce redundant data, and optimize the patch generation process.

[0036] According to an embodiment of the present invention, an embodiment of a method for generating a difference file is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0037] In this embodiment, a method for generating a difference file is provided, which can be used in computer devices, such as laptop computers, desktop computers, etc. Figure 1 is a flow chart of a method for generating a difference file according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:

[0038] Step S101, obtaining an original file and a target file.

[0039] The original file is used to represent the file before the version upgrade or the baseline version file. It is the file that already exists before the software upgrade and is the starting point for comparison and upgrade. Specifically, the original file can be an old version file that has been deployed on a computer device, or a baseline file stored in a server or version control system, which is not limited here. When performing a software upgrade, you need to first obtain the original file from an appropriate source.

[0040] The target file is used to represent the file after the version upgrade or the new version of the file. It is a file generated after the upgrade operation. It may be different from the original file, and these differences need to be determined through comparative analysis. Specifically, the target file is a new version file generated after the software upgrade or update operation. It can be a file processed by developers or automated tools, or an update file obtained from a software vendor or other trusted source, and there is no limitation here.

[0041] Step S102, comparing the original file and the target file to find a completely matching region in the original file and the target file whose length is greater than a preset byte; wherein the completely matching region is a continuous byte sequence existing in both the original file and the target file, and has the same content and length.

[0042] The preset byte length is a threshold set according to specific needs or algorithms, and is used to filter out larger matching areas, such as 10 bytes. Specifically, the contents of the original file and the target file are compared byte by byte or line by line to determine the differences between them. During the comparison process, check whether there are completely matching areas in the original file and the target file. A completely matching area refers to a continuous byte sequence that exists in both files, and the content and length of these byte sequences are exactly the same. Determine whether the length of these matching areas is greater than the preset byte length. When a completely matching area that meets the conditions is found, it needs to be marked or recorded, such as recording the starting position, end position and length of the matching area for subsequent processing or analysis.

[0043] Step S103, expanding the completely matched areas in the original file and the target file to obtain a new data extension area after the completely matched area in the target file is expanded and an old data extension area after the completely matched area in the original file is expanded.

[0044] The fully matched area is extended to generate a new data area, which includes the content of the fully matched area and extends a byte sequence of a certain length on both sides. Specifically, for the fully matched area in the target file, additional byte sequences will be added on both sides of the matched area to obtain more new data related to the matched area, and this extended area is the new data extended area in the target file. Similarly, for the fully matched area in the original file, additional byte sequences will be added on both sides of the matched area to obtain old data related to the matched area, and this extended area is the old data extended area in the original file. The extended areas in the obtained target file and the original file can be marked or recorded, which will help with subsequent analysis or processing. For example, during file synchronization or software upgrades, special processing measures can be taken for these extended areas.

[0045] Step S104, processing the new data extension area and the old data extension area to obtain the corresponding amount of space saved and the amount of additional data after the complete matching area is expanded.

[0046] The space saving amount is the space saving amount in the target file due to the reuse of the data in the old data extension area. Specifically, the space saving amount can be the size of the old data extension area of ​​the original file. Since this part of data already exists in the target file, there is no need to store it again.

[0047] The extra data volume is the size of the newly added new data extension area and the reused old data extension area, that is, the amount of data that needs to be additionally stored in the target file. Specifically, the extra data volume can be the size of the new data extension area in the target file minus the size of the old data extension area in the original file.

[0048] Step S105, determining the approximate matching area corresponding to the complete matching area in the original file and the target file according to the comparison result of the space saving amount and the additional data amount; wherein the approximate matching area is used to represent an area that is partially similar or approximately similar between the original file and the target file.

[0049] Compare the amount of space saved and the amount of additional data. Specifically, if the amount of space saved is large, it indicates that there are a large number of similar parts in the original file and the target file. If the amount of additional data is large, it indicates that there may be more incomplete matches or dissimilar parts in the original file and the target file.

[0050] According to the comparison results, the approximate matching areas corresponding to the complete matching areas in the original file and the target file are determined, such as Figure 2 As shown, area A is used to represent the original file data, area B is used to represent the target file data, the black area C is used to represent the complete matching area, the white area E on the left is used to represent the forward extending area, and the white area F on the right is used to represent the backward extending area. Areas C, E and F constitute an approximate matching area D.

[0051] Specifically, if the amount of space saved is large, it can be considered that the data near the fully matched area is also similar, and these data constitute the approximate matching area. If the amount of additional data is large, it means that the data after the expansion of the fully matched area in the target file does not occupy a large proportion, and there may be more incomplete matches or dissimilar parts. By analyzing the data around the fully matched area, the similar area can be determined as the approximate matching area.

[0052] Step S106: extract the approximate matching area to obtain target difference data between the original file and the target file, and store the target difference data as a difference file.

[0053] The target difference data is the difference content between the original file and the target file, including added, deleted or modified parts. The difference file contains the difference information between the original file and the target file so that comparison, merging or rollback operations can be performed when necessary. Specifically, based on the determined approximate matching areas, difference data is extracted from the original file and the target file, which represents the changes between the files. The extraction process may involve copying or extracting the corresponding area from the file for further processing. The extracted difference area is marked to indicate its specific difference type. This may include marking different types of operations such as addition, deletion, replacement, etc. for subsequent processing and analysis. The extracted and marked difference data is stored as a difference file for further processing or distribution to better understand the changes between the original file and the target file and effectively manage them in scenarios such as version control, backup and recovery.

[0054] The method for generating a difference file provided by the embodiment of the present invention can accurately determine the fully matched area in the original file and the target file, and expand it so as to better capture the similarity between the files, thereby ensuring the accuracy and integrity of the difference file. By searching for a fully matched area with a length greater than a preset byte in the original file and the target file and expanding it, the efficiency of generating the difference file can be effectively improved, and the calculation and processing time can be reduced. The fully matched area in the original file and the target file is expanded to obtain a new data extension area and an old data extension area. The expansion process is dynamically performed according to the actual data content and length, which can ensure that as many similar areas as possible are covered while minimizing the generation of redundant data. The new data area and the old data area are processed to obtain the corresponding space saving amount and additional data amount after the fully matched area is expanded. By comparing the size of the space saving amount and the additional data amount, the optimal approximate matching area can be dynamically determined to minimize the size of the difference file, thereby optimizing the patch generation process. Extracting the target difference data between the original file and the target file according to the determined approximate matching area is performed according to the actual matching situation and the degree of difference, which can effectively reduce the storage of redundant data while retaining important difference information, thereby optimizing the generation process of the difference file.

[0055] In this embodiment, a method for generating a difference file is provided, which can be used in computer devices, such as laptop computers, desktop computers, etc. Figure 3 is a flow chart of a method for generating a difference file according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:

[0056] Step S201, obtain the original file and the target file. Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.

[0057] Step S202, compare the original file and the target file to find a completely matching region in the original file and the target file whose length is greater than a preset byte; wherein the completely matching region is a continuous byte sequence existing in both the original file and the target file, and the content and length are consistent. For details, please refer to Figure 1 Step S102 of the illustrated embodiment will not be described in detail here.

[0058] Step S203, the completely matched regions in the original file and the target file are extended to obtain a new data extended region after the completely matched region in the target file is extended and an old data extended region after the completely matched region in the original file is extended.

[0059] Specifically, the complete matching region includes a first complete matching region corresponding to the target file and a second complete matching region corresponding to the original file. The above step S203 includes:

[0060] Step S2031 , starting from the complete matching region, and gradually expanding forward and backward according to a preset step length until reaching the boundary of an adjacent complete matching region.

[0061] For each fully matched area, obtain the starting position and length of the fully matched area. According to the preset step size rule, calculate the expansion step size corresponding to each fully matched area. For example, it can be 10% of the length of the fully matched area, but if it is less than 10 bytes, it is calculated as 10 bytes. Specifically, if the matching area is extended forward, it is extended step by step from the starting position of the fully matched area forward. In each step, check whether the next byte or character still matches. If it matches, continue to expand; if it does not match, stop expanding because the boundary of the adjacent match has been reached. If the matching area is extended backward, it is extended step by step from the end of the fully matched area backward. Similarly, in each step, check whether the next byte or character still matches. If it matches, continue to expand; if it does not match, stop expanding because the boundary of the adjacent match has been reached.

[0062] Step S2032, determining the area in the target file that is gradually expanded starting from the first complete matching area as the new data extension area; determining the area in the original file that is gradually expanded starting from the second complete matching area as the old data extension area.

[0063] The first fully matching regions are each fully matching region in the target file. Specifically, each first fully matching region in the target file is used as a starting point and is gradually extended forward and backward according to a preset step length. The extended region is determined as a new data extension region.

[0064] The second fully matching area is each fully matching area in the original file. Specifically, each second fully matching area in the original file is used as a starting point and is gradually extended forward and backward according to the same steps. The extended area is determined as the old data extension area.

[0065] The method for generating a difference file provided by the embodiment of the present invention ensures accurate identification and expansion of similar areas by gradually expanding the area based on the complete matching area according to a preset step length, so that the expanded area can cover similar contents in the target file and the original file as much as possible. By expanding the complete matching area, a larger range of similar areas can be identified, thereby improving the efficiency and accuracy of matching, and helping to reduce the amount of redundant data in subsequent processing steps. By using a preset step length for expansion, the scope of expansion can be flexibly adjusted according to actual conditions, thereby better adapting to the characteristics of different files and improving the applicability and adjustability of the algorithm.

[0066] Step S204: Process the new data extension area and the old data extension area to obtain the amount of space saved and the amount of additional data corresponding to the expansion of the fully matched area.

[0067] Specifically, the above step S204 includes:

[0068] Step S2041, compressing the first data corresponding to the new data extension area according to a preset compression algorithm to obtain a first length of the compressed first data.

[0069] The first data is all the data in the expanded new data area. Specifically, according to a preset compression algorithm, all the data in the entire new data expansion area is compressed, that is, the data in the entire new data area is converted into a form processed by the compression algorithm to reduce the space occupied by it in storage or transmission. After applying the compression algorithm to all the data in the new data expansion area, a compressed result, that is, a compressed first length, is obtained, and this result can be used to evaluate the compression effect.

[0070] The preset compression algorithm is a method for encoding data into a more compact representation, including Huffman coding, Lempel-Ziv compression algorithm, etc. The compression algorithm can eliminate redundant information according to the characteristics and repetitiveness of the data, thereby reducing the size of the data. Specifically, the preset compression algorithm can be the LZ4 compression algorithm.

[0071] Step S2042: determine the first length as the corresponding benefit each time the expansion is performed based on the complete matching region; the benefit is used to represent the amount of space saved by expanding the matching region.

[0072] Gain is a quantitative indicator used to represent the amount of space saved by expanding the matching area. Each time the matching area is expanded, a corresponding gain is obtained to evaluate the contribution of the expanded matching area to the overall compression effect. Specifically, the first length after compression is determined as the gain obtained each time the expansion is performed based on the fully matched area, that is, by expanding the matching area, the amount of space equivalent to the length of the first data after compression can be saved.

[0073] Step S2043: Subtract byte by byte the second data corresponding to the new data extension area and the first complete matching area and the third data corresponding to the old data extension area and the second complete matching area to obtain a difference between the second data and the third data.

[0074] The second data is all the data in the new data extension area and the first completely matching area. The third data is all the data in the old data extension area and the second completely matching area. Specifically, the second data and the third data are subtracted byte by byte, that is, a subtraction operation is performed on each byte of them. The result obtained by subtracting the byte of the third data at the corresponding position from each byte of the second data is the difference between the second data and the third data.

[0075] Step S2044, compress the difference according to a compression algorithm to obtain a second length of the compressed difference.

[0076] The second length is the length obtained after the difference is compressed. Specifically, the obtained difference is compressed by applying a compression algorithm, that is, it is encoded into a more compact form. This process will eliminate the redundant information in the difference or encode it into a more concise representation according to the specific implementation of the compression algorithm. After being processed by the compression algorithm, the obtained difference will become more compact and its length will be reduced accordingly. This compressed length is the second length after the difference is compressed.

[0077] Step S2045: determine the second length as the cost corresponding to each expansion based on the complete matching region; the cost is used to characterize the amount of additional data generated each time the expansion is performed based on the complete matching region.

[0078] The cost is used to measure the amount of additional data generated when performing an expansion operation based on a fully matched region. By associating the cost with the length of the compressed difference, the efficiency and performance of the expansion operation can be better evaluated. Specifically, the length of the compressed difference is set as the cost corresponding to each expansion operation based on a fully matched region, that is, when performing an expansion operation, the length of the compressed difference needs to be considered as the cost indicator of the operation.

[0079] Step S205: Determine the approximate matching area corresponding to the complete matching area in the original file and the target file according to the comparison result of the amount of space saved and the amount of additional data; wherein the approximate matching area is used to represent the area that is partially similar or approximately similar between the original file and the target file. Figure 1 Step S105 of the illustrated embodiment will not be described in detail here.

[0080] Step S206: extract the approximate matching area to obtain target difference data between the original file and the target file, and store the target difference data as a difference file. Figure 1 Step S106 of the illustrated embodiment will not be described in detail here.

[0081] The method for generating a differential file provided by an embodiment of the present invention effectively reduces the storage space of data by compressing the new data extension area with a preset compression algorithm, thereby saving storage resources. By estimating the length of the first data after compression and using it as the benefit during expansion, the amount of space saved by expanding the matching area can be quantitatively characterized, which helps to evaluate the economic benefits of the expansion operation. By compressing the difference, the difference between the new data extension area and the old data extension area is effectively reduced, thereby reducing the amount of additional data generated, which helps to reduce data transmission and storage costs. By estimating the length of the difference after compression and using it as the cost of each expansion operation, the amount of additional data generated by each expansion operation can be quantitatively characterized, which helps to control the cost of the expansion operation.

[0082] In this embodiment, a method for generating a difference file is provided, which can be used in computer devices, such as laptop computers, desktop computers, etc. Figure 4 is a flow chart of a method for generating a difference file according to an embodiment of the present invention. Figure 4 As shown, the process includes the following steps:

[0083] Step S301, obtain the original file and the target file. Figure 3 Step S201 of the illustrated embodiment will not be described in detail here.

[0084] Step S302, compare the original file and the target file to find a completely matching region in the original file and the target file whose length is greater than a preset byte; wherein the completely matching region is a continuous byte sequence existing in both the original file and the target file, and the content and length are consistent. For details, please refer to Figure 3 Step S202 of the illustrated embodiment will not be described in detail here.

[0085] Step S303, expand the completely matched area in the original file and the target file to obtain the new data extension area after the completely matched area in the target file is expanded and the old data extension area after the completely matched area in the original file is expanded. Figure 3 Step S203 of the illustrated embodiment will not be described in detail here.

[0086] Step S304: Process the new data extension area and the old data extension area to obtain the corresponding amount of space saved and the amount of additional data after the complete matching area is expanded. Figure 3Step S204 of the illustrated embodiment will not be described in detail here.

[0087] Step S305, determining the approximate matching area corresponding to the complete matching area in the original file and the target file according to the comparison result of the space saving amount and the additional data amount; wherein the approximate matching area is used to represent an area that is partially similar or approximately similar between the original file and the target file.

[0088] In some optional implementations, when the amount of space saved is less than the amount of additional data, the above step S305 includes:

[0089] Step a1, stop expanding the current matching area; wherein the current matching area is the area expanded based on the current complete matching area.

[0090] When the amount of space saved is less than the amount of additional data, it means that the amount of space saved by expanding the current matching area is not enough to offset the amount of additional data generated by the expansion operation. In data processing, the expansion operation usually brings additional data because the expanded matching area may be larger than the original area. If the amount of space saved (that is, the storage space saved by the expansion operation) is less than the amount of additional data (the amount of additional data generated by the expansion operation), it means that the expansion operation will increase the total size of the data instead of reducing it.

[0091] The current matching region refers to the result obtained in the previous expansion operation based on the complete matching region. In this process, a larger matching region is obtained by expanding the complete matching region. Specifically, when the amount of space saved is less than the amount of additional data, the expansion of the current matching region is stopped. Because the expansion operation is not economical, continuing to expand will only increase the size of the data without bringing enough space savings.

[0092] Step a2: determine the current matching area as an approximate matching area.

[0093] After the expansion stops, the current matching area is determined as the approximate matching area.

[0094] For example, when the third data is 746517004abcdefghijklmnopqr919487084 and the second data is 999999999abcdefghijklmnopqr999999999, the complete matching area is abcdefghijklmnopq. The difference between the second and third data is 25348299500000000000000000000080512915. The extended area is poorly compressible, while the second data (new data of the target file) is more compressible. In this case, it is better not to expand because there is no positive benefit after expansion.

[0095] In the above implementation, by stopping the expansion of the current matching area when the amount of space saved is less than the amount of additional data, unnecessary calculations and processing can be avoided, thereby saving computing resources and improving efficiency. Avoiding additional expansion of unnecessary data areas effectively reduces data redundancy and unnecessary increase in data volume, which helps to improve the efficiency of data storage and transmission. By accurately determining the approximate matching area, it can be ensured that while saving space, the data integrity of the original file and the target file will not be affected, thereby improving the reliability of data processing. The method of dynamically determining the matching area based on the comparison of the amount of space saved and the amount of additional data makes the algorithm more flexible and adaptive, and can be optimized according to different data characteristics and requirements.

[0096] In some optional implementations, when the amount of space saved is greater than the amount of additional data, the above step S305 further includes:

[0097] Step b1, accepting the expansion of the current matching area, and continuing the next expansion until the amount of space saved corresponding to the expansion of the current matching area is less than the amount of additional data.

[0098] When the amount of space saved after the expansion operation is greater than the amount of additional data generated, it means that the expansion operation is cost-effective because more space can be saved through expansion. In this case, the expansion of the current matching area is accepted and the next expansion operation is continued.

[0099] Step b2, stop expanding the target matching area; wherein the target matching area is the area expanded based on the complete matching area corresponding to when the amount of saved space is less than the amount of additional data.

[0100] When the amount of space saved after expansion is less than the amount of additional data, that is, when the expansion operation is no longer cost-effective, the expansion of the target matching area is stopped. The target matching area is obtained in the previous expansion operation, and the amount of space saved after expansion is less than the amount of additional data.

[0101] Step b3: determine the target matching area as the approximate matching area.

[0102] The target matching area where the expansion stops is determined as the approximate matching area, that is, the area is accepted as the final approximate matching result.

[0103] For example, when the third data is 012345678abcdefghijklmnopqr123456789 and the second data is 123456789abcdefghijklmnopqr012345678, the complete matching area is abcdefghijklmnopq. The difference between the second data and the third data is 1111111110000000000000000000111111111, that is, the difference is highly compressible, so this case has a positive return.

[0104] In the above implementation, by accepting the expansion of the current matching area until the corresponding amount of space saved is less than the amount of additional data, the full matching information can be maximized to achieve effective data compression and space saving. In the process of expanding the current matching area, the consistency of the target matching area and the corresponding area in the original file is maintained, ensuring the integrity and accuracy of the data. By stopping the expansion of the target matching area, unnecessary data duplication and redundancy are avoided, the size of the compressed data is effectively reduced, and the efficiency of data storage and transmission is improved. By dynamically expanding and adjusting the matching area when the amount of space saved is greater than the amount of additional data, the performance and compression effect of the algorithm are optimized, making it more suitable for different data processing scenarios.

[0105] Step S306: extract the approximate matching area to obtain target difference data between the original file and the target file, and store the target difference data as a difference file.

[0106] Specifically, the approximate matching area includes a first approximate matching area corresponding to the target file and a second approximate matching area corresponding to the original file. The above step S306 includes:

[0107] Step S3061 : Subtract the new matching data corresponding to the first approximate matching area and the old matching data corresponding to the second approximate matching area byte by byte to obtain first difference data.

[0108] The first approximate matching area is the approximate matching area corresponding to the target file. The second approximate matching area is the approximate matching area corresponding to the original file. Specifically, the new matching data corresponding to the first approximate matching area is subtracted byte by byte from the old matching data corresponding to the second approximate matching area, that is, the bytes at the corresponding positions are subtracted to obtain the first difference data.

[0109] Step S3062: Determine the data obtained by compressing the first difference data as the target difference data between the original file and the target file.

[0110] The first difference data is compressed to obtain compressed data, so as to reduce the volume of the first difference data and make it easier to store and transmit. The data after the first difference data is compressed is the target difference data between the original file and the target file.

[0111] Step S3063, comparing the new matching data with the old matching data, compressing the non-matching data between the new matching data and the old matching data, and obtaining second difference data; wherein the non-matching data is data having no similarity between the new matching data and the old matching data.

[0112] After comparing the new and old matching data, find out the parts that have no similarity between the new matching data and the old matching data, that is, non-matching data. These non-matching data represent the modified, added or deleted content between the new and old versions. Compress these non-matching data to obtain second difference data. The second difference data contains the difference information of the non-matching parts between the original file and the target file.

[0113] Step S3064: determine the second difference data as target difference data between the original file and the target file.

[0114] The second difference data is determined as target difference data between the target file and the original file.

[0115] The method for generating a difference file provided by an embodiment of the present invention extracts the approximate matching area and subtracts the new and old matching data byte by byte to obtain the first difference data, thereby ensuring the accurate extraction of the difference between the original file and the target file. The first difference data is compressed and determined as the difference data, which effectively reduces the size of the difference data and saves storage space and transmission bandwidth. By extracting and comparing the first approximate matching area and the second approximate matching area, the data consistency between the original file and the target file is ensured, and the reliability of data processing is improved. By comparing the new matching data and the old matching data, the non-matching data between the two, that is, the missing or changed part, can be accurately determined, ensuring the accuracy of the difference data. Compressing the non-matching data effectively reduces the size of the difference data, saves storage space and transmission bandwidth, and improves the efficiency of data processing. By comparing the new and old matching data, the data consistency between the original file and the target file is ensured, the occurrence of errors and inconsistencies is avoided, and the reliability of data processing is improved. By extracting the non-matching data, the differences between the original file and the target file, including the newly added, deleted and modified parts, can be fully captured, ensuring the comprehensiveness and accuracy of data processing.

[0116] In this embodiment, a device for generating a difference file is also provided, and the device is used to implement the above-mentioned embodiment and preferred implementation mode, and the descriptions that have been made are not repeated here. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceivable.

[0117] This embodiment provides a device for generating a difference file, such as Figure 5 As shown, including:

[0118] The acquisition module 501 is used to acquire the original file and the target file.

[0119] The comparison module 502 is used to compare the original file and the target file to find a completely matched region in the original file and the target file whose length is greater than a preset byte; wherein the completely matched region is a continuous byte sequence existing in both the original file and the target file, and has the same content and length.

[0120] The expansion module 503 is used to expand the completely matched areas in the original file and the target file to obtain a new data extension area after the completely matched area in the target file is expanded and an old data extension area after the completely matched area in the original file is expanded.

[0121] The processing module 504 is used to process the new data extension area and the old data extension area to obtain the corresponding amount of space saving and additional data after the full matching area is expanded.

[0122] The determination module 505 is used to determine the approximate matching area corresponding to the complete matching area in the original file and the target file according to the comparison result of the amount of space saved and the amount of additional data; wherein the approximate matching area is used to represent the area with partial similarity or approximate similarity between the original file and the target file.

[0123] The storage module 506 is used to extract the approximate matching area, obtain the target difference data between the original file and the target file, and store the target difference data as a difference file.

[0124] In some optional implementations, the complete matching region includes a first complete matching region corresponding to the target file and a second complete matching region corresponding to the original file. The expansion module 503 includes:

[0125] The expansion submodule is used to take the complete matching area as the starting point and gradually expand forward and backward according to a preset step size until reaching the boundary of the adjacent complete matching area.

[0126] The first determination submodule is used to determine the area in the target file that is gradually expanded starting from the first complete matching area as the new data extension area, and to determine the area in the original file that is gradually expanded starting from the second complete matching area as the old data extension area.

[0127] In some optional implementations, the processing module 504 includes:

[0128] The first compression submodule is used to compress the first data corresponding to the new data extension area according to a preset compression algorithm to obtain a first length of the compressed first data.

[0129] The second determining submodule is used to determine the first length as the corresponding benefit when the expansion is performed each time based on the completely matched region. The benefit is used to represent the amount of space saved by expanding the matched region.

[0130] The first calculation submodule is used to perform byte-by-byte subtraction of the second data corresponding to the new data extension area and the first complete matching area and the third data corresponding to the old data extension area and the second complete matching area to obtain a difference between the second data and the third data.

[0131] The second compression submodule is used to compress the difference according to the compression algorithm to obtain a second length of the compressed difference.

[0132] The third determination submodule is used to determine the second length as a corresponding cost each time the expansion is performed based on the complete matching region. The cost is used to characterize the amount of additional data generated each time the expansion is performed based on the complete matching region.

[0133] In some optional implementations, when the amount of space saved is less than the amount of additional data, the determination module 505 includes:

[0134] The first stop submodule is used to stop the expansion of the current matching area, wherein the current matching area is the area expanded based on the current complete matching area.

[0135] The fourth determining submodule is used to determine the current matching area as an approximate matching area.

[0136] In some optional implementations, when the amount of space saved is greater than the amount of additional data, the determination module 505 includes:

[0137] The accepting submodule is used to accept the expansion of the current matching area and continue the next expansion until the amount of space saved corresponding to the expansion of the current matching area is less than the amount of additional data.

[0138] The second stop submodule is used to stop the expansion of the target matching area, wherein the target matching area is the area expanded based on the complete matching area corresponding to when the amount of saved space is less than the amount of additional data.

[0139] The fifth determining submodule is used to determine the target matching area as an approximate matching area.

[0140] In some optional implementations, the approximate matching region includes a first approximate matching region corresponding to the target file and a second approximate matching region corresponding to the original file. The storage module 506 includes:

[0141] The second calculation submodule is used to perform byte-by-byte subtraction of the new matching data corresponding to the first approximate matching area and the old matching data corresponding to the second approximate matching area to obtain first difference data.

[0142] The sixth determining submodule is used to determine the data obtained by compressing the first difference data as the target difference data between the original file and the target file.

[0143] The comparison submodule is used to compare the new matching data with the old matching data, and compress the non-matching data between the new matching data and the old matching data to obtain the second difference data, wherein the non-matching data is data that has no similarity between the new matching data and the old matching data.

[0144] The seventh determining submodule is used to determine the second difference data as target difference data between the original file and the target file.

[0145] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0146] The difference file generation device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0147] The difference file generation device provided by the embodiment of the present invention can accurately determine the complete matching area in the original file and the target file, and expand it to better capture the similarity between the files, thereby ensuring the accuracy and integrity of the difference file. By searching for the complete matching area with a length greater than the preset bytes in the original file and the target file and expanding it, the efficiency of the difference file generation can be effectively improved and the calculation and processing time can be reduced. The complete matching area in the original file and the target file is expanded to obtain the new data extension area and the old data extension area. The expansion process is dynamically performed according to the actual data content and length, which can ensure that as many similar areas as possible are covered while minimizing the generation of redundant data. The new data area and the old data area are processed to obtain the corresponding space saving amount and additional data amount after the complete matching area is expanded. By comparing the size of the space saving amount and the additional data amount, the optimal approximate matching area can be dynamically determined to minimize the size of the difference file, thereby optimizing the patch generation process. Extracting the target difference data between the original file and the target file according to the determined approximate matching area is performed according to the actual matching situation and the degree of difference, which can effectively reduce the storage of redundant data while retaining important difference information, thereby optimizing the generation process of the difference file.

[0148] The embodiment of the present invention also provides a computer device having the above Figure 5 The device for generating the difference file shown.

[0149] See also Figure 6 , Figure 6 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 6 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 10 is taken as an example.

[0150] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0151] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.

[0152] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0153] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0154] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.

[0155] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the computer device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.

[0156] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0157] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.

[0158] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A method for generating a difference file, characterized in that: The method comprises: Get the original file and the target file; Comparing the original file with the target file to find a completely matching region in the original file and the target file whose length is greater than a preset byte; wherein the completely matching region is a continuous byte sequence existing in both the original file and the target file, and has the same content and length; Expanding the completely matching regions in the original file and the target file to obtain a new data extension region after the completely matching region in the target file is expanded and an old data extension region after the completely matching region in the original file is expanded; Processing the new data extension area and the old data extension area to obtain the amount of space saved and the amount of additional data corresponding to the expansion of the fully matched area, including: compressing the first data corresponding to the new data extension area according to a preset compression algorithm to obtain a first length of the compressed first data; determining the first length as the corresponding benefit each time the expansion is performed based on the fully matched area; the benefit is used to characterize the amount of space saved by expanding the matching area; subtracting the second data corresponding to the new data extension area and the first fully matched area and the third data corresponding to the old data extension area and the second fully matched area byte by byte to obtain the difference between the second data and the third data; compressing the difference according to the compression algorithm to obtain a second length of the compressed difference; determining the second length as the corresponding cost each time the expansion is performed based on the fully matched area; the cost is used to characterize the amount of additional data generated each time the expansion is performed based on the fully matched area; Determine, according to the comparison result of the space saving amount and the additional data amount, an approximate matching area corresponding to the complete matching area in the original file and the target file; wherein the approximate matching area is used to represent an area that is partially similar or approximately similar between the original file and the target file; Wherein, when the amount of space saved is greater than the amount of additional data, the determining of the approximate matching area corresponding to the fully matching area in the original file and the target file includes: accepting the expansion of the current matching area, and continuing the next expansion until the amount of space saved corresponding to the expansion of the current matching area is less than the amount of additional data; stopping the expansion of the target matching area; wherein the target matching area is the area corresponding to the expansion of the fully matching area when the amount of space saved is less than the amount of additional data; and determining the target matching area as the approximate matching area; The approximately matching area is extracted to obtain target difference data between the original file and the target file, and the target difference data is stored as a difference file.

2. The method according to claim 1, characterized in that The fully matched area includes a first fully matched area corresponding to the target file and a second fully matched area corresponding to the original file; the fully matched areas in the original file and the target file are extended to obtain a new data extended area after the fully matched area in the target file is extended and an old data extended area after the fully matched area in the original file is extended, including: Taking the fully matched region as a starting point, the image is gradually expanded forward and backward according to a preset step size until reaching the boundary of an adjacent fully matched region; The area in the target file that is gradually expanded starting from the first completely matching area is determined as the new data extension area; the area in the original file that is gradually expanded starting from the second completely matching area is determined as the old data extension area.

3. The method according to claim 1, characterized in that: The compression algorithm is the LZ4 compression algorithm.

4. The method according to claim 1, characterized in that When the amount of space saved is less than the amount of additional data, determining the approximate matching area corresponding to the complete matching area in the original file and the target file includes: Stop expanding the current matching area; wherein the current matching area is the area currently expanded based on the complete matching area; The current matching area is determined as the approximate matching area.

5. The method according to claim 1, characterized in that The approximate matching region includes a first approximate matching region corresponding to the target file and a second approximate matching region corresponding to the original file; extracting the approximate matching region to obtain target difference data between the original file and the target file includes: Subtracting the new matching data corresponding to the first approximately matching area from the old matching data corresponding to the second approximately matching area byte by byte to obtain first difference data; The data obtained by compressing the first difference data is determined as the target difference data between the original file and the target file.

6. The method according to claim 5, characterized in that The method further comprises: Comparing the new matching data with the old matching data, compressing the non-matching data between the new matching data and the old matching data, and obtaining second difference data; wherein the non-matching data is data having no similarity between the new matching data and the old matching data; The second difference data is determined as target difference data between the original file and the target file.

7. A device for generating a difference file, characterized in that: The device comprises: An acquisition module, used to acquire original files and target files; A comparison module, used for comparing the original file and the target file to find a completely matching region in the original file and the target file whose length is greater than a preset byte; wherein the completely matching region is a continuous byte sequence existing in both the original file and the target file, and has the same content and length; An extension module, used for extending the completely matching regions in the original file and the target file to obtain a new data extension region after the completely matching region in the target file is extended and an old data extension region after the completely matching region in the original file is extended; A processing module, used for processing the new data extension area and the old data extension area to obtain the amount of space saved and the amount of additional data corresponding to the expansion of the fully matched area, including: compressing the first data corresponding to the new data extension area according to a preset compression algorithm to obtain a first length of the compressed first data; determining the first length as the corresponding benefit each time the expansion is performed based on the fully matched area; the benefit is used to characterize the amount of space saved by expanding the matching area; subtracting the second data corresponding to the new data extension area and the first fully matched area and the third data corresponding to the old data extension area and the second fully matched area byte by byte to obtain the difference between the second data and the third data; compressing the difference according to the compression algorithm to obtain a second length of the compressed difference; determining the second length as the corresponding cost each time the expansion is performed based on the fully matched area; the cost is used to characterize the amount of additional data generated each time the expansion is performed based on the fully matched area; A determination module, for determining, based on a comparison result of the space saving amount and the additional data amount, an approximate matching area corresponding to the complete matching area in the original file and the target file; wherein the approximate matching area is used to characterize an area that is partially similar or approximately similar between the original file and the target file; wherein, when the space saving amount is greater than the additional data amount, determining the approximate matching area corresponding to the complete matching area in the original file and the target file comprises: accepting an extension of the current matching area, and continuing the next extension until the space saving amount corresponding to the extension of the current matching area is less than the additional data amount; stopping the extension of the target matching area; wherein the target matching area is an area corresponding to the extension of the complete matching area when the space saving amount is less than the additional data amount; and determining the target matching area as the approximate matching area; The storage module is used to extract the approximate matching area, obtain target difference data between the original file and the target file, and store the target difference data as a difference file.

8. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for generating a difference file according to any one of claims 1 to 6 by executing the computer instructions.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method for generating a difference file according to any one of claims 1 to 6.

10. A computer program product, characterized in that The method comprises computer instructions for causing a computer to execute the method for generating a difference file according to any one of claims 1 to 6.