Data compression method and device, electronic equipment, chip and medium
The sliding window is used to compare and segment the data to be compressed, which solves the problem of inconsistent coding of data segments caused by fixed-length segmentation in the existing technology, improves the efficiency of data compression, and saves storage space.
Patent Information
- Application Number
- CN202311149577.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-07
- Publication Date
- 2024-10-18
AI Technical Summary
In the existing technology, due to fixed-length segmentation and segment-by-segment comparison during file compression, data segment encoding is inconsistent during multiple compression processes, which reduces compression efficiency.
A sliding window is used to compare the data to be compressed to obtain a non-duplicate data set and a compressed trajectory table. By first comparing and then dividing, the non-duplicate data set and compressed trajectory table are determined as compressed data.
Improves the compression efficiency of multiple files and modified files, reduces the compression rate, and saves storage space.
Smart Images

Figure CN118801897A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing, and in particular to a data compression method, device, electronic device, chip and medium. Background Art
[0002] In the related art, data compression is to divide the data file into fixed lengths and then compare them segment by segment. For a single compression of a single file, during the modified data file or multiple compressions of multiple files, the compression rate is increased due to inconsistent encoding of most data segments, which ultimately reduces the efficiency of data compression. Summary of the invention
[0003] The present disclosure provides a data compression method, device, electronic device, chip and medium to solve the problem that the related art adopts fixed length segmentation and then compares each data segment in file compression, which leads to high compression rate and low compression efficiency in the process of multiple compression of modified data segments or multiple files. The present disclosure receives data to be compressed; compares the data to be compressed through a sliding window to obtain a non-repeating data set and a compression trajectory table; and determines the non-repeating data set and the compression trajectory table as compressed data. The compression rate is reduced and the compression efficiency is improved.
[0004] A first aspect of the present disclosure provides a data compression method, which is applied to a server. The method includes:
[0005] receiving data to be compressed;
[0006] Through the sliding window, the data to be compressed is compared to obtain a non-repetitive data set and a compression trajectory table;
[0007] A non-repetitive data set and a compression trace table are determined as compressed data.
[0008] In one embodiment of the present disclosure, data comparison is performed on the data to be compressed through a sliding window to obtain a non-repetitive data set and a compression trajectory table including:
[0009] Get the first sliding window length of the sliding window;
[0010] Get the first sliding step of the sliding window;
[0011] According to the first sliding window length and the first sliding step length, the sliding window is used to compare the data to be compressed to determine a non-repetitive data set and an index set.
[0012] A compression trajectory table is determined according to the data to be compressed and the index set.
[0013] In one embodiment of the present disclosure, according to the first sliding window length and the first sliding step length, using the sliding window to compare the data to be compressed to determine the non-repetitive data set and the index set includes:
[0014] Using a sliding window, obtaining a first data segment of the data to be compressed with a first sliding window length;
[0015] determining a first encoding value for a first data segment;
[0016] Using a sliding window, sequentially obtaining at least one second data segment with a first sliding window length;
[0017] determining a second encoding value for a second data segment;
[0018] According to the first encoding value and the second encoding value, the non-repetitive data set and / or the index set are updated.
[0019] In one embodiment of the present disclosure, updating a non-repetitive data set and / or an index set according to a first encoding value and a second encoding value includes:
[0020] Determine whether the first code value is equal to the second code value;
[0021] If the first encoding value is equal to the second encoding value, adding the first data segment to the non-repetitive data set, determining a first index value of the second data segment, and adding the first index value to the index set, wherein the first index value is an index of the first data segment in the non-repetitive data set;
[0022] If the first encoding value is not equal to the second encoding value, the sliding window continues to slide until a third data segment or the end of the data to be compressed is obtained, wherein the third encoding value of the third data segment is equal to the first encoding value, and the second index value of the third data segment is added to the index set;
[0023] Based on the data to be compressed, the first data segment, the second data segment and the third data segment, intermediate data is determined and compressed.
[0024] In one embodiment of the present disclosure, based on the data to be compressed, the first data segment, the second data segment, and the third data segment, determining the intermediate data, and compressing the intermediate data includes:
[0025] Based on the data to be compressed, the data segment between the first data segment and the fourth data segment is used as the intermediate data, and the fourth data segment is the second data segment or the third data segment;
[0026] Use sliding windows to compress intermediate data.
[0027] In one embodiment of the present disclosure, compressing the intermediate data according to the intermediate data and the sliding window includes:
[0028] Determine the length of the intermediate data and the length of the first sliding window;
[0029] If the length of the intermediate data is less than or equal to the first sliding window length, and the intermediate data does not exist in the non-repetitive data set, then the intermediate data is appended to the non-repetitive data set, or
[0030] If the length of the intermediate data is less than or equal to the first sliding window length, and the intermediate data exists in the non-repetitive data set, then create an index pointing to the element in the non-repetitive data set that is equal to the intermediate data, and add it to the index set;
[0031] If the length of the intermediate data is greater than the length of the first sliding window, the intermediate data is compared using the sliding window in a recursive manner.
[0032] The second aspect of the present disclosure proposes a data compression device, which includes: a receiving module for receiving data to be compressed; a compression module for performing data comparison on the data to be compressed through a sliding window to obtain a non-repetitive data set and a compression trajectory table; and a determination module for determining the non-repetitive data set and the compression trajectory table as compressed data.
[0033] The third aspect embodiment of the present disclosure proposes an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any one of the methods in the first aspect embodiment of the present disclosure.
[0034] The fourth aspect embodiment of the present disclosure proposes a non-transitory computer-readable storage medium storing computer instructions, characterized in that the computer instructions are used to enable a computer to execute the method in the first aspect embodiment of the present disclosure.
[0035] The fifth aspect embodiment of the present disclosure proposes a computer program product, characterized in that it includes a computer program, and when the computer program is executed by a processor, it implements any method in the first aspect embodiment of the present disclosure.
[0036] The sixth aspect embodiment of the present disclosure proposes a chip, characterized in that it includes one or more interface circuits and one or more processors; the interface circuit is used to receive signals from the memory of the electronic device and send signals to the processor, the signals include computer instructions stored in the memory, and when the processor executes the computer instructions, the electronic device executes any one of the methods in the first aspect embodiment of the present disclosure.
[0037] In summary, according to the data compression method proposed in the present disclosure, the data to be compressed is received to collect and organize the data to be compressed; the data to be compressed is compared through a sliding window to obtain a non-repetitive data set and a compression trajectory table; by first comparing and then dividing, a non-repetitive data set and a compression trajectory table are obtained from the entire data to be compressed; the non-repetitive data set and the compression trajectory table are determined as compressed data, and high-efficiency compression of the data is completed. The compression efficiency of multi-file compression and modified file compression is improved, and the compression rate is reduced.
[0038] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0040] Figure 1 A flowchart of a data compression method according to an embodiment of the present disclosure;
[0041] Figure 2 This is a flow chart of an embodiment of the present disclosure, which compares data to be compressed by using a sliding window to obtain a non-repetitive data set and a compression trajectory table;
[0042] Figure 3 A flowchart of an embodiment of the present disclosure, in which a sliding window is used to compare data to be compressed according to a first sliding window length and a first sliding step length to determine a non-repetitive data set and an index set;
[0043] Figure 4 A flowchart of updating a non-repetitive data set and / or an index set according to a first coding value and a second coding value according to an embodiment of the present disclosure;
[0044] Figure 5 It is a flowchart of an embodiment of the present disclosure for determining intermediate data based on the data to be compressed, the first data segment, the second data segment and the third data segment, and compressing the intermediate data;
[0045] Figure 6 A flowchart of using a sliding window to compress intermediate data according to an embodiment of the present disclosure;
[0046] Figure 7 A schematic diagram of a data compression system architecture according to an embodiment of the present disclosure;
[0047] Figure 8 It is a schematic diagram of data comparison based on a sliding window of data source 1;
[0048] Fig. 9 A schematic diagram of sliding window comparison and cutting based on data source 1;
[0049] Fig.10 is a schematic diagram of a compression result based on data source 1;
[0050] Fig.11 A schematic diagram of a data source 2 according to an implementation of this embodiment;
[0051] Fig.12 This is a schematic diagram of data comparison based on a sliding window of a data source 2 according to an implementation of an embodiment of the present disclosure;
[0052] Fig.13 Based on two data sources Fig.10 A schematic diagram after the compression result is updated;
[0053] Fig.14 It is a structural schematic diagram of a data compression device according to an embodiment of the present disclosure;
[0054] Fig.15 It is a block diagram of an electronic device for implementing the data compression method disclosed in the present invention according to an exemplary embodiment. DETAILED DESCRIPTION
[0055] Embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout identify the same or similar originals or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present disclosure, and should not be construed as limiting the present disclosure.
[0056] In the process of data storage, data compression is usually involved, and the compression rate is used to characterize the effect of data compression. The compression rate refers to the ratio of the compressed data size to the original data size, usually expressed as a percentage. For example, in one compression scheme, a 100M file is compressed to 90M, and the compression rate is 90 / 100*100%=90%; in another compression scheme, a 100M file is compressed to 10M, and the compression rate is 10 / 100*100%=10%. It can be seen that the second compression scheme has a better compression effect. In other words, the smaller the compression rate, the higher the compression efficiency.
[0057] The relevant compression method is mainly to split the data file into multiple groups of data segments with specific lengths, including:
[0058] 1. Calculate the code for each data segment. The coding methods include MD5, MD5 Hash, SHA-1, AES, DES, RSA, etc. MD5 coding is usually used.
[0059] 2. Use the code as the keyword for comparison and search. If the codes of multiple data segments are consistent, only one data segment is stored, and other duplicate data segments are indexed to the stored data segments.
[0060] 3. If there is no consistent encoding after traversing all data segments, it means that the data segment is a new data segment and needs to be stored separately.
[0061] For example, the original data segmentation:
[0062] <![CDATA[H1]]> data <![CDATA[H2]]> data <![CDATA[H3]]> data … <![CDATA[H 10 ]]> data
[0063] Among them, H1~H 10 If the encoding values of are the same, only the H2 segment data is stored, and the rest of the data is index H ni , n is the number of data segments, i is the sequence number of the data segment:
[0064] <![CDATA[H n1 ]]> <![CDATA[H2]]> data <![CDATA[H n3 ]]> … <![CDATA[H n10 ]]>
[0065] The data finally stored is the data volume of H2 and 9 indexes, thus achieving the goal of data compression and saving storage space.
[0066] In the related technical solution, there are the following problems in data compression:
[0067] 1. The existing technical solutions are generally for single compression of a single file. When multiple files are compressed multiple times, it is not possible to perform a global comparison of all files to be compressed, especially for files of different types, that is, the comparison between files, which results in low compression efficiency.
[0068] 2. Since the relevant technical solutions divide the data file into fixed lengths each time and then compare them segment by segment, when the same file needs to be compressed again, and a segment of content is added or reduced in the file, even if it is a small segment, it will cause the previous and next data segments to deviate after cutting, and then cause most of the data segments to be inconsistently encoded, ultimately increasing the compression rate and reducing the efficiency of data compression.
[0069] For example, the original data segmentation:
[0070] 1011 1011 1011 1011 1011 1011 1011 1011 1011
[0071] Add data 0 at the end of the 5th segment:
[0072] 1011 1011 1011 1011 10110 1011 1011 1011 1011
[0073] Re-division under fixed segmentation:
[0074] 1011 1011 1011 1011 1011 0101 1101 1101 1101 1
[0075] This means that when only slight modifications are made to the data, the compression rate is increased from the original 1 / 9 to 4 / 9 through this compression method, indicating that storing the compressed data requires a larger storage space than the original compressed data, and the compression efficiency is reduced.
[0076] In response to the above problems, the present disclosure proposes a data compression method, which is applied to a server. The server receives the data to be compressed, and performs compression cutting, calculation, comparison and recording, and then uses corresponding storage resources to store the compressed data that actually needs to be stored.
[0077] At the same time, the server no longer uses a fixed-length cutting method, but a compression method of comparing first and then cutting. That is, when the data is received, it starts to calculate and encode it, and when its encoding is consistent with the encoding of the data segment in storage, it is cut. This achieves a smaller data compression rate, increases the efficiency of data compression, and can achieve global compression.
[0078] Currently, compression software on the market is personal software, and there is almost no compression software available for enterprise data centers, but its market value is huge. There is demand for some industry-specific and large data types, such as: call data, content management data, paperless office data in the operator industry, electronic medical record data, imaging data in the medical industry, evidence preservation data in the legal industry, etc. These data need to be stored for a long time and need to be updated irregularly, such as patient follow-up visits and case trials. At the same time, it is also necessary to save the status of different periods, such as the development of the disease and the development of the case. These data will take up a lot of storage space and need to be stored for a long time, but at the same time, the frequency of their reading is relatively low, so they are suitable for compressed storage.
[0079] The present disclosure is applied in data management, focusing on the overall strategy of "compressing online data - moving cold data - compressing and merging offline data", and can also be used in automated operation and maintenance systems to regularly schedule data compression jobs and routinely compress multiple data sources that have been defined in advance in the production system. The application scenarios are not limited in the embodiments of the present disclosure.
[0080] The data compression method provided by the present application is described in detail below with reference to the accompanying drawings.
[0081] Figure 1 FIG. 1 is a flow chart of a data compression method according to an embodiment of the present disclosure. Figure 1 As shown, the data compression method includes:
[0082] Step 101: Receive data to be compressed.
[0083] In the present disclosure, the server receives data sent by the terminal or forwarded by other servers, and uses part or all of the received data as data to be compressed.
[0084] Step 102: perform data comparison on the data to be compressed through a sliding window to obtain a non-repetitive data set and a compression trajectory table.
[0085] In the present disclosure, a sliding window is a processing range selection tool or algorithm with a fixed window length and a fixed sliding step. A non-repetitive data set is a data set in which the data stored are all different and non-repetitive data, and is used to store the data segments that appear for the first time in the data to be compressed. The compression trajectory table is a text that records the mapping relationship between the data to be compressed and the compressed data. Through the sliding window, a sliding data comparison is performed on the data to be compressed. In the process of continuous sliding comparison, new data sources or indexes are continuously added to the non-repetitive data set and the compression trajectory table, and a continuously updated non-repetitive data set and compression trajectory table are obtained.
[0086] Step 103: determine the non-repetitive data set and the compression trajectory table as compressed data.
[0087] In the present disclosure, after comparing the data segments through the sliding window, the obtained non-repetitive data set and compression trajectory table are the compressed data, that is, the compressed data.
[0088] In summary, according to the data compression method proposed in the present disclosure. The data to be compressed is received, and is used to collect and organize the data to be compressed; through a sliding window, the data to be compressed is compared to obtain a non-repetitive data set and a compression trajectory table; based on the sliding window, the data to be compressed is first compared and then divided, and repeated data segments are independently recorded, and a non-repetitive data set and a compression trajectory table are created through repeated data segments and the first appearance of the data segment and the corresponding index. The non-repetitive data set and the compression trajectory table are determined as compressed data, and the data compressed by the data compression method are obtained, completing the compression of the data with a low compression rate and high compression efficiency, improving the compression efficiency of multi-file compression and modified file compression, and greatly saving the storage space.
[0089] Figure 2 This is a flow chart of an embodiment of the present disclosure, which compares data to be compressed by sliding a window to obtain a non-repetitive data set and a compression trajectory table. Figure 2 right Figure 1 Step 102 is further described. Figure 2 The embodiment shown, Figure 2 The steps include:
[0090] Step 201, obtaining a first sliding window length of a sliding window.
[0091] In this embodiment, the first sliding window length is the length of data that can be processed by the sliding window each time. The first sliding window length is set to the length of the sliding window, and its length can be a specified number of bytes or bits.
[0092] Step 202: Obtain a first sliding step length of the sliding window.
[0093] In this embodiment, the first sliding step length is the moving length of each sliding of the sliding window. The first sliding step length is set as the sliding step length of the sliding window, and each sliding step length is a specified number of bytes or bits.
[0094] Step 203: Compare the data to be compressed using a sliding window according to the first sliding window length and the first sliding step length to determine a non-repetitive data set and an index set.
[0095] In this embodiment, a sliding window with a first sliding window length and a first sliding step length as designated parameters is used to slide the data to be compressed to obtain the encoding of the data segment to determine whether it is consistent, and a non-repetitive data set and an index set are determined according to the comparison result. If the comparison is inconsistent, the data segment that appears for the first time is added to the non-repetitive data set. If the comparison is consistent, an index pointing to the corresponding data that appears for the first time in the non-repetitive data set is created, and the index is saved in the index set.
[0096] Step 204: Determine a compression trajectory table according to the data to be compressed and the index set.
[0097] In this embodiment, the compression trajectory table records the mapping relationship between the data to be compressed and the compressed data. The compression trajectory table is composed of the index set, data segment and the encoding value corresponding to the data segment obtained by sliding the sliding window on the data to be compressed.
[0098] In this embodiment, the length and step size of the sliding window are set, and the sliding window is used to compare and segment the data to be compressed, and the obtained data segments are stored separately according to whether they are repeated, so as to obtain a non-repeating data set and a compression trajectory table. The preparation of the data structure is provided for data compression, and a non-repeating data set and a compression trajectory table are obtained. Among them, step 203 of this embodiment is particularly important for determining the non-repeating data set and the index set.
[0099] Figure 3 This is a flowchart of an embodiment of the present disclosure, which uses a sliding window to compare the compressed data according to the first sliding window length and the first sliding step size to determine a non-repeating data set and an index set. Figure 3 right Figure 2 Step 203 is described in detail. Figure 3 The embodiment shown, Figure 3 The following steps are involved:
[0100] Step 301: Use a sliding window to obtain a first data segment of data to be compressed with a first sliding window length.
[0101] The first data segment is the data segment where the sliding window processes the data to be compressed for the first time, and the length of the first data segment is the first sliding window length. The sliding window is used to perform sliding processing on the data to be compressed, and the data segment of the first sliding window length where the sliding window is currently located in the data to be compressed is taken as the first data segment.
[0102] In one implementation of this embodiment, the data to be compressed is 10111101111001111011110111100111, the sliding window length is 4 bits, and the sliding step is 1, then the first data segment is 1011.
[0103] Step 302: determine a first encoding value of a first data segment.
[0104] In this embodiment, the first coding value is a coding value of the first data segment after data coding.
[0105] In one implementation of this embodiment, MD5 encoding is performed on the first data segment to obtain an MD5 encoding value of the first data segment, that is, a hash value.
[0106] Step 303: Use a sliding window to sequentially obtain at least one second data segment with a first sliding window length.
[0107] In this embodiment, when the sliding window moves on the data to be compressed with the first sliding step length, the data segment obtained is used as the second data segment. Since the movement of the sliding window on the data to be compressed is continuous, at least one second data segment is obtained, and the length of the second data segment is the first sliding window length.
[0108] Step 304: determine a second encoding value of the second data segment.
[0109] In this embodiment, the second coding value is a coding value of the second data segment after data coding.
[0110] In one implementation of this embodiment, MD5 encoding is performed on the second data segment to obtain a hash value of the second data segment.
[0111] Step 305: Update the non-repetitive data set and / or index set according to the first encoding value and the second encoding value.
[0112] In this embodiment, based on the determined first coding value of the first data segment and the second coding value of the second data segment, the two are compared to determine whether they are consistent, thereby updating the non-repetitive data set and / or index set.
[0113] In this embodiment, the first data segment and the second data segment are obtained on the data to be compressed by sliding the window, and the first coding value of the first data segment and the second coding value of the second data segment are determined, thereby completing the encryption of the first data segment and the second data segment, providing the necessary premise for the comparison of the data segments. Based on the encrypted coding value, further comparison is performed to update the non-repetitive data set and / or index set.
[0114] Figure 4 This is a flowchart of updating a non-repetitive data set and / or an index set according to a first coding value and a second coding value according to an embodiment of the present disclosure. Figure 4 right Figure 3 Step 305 is described in detail. Figure 4 The embodiment shown, Figure 4 The steps include:
[0115] Step 401, determining whether the first code value is equal to the second code value.
[0116] In this embodiment, the first coding value of the first data segment is compared with the second coding value of the second data segment to determine whether the two are the same.
[0117] Step 402, if the first coding value is equal to the second coding value, add the first data segment to the non-repetitive data set, determine the first index value of the second data segment, and add the first index value to the index set, wherein the first index value is the index of the first data segment in the non-repetitive data set.
[0118] In this embodiment, if the first coding value is equal to the second coding value, it indicates that the first data segment is the same as the second data segment, that is, a duplicate data segment appears, then the first data segment is added to the non-duplicate data set, and a first index value of the second data segment is created, the first index value points to the first data segment in the non-duplicate data set, and the first index value is added to the index set.
[0119] Step 403, if the first coding value is not equal to the second coding value, the sliding window continues to slide until the third data segment or the end of the data to be compressed is obtained, wherein the third coding value of the third data segment is equal to the first coding value, and the second index value of the third data segment is added to the index set.
[0120] In this embodiment, if the first code value is not equal to the second code value, it means that the sliding window has not yet compared and obtained the second code value that is the same as the first code value, then the sliding window continues to slide until the third data segment or the end of the data to be compressed is obtained. Among them, the third code value of the third data segment is equal to the first code value, which means that the third data segment is the same as the first data segment, and a duplicate data segment appears, then the second index value of the third data segment is added to the index set, where the second index value points to the first data segment in the non-duplicate data set. In addition, the sliding window slides to the end of the data to be compressed, and the sliding of the sliding window is automatically terminated.
[0121] Step 404: determine intermediate data based on the data to be compressed, the first data segment, the second data segment, and the third data segment, and compress the intermediate data.
[0122] In this embodiment, the intermediate data is a data segment composed of partial data between two identical data segments. The intermediate data is obtained by the data to be compressed, the first data segment, the second data segment and the third data segment obtained in the process of processing the data to be compressed in the sliding window. If the second data segment is the same as the first data segment, the intermediate data is the data segment surrounded by the first data segment and the second data segment; if the third data segment is the same as the first data segment, the intermediate data is the data segment surrounded by the first data segment and the third data segment. After determining the intermediate data, it is necessary to compress the intermediate data. Through this embodiment, the data comparison in the compressed data is completed, and the non-repetitive data set and the index set are updated according to the comparison results, that is, the continuous compression of the data is completed.
[0123] In this embodiment, it is determined whether the first code value of the first data segment and the second code value of the second data segment are the same, thereby performing data segment comparison, and updating the non-repetitive data set and / or index set according to different comparison results. When intermediate data exists, the intermediate data is compressed.
[0124] Figure 5 This is a flowchart of an embodiment of the present disclosure for determining intermediate data based on the data to be compressed, the first data segment, the second data segment, and the third data segment, and compressing the intermediate data. Figure 5 right Figure 4 Step 404 is described in detail. Figure 5 The embodiment shown, Figure 5 The steps include:
[0125] Step 501: Based on the data to be compressed, the data segment between the first data segment and the fourth data segment is used as intermediate data, and the fourth data segment is the second data segment or the third data segment.
[0126] In this embodiment, the fourth data segment is one of the second data segment or the third data segment. Based on the data to be compressed and the first data segment and the fourth data segment obtained in the process of processing the data to be compressed by the sliding window, the intermediate data is obtained. In other words, if the second data segment is the same as the first data segment, the intermediate data is the data segment surrounded by the first data segment and the second data segment; if the third data segment is the same as the first data segment, the intermediate data is the data surrounded by the first data segment and the third data segment.
[0127] Step 502: Use a sliding window to compress the intermediate data.
[0128] In this embodiment, based on the determined intermediate data, the intermediate data is compressed using a sliding window.
[0129] In this embodiment, the middle part of the repeated data segment is determined by comparing the data to be compressed with the sliding window, and is used as the intermediate data, which provides a necessary data source for further compressing the data. Since the intermediate data varies in length, in order to achieve a lower compression rate, the intermediate data needs to be further compressed.
[0130] Figure 6 This is a flow chart of using a sliding window to compress intermediate data according to an embodiment of the present disclosure. Figure 6 right Figure 5 Step 502 is described in detail. Figure 6 The embodiment shown, Figure 6 The steps include:
[0131] Step 601, determine the length of the intermediate data and the length of the first sliding window.
[0132] In this embodiment, the length of the intermediate data is compared with the first sliding window length. The length of the intermediate data is represented by bytes or bits, which is consistent with the unit of the first sliding window length.
[0133] Step 602: If the length of the intermediate data is less than or equal to the first sliding window length, and the intermediate data does not exist in the non-repetitive data set, then the intermediate data is added to the non-repetitive data set.
[0134] In this embodiment, if the length of the intermediate data is less than or equal to the first sliding window length, and the intermediate data does not exist in the non-repetitive data set, that is, the intermediate data is that the sliding window does not have the same data segment when it starts processing the data to be compressed to the current intermediate data position, and the length of the intermediate data does not exceed the first sliding window length, then the intermediate data is added to the non-repetitive data set.
[0135] In one implementation of this embodiment, the data to be compressed is 110011011000, which is 11 bits in total. The first sliding window length of the sliding window is 4 bits, and the sliding step is 1. Then, in the first data segment 1100 and the second data segment 1100, there is an intermediate data 110. Since the intermediate data is 3 bits in total, which is less than the first sliding window length, and the data segments stored in the current non-repetitive data set are all 4-bit data segments, the intermediate data is non-repetitive data and is added to the non-repetitive data set.
[0136] Step 603: If the length of the intermediate data is less than or equal to the first sliding window length, and the intermediate data exists in the non-repetitive data set, create an index pointing to the element in the non-repetitive data set that is equal to the intermediate data, and add it to the index set.
[0137] In this embodiment, if the length of the intermediate data is less than or equal to the first sliding window length, and the intermediate data exists in a non-repetitive data set, then an index value is created for the intermediate data, the index value points to the element in the non-repetitive data set that is equal to the intermediate data, and the index value is added to the index set.
[0138] In one implementation of this embodiment, the data to be compressed is 110011011000, which is 11 bits in total. The first sliding window length of the sliding window is 4 bits, and the sliding step size is 1. Then, in the first data segment 1100 and the second data segment 1100, there is an intermediate data 110. Since the intermediate data is 3 bits in total, which is less than the first sliding window length, and the data segment 110 already exists in the current non-repetitive data set, the intermediate data is duplicate data. Then, an index value 302 of the data segment is created, and the index value points to the data segment 110 in the non-repetitive data set. At the same time, the index value 302 is added to the index set, indicating that the 303rd data segment 110 appears in the data to be compressed.
[0139] Step 604: If the length of the intermediate data is greater than the first sliding window length, a data comparison is performed on the intermediate data using the sliding window in a recursive manner.
[0140] In this embodiment, if the length of the intermediate data exceeds the first sliding window length, the intermediate data is subjected to sliding processing through the sliding window to perform data comparison and compression. The comparison and compression methods are completely consistent with the processing methods of the data to be compressed, that is, the intermediate data is processed in a recursive manner.
[0141] In one implementation of this embodiment, the data to be compressed is 1100101001011100, which is 16 bits in total. The first sliding window length of the sliding window is 4 bits, and the sliding step length is 1. In the first data segment 1100 and the third data segment 1100, the intermediate data is 10100101. Since the intermediate data is 8 bits in total, which is greater than the first sliding window length 4, the intermediate data is recursively compared. For the intermediate data, the first data segment is 1010. No data segment identical to the first data segment is compared in the intermediate data segment. If 1010 does not exist in the non-repetitive data set, 1010 is added to the non-repetitive data set. If 1010 already exists in the non-repetitive data set, an index value 2 is created for the first data segment 1010 to indicate the third 1010 data segment in the data to be compressed. As in the above processing method, the same compression operation is performed on the last four bits 0101 of the intermediate data.
[0142] In this embodiment, a sliding window is used to compress intermediate data of different lengths, thereby completing the overall compression of the entire data to be compressed.
[0143] Figure 7 Schematic diagram of a data compression system architecture according to an embodiment of the present disclosure. Figure 7 In the embodiment shown, the data compression system is mainly composed of the following two parts in terms of physical architecture:
[0144] Compression server: The compression server is responsible for receiving data to be compressed from different sources. For the first received data, it will not be compressed and will be directly stored. Cursor calculation will be performed on subsequent data. Finally, the data that needs to be stored will be passed to the back-end storage compression module.
[0145] Storage compression module: mainly used to store non-repetitive data sets processed by the compression server. It can be the storage provided by the compression server or an external independent storage. The storage can be expanded.
[0146] In the figure, data to be compressed 2 and data to be compressed 2 are both data files to be compressed, wherein data to be compressed 1 includes data segment 1 and data segment 2, and data to be compressed 2 includes data segment 3, data segment 4 and data segment 5. In the compression server, data to be compressed 2 and data to be compressed 3 are compressed, wherein data segment 3 is the same as data segment 1, so data segment 1 of data source 1 (data to be compressed 1) that appears for the first time is saved in the compression storage module, and for data segment 3 of data source 2 that is the same as data segment 1, an index pointing to data segment 1 in the compression storage module is created in the compression server. Similarly, since data segment 2 of data source 2 (data to be compressed 2) is the first data segment to appear, data segment 2 is stored in the compression storage module, and then data segment 5 of data source 1 that is the same as data segment 2 is created to point to data segment 2 in the compression storage module. Since data segment 4 of data source 2 is a single non-repeating field, it is stored in the compression storage module. Therefore, there are a total of 3 data segments that actually appear at present, corresponding to 3 encoding values, and the above index relationship is recorded in the cursor segment.
[0147] The cursor segment in the figure means that when a certain segment of data has been stored in the compression storage module, the compression server marks it as a cursor segment and records it as an index on the compression server, pointing to the non-duplicate data in the compression storage module.
[0148] The data segment in the figure refers to the data that is determined not to need to be compressed after calculation by the compression server and is directly stored in the compression storage module.
[0149] The encoding value in the figure means that when the compression server cuts and connects each data segment, it does not directly compare the content, but calculates an encoding value (Hash encoding) for it. If the encoding values are consistent, the content is consistent.
[0150] The compression trajectory table in the figure is stored by the compression server. When the compression server receives new data, it only needs to calculate its encoding value to compare it in the compression server, without having to read the data in the compression storage module again, thereby enhancing the efficiency of comparison and data decompression.
[0151] When new data (data source 1) is written to the compression server, the compression server will set a sliding window length, which can be set and adjusted.
[0152] The length is mainly selected based on the memory size of the compression server (it can make good use of the memory computing power of the compression server): the minimum recommended is 4 bytes. If the length is too short, the compression system will be overloaded with computing pressure; the maximum recommended is 256 bytes. If the length is too long, the compression rate will be reduced; match according to the memory size of the compression server, such as: 8G memory - 8 bytes; 16G memory - 16 bytes; 32G memory - 32 bytes...
[0153] In one implementation of this embodiment, the sliding window moves from the beginning to the end of the data to be compressed in bytes, the first sliding window length of the sliding window is 4 bytes, and the sliding step is 1 byte. For the convenience of description, the encoding of the data segment is not shown in this implementation, and the data source 1 to be compressed is 10111101111001111011110111100111.
[0154] In one implementation of this embodiment, Figure 8 FIG. 1 is a schematic diagram of data comparison based on a sliding window of data source 1. Figure 8 As shown, the sliding window moves from the leftmost end to the rightmost end of data source 1, one byte at a time. When the comparison is done for the fifth time, the data segment 1011 in data source 1, which is used as the reference data segment, is found.
[0155] After comparing data source 1, the data segment list shown in the following table is obtained:
[0156] Data Source 1 - Segment 1 1011 Data Source 1 - Segment 2 1 Data Source 1 - Segment 3 1011 Data Source 1 - Segment 4 1100111 Data Source 1 - Segment 5 1011 Data Source 1 - Segment 6 1 Data Source 1 - Segment 7 1011 Data Source 1 - Segment 8 1100111
[0157] In one implementation of this embodiment, Fig. 9 FIG. 1 is a schematic diagram of a sliding window comparison and cutting based on data source 1. Fig. 9 As shown, in the first round of movement, a data segment exceeding 4 bytes is obtained. For the data segment exceeding 4 bytes, it is moved again and cut with the cursor length, and finally the data segments in the following table are obtained, in which the data segments are represented by segments:
[0158] Data Source 1 - Segment 1 1011 Data Source 1 - Segment 2 1 Data Source 1 - Segment 3 1011 Data Source 1 - Segment 4 1100 Data Source 1 - Segment 4.1 111 Data Source 1 - Segment 5 1011 Data Source 1 - Segment 6 1 Data Source 1 - Segment 7 1011 Data Source 1 - Segment 8 1100 Data Source 1 - Segment 8.1 111
[0159] In one implementation of this embodiment, Fig.10 FIG. 1 is a schematic diagram of a compression result based on data source 1. Fig.10 As shown, the compression server obtains data source 1 and compresses it.
[0160] After comparison, as shown in the table above, there are only 4 non-repeating data segments, 1011, 1, 1100, and 111, which correspond to the first appearing data segments 1, 2, 4, and 4.1. The 4 non-repeating data segments are stored in the compression storage module. The compression track table is saved in the compression server to record the index relationship between the repeated data segments and the data in the compression storage module.
[0161] Compared with the traditional compression method, the data source 1 10111101111001111011110111100111 can be divided into the following table:
[0162] 1011 1101 1110 0111 1011 1101 1110 0111
[0163] According to the table Fig.10 As shown in the compression trajectory table, both the traditional compression and the compression disclosed herein finally store 4 data segments, but each segment of the traditional compression has only one identical segment, and the length of each segment is 4 bytes, while the data segment 1 calculated by the disclosed method has 3 identical segments, and data segment 2 is 1 byte, and data segment 4.1 is 3 bytes.
[0164] The compression ratio comparison is as follows:
[0165] Traditional compression ratio: 16 bytes / 32 bytes = 50%
[0166] The compression ratio of this disclosure is: 12 bytes / 32 bytes = 37.5%
[0167] Obviously, the compression rate of the present invention is lower than the traditional compression rate. For the same data to be compressed, the storage space required after compression is smaller, and the compression efficiency is higher.
[0168] Fig.11 Schematic diagram of data source 2 of an implementation of this embodiment. As shown in FIG. e, data source 2 is 10111101111001110101111101111100111. Data source 2 is data source 1 with three data 0, 1, and 1 inserted into the positions shown in the figure.
[0169] Fig.12 FIG. 2 is a schematic diagram of data comparison based on a sliding window of data source 2 according to an implementation of this embodiment. Fig.12 As shown, the sliding window moves from the leftmost end to the rightmost end of the data source 2, one byte at a time. When the comparison is performed for the third time, the data segment 1011 in the data source 2 as the reference data segment is found.
[0170] After comparing data source 2, the data segment list shown in the following table is obtained:
[0171] Data Source 2 - Segment 9 1011 Data Source 2 - Segment 10 1 Data Source 2 - Segment 11 1011 Data Source 2 - Segment 12 11001110 Data Source 2 - Segment 13 1011 Data Source 2 - Segment 14 11 Data Source 2 - Segment 15 1011 Data Source 2 - Segment 16 11100111
[0172] Since a data segment exceeding 4 bytes is obtained during the upward movement, the data segment exceeding 4 bytes is moved again, and the final data segment status is shown in the following table:
[0173] Data Source 2 - Segment 9 1011 Data Source 2 - Segment 10 1 Data Source 2 - Segment 11 1011 Data Source 2 - Segment 12 1100 Data Source 2 - Segment 12.1 1110 Data Source 2 - Segment 13 1011 Data Source 2 - Segment 14 11 Data Source 2 - Segment 15 1011 Data Source 2 - Segment 16 1110 Data Source 2 - Segment 16.1 0111
[0174] In one implementation of this embodiment, Fig.13 Based on two data sources Fig.10Schematic diagram after the compression result is updated. As shown in the compression trajectory table in the figure, after data source 1 and data source 2 are compressed together, there are 7 non-repeating data segments actually stored in the compression storage module, namely 1011 of data segment 1, 1 of data segment 2, 1100 of data segment 4, 111 of data segment 4.1, 11 of data segment 14, 1110 of data segment 12.1, and 0111 of data segment 16.1. The 7 data segments correspond to 7 encoding values. For data segment 1, data segments 3, 5, 7, 9, 11, 13, and 15 all have index values pointing to data segment 1 stored in the cursor segment; for data segment 2, data segment 6 has an index value pointing to data segment 2 stored in the cursor segment; for data segment 4, data segments 8 and 12 have index values pointing to data segment 4 stored in the cursor segment; for data segment 4.1, data segment 8.1 has an index value pointing to data segment 4.1 stored in the cursor segment. The data segments 12.1, 14 and 16.1 are all non-repeated data in the data source 1 and the data source 2 of the data to be compressed, and are independently stored in the compression storage module.
[0175] The compression of the data source 1 and the data source 2 in the embodiment of the present disclosure is compared with the traditional compression as follows:
[0176] Traditional compression is shown in the following table:
[0177] 1011 1101 1110 0111 1011 1101 1110 0111
[0178] 1011 1101 1110 0111 0101 1111 0111 1100 111
[0179] Traditional compression adds 4 data segments, while the disclosed embodiment adds 3 data segments for the same data to be compressed.
[0180] Traditional compression ratio: 31 bytes / 35 bytes = 88.6%
[0181] Compression ratio of this disclosure: 22 bytes / 35 bytes = 62.8%
[0182] Obviously, the disclosed embodiments have made significant progress in multi-file compression, reduced the compression ratio, improved the compression efficiency of multi-file compression and modified file compression, reduced the compression ratio, and made the compressed files occupy less storage space, saving more storage space for system storage.
[0183] Corresponding to the methods provided in the above-mentioned embodiments, the present disclosure also provides a data compression device. Since the device provided in the embodiment of the present disclosure corresponds to the methods provided in the above-mentioned embodiments, the implementation method of the method is also applicable to the device provided in this embodiment and will not be described in detail in this embodiment.
[0184] Fig.14FIG. 1 is a schematic diagram of the structure of a data compression device 1400 according to an embodiment of the present disclosure. Fig.14 As shown, the data compression device comprises:
[0185] The receiving module 1410 is used to receive data to be compressed;
[0186] The compression module 1420 is used to compare the data to be compressed through a sliding window to obtain a non-repetitive data set and a compression trajectory table;
[0187] The determination module 1430 is configured to determine the non-repetitive data set and the compression trajectory table as compressed data.
[0188] In some embodiments, the compression module 1420 is used to:
[0189] Get the first sliding window length of the sliding window;
[0190] Get the first sliding step of the sliding window;
[0191] According to the first sliding window length and the first sliding step length, using the sliding window to compare the data to be compressed to determine a non-repetitive data set and an index set;
[0192] A compression trajectory table is determined according to the data to be compressed and the index set.
[0193] In some embodiments, the compression module 1420 uses the sliding window to compare the data to be compressed according to the first sliding window length and the first sliding step length in the following manner to determine that the non-repetitive data set and the index set include:
[0194] Using a sliding window, obtaining a first data segment of the data to be compressed with a first sliding window length;
[0195] determining a first encoding value for a first data segment;
[0196] Using a sliding window, sequentially obtaining at least one second data segment with a first sliding window length;
[0197] determining a second encoding value for a second data segment;
[0198] According to the first encoding value and the second encoding value, the non-repetitive data set and / or the index set are updated.
[0199] In some embodiments, the compression module 1420 updates the non-repetitive data set and / or the index set according to the first encoding value and the second encoding value in the following manner:
[0200] Determine whether the first code value is equal to the second code value;
[0201] If the first encoding value is equal to the second encoding value, adding the first data segment to the non-repetitive data set, determining a first index value of the second data segment, and adding the first index value to the index set, wherein the first index value is an index of the first data segment in the non-repetitive data set;
[0202] If the first encoding value is not equal to the second encoding value, the sliding window continues to slide until a third data segment or the end of the data to be compressed is obtained, wherein the third encoding value of the third data segment is equal to the first encoding value, and the second index value of the third data segment is added to the index set;
[0203] Based on the data to be compressed, the first data segment, the second data segment and the third data segment, intermediate data is determined and compressed.
[0204] In some embodiments, the compression module 1420 determines the intermediate data based on the data to be compressed, the first data segment, the second data segment, and the third data segment in the following manner, and compressing the intermediate data includes:
[0205] Based on the data to be compressed, the data segment between the first data segment and the fourth data segment is used as the intermediate data, and the fourth data segment is the second data segment or the third data segment;
[0206] Use sliding windows to compress intermediate data.
[0207] In some embodiments, the compression module 1420 compresses the intermediate data according to the intermediate data and the sliding window in the following manner:
[0208] Determine the length of the intermediate data and the length of the first sliding window;
[0209] If the length of the intermediate data is less than or equal to the first sliding window length, and the intermediate data does not exist in the non-repetitive data set, then the intermediate data is appended to the non-repetitive data set, or
[0210] If the length of the intermediate data is less than or equal to the first sliding window length, and the intermediate data exists in the non-repetitive data set, then create an index pointing to the element in the non-repetitive data set that is equal to the intermediate data, and add it to the index set;
[0211] If the length of the intermediate data is greater than the length of the first sliding window, the intermediate data is compared using the sliding window in a recursive manner.
[0212] In summary, the data to be compressed is received by the data compression device to collect and organize the data to be compressed; the data to be compressed is compared by the sliding window to obtain a non-repeating data set and a compression trajectory table; the non-repeating data set and the compression trajectory table are obtained from the entire data to be compressed by first comparing and then dividing; the non-repeating data set and the compression trajectory table are determined as compressed data, and the high-efficiency compression of the data is completed. The compression efficiency of multi-file compression and modified file compression is improved, and the compression rate is reduced.
[0213] In the embodiments provided in the present application, the methods and devices provided in the embodiments of the present application are introduced. In order to implement the functions in the methods provided in the embodiments of the present application, the electronic device may include a hardware structure and a software module, and implement the functions in the form of a hardware structure, a software module, or a hardware structure plus a software module. A function of the functions may be executed in the form of a hardware structure, a software module, or a hardware structure plus a software module.
[0214] Fig.15 is a block diagram of an electronic device 1400 for implementing the above data compression method according to an exemplary embodiment.
[0215] For example, the electronic device 1500 may be a mobile phone, a computer, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0216] Reference Fig.15 , the electronic device 1500 may include one or more of the following components: a processing component 1502 , a memory 1504 , a power component 1506 , a multimedia component 1508 , an audio component 1510 , an input / output (I / O) interface 1512 , a sensor component 1514 , and a communication component 1516 .
[0217] The processing component 1502 generally controls the overall operation of the electronic device 1500, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 1502 may include one or more processors 1520 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 1502 may include one or more modules to facilitate the interaction between the processing component 1502 and other components. For example, the processing component 1502 may include a multimedia module to facilitate the interaction between the multimedia component 1508 and the processing component 1502.
[0218] The memory 1504 is configured to store various types of data to support operations on the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 1500, contact data, phone book data, messages, pictures, videos, etc. The memory 1504 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0219] The power supply component 1506 provides power to the various components of the electronic device 1500. The power supply component 1506 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 1500.
[0220] The multimedia component 1508 includes a screen that provides an output interface between the electronic device 1500 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 1508 includes a front camera and / or a rear camera. When the electronic device 1500 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0221] The audio component 1510 is configured to output and / or input audio signals. For example, the audio component 1510 includes a microphone (MIC), and when the electronic device 1500 is in an operation mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 1504 or sent via the communication component 1516. In some embodiments, the audio component 1510 also includes a speaker for outputting audio signals.
[0222] I / O interface 1512 provides an interface between processing component 1502 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0223] The sensor assembly 1514 includes one or more sensors for providing various aspects of status assessment for the electronic device 1500. For example, the sensor assembly 1514 can detect the open / closed state of the electronic device 1500, the relative positioning of components, such as the display and keypad of the electronic device 1500, and the sensor assembly 1514 can also detect the position change of the electronic device 1500 or a component of the electronic device 1500, the presence or absence of user contact with the electronic device 1500, the orientation or acceleration / deceleration of the electronic device 1500, and the temperature change of the electronic device 1500. The sensor assembly 1514 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 1514 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 1514 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0224] The communication component 1516 is configured to facilitate wired or wireless communication between the electronic device 1500 and other devices. The electronic device 1500 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, 4G LTE, 5G NR (NewRadio) or a combination thereof. In an exemplary embodiment, the communication component 1516 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 1516 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0225] In an exemplary embodiment, the electronic device 1500 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0226] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1504 including instructions, and the instructions can be executed by the processor 1520 of the electronic device 1500 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0227] The embodiments of the present disclosure further provide a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the data compression method described in the above embodiments of the present disclosure.
[0228] The embodiments of the present disclosure further provide a computer program product, including a computer program, which executes the data compression method described in the above embodiments of the present disclosure when a processor is used.
[0229] An embodiment of the present disclosure also proposes a chip, which includes one or more interface circuits and one or more processors; the interface circuit is used to receive signals from a memory of an electronic device and send signals to the processor, the signals include computer instructions stored in the memory, and when the processor executes the computer instructions, the electronic device executes the data compression method described in the above embodiments of the present disclosure.
[0230] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0231] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiments or examples are included in at least one embodiment or example of the present disclosure. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0232] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present disclosure includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present disclosure belong.
[0233] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processing module, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (control method), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or otherwise processing in a suitable manner if necessary, and then stored in a computer memory.
[0234] It should be understood that the various parts of the embodiments of the present disclosure can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0235] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0236] In addition, each functional unit in each embodiment of the present disclosure may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium. The above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0237] Although the embodiments of the present disclosure have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present disclosure. A person skilled in the art may make changes, modifications, substitutions and variations to the above embodiments within the scope of the present disclosure.
Claims
1. A data compression method, characterized in that: Applied to a server, the method comprises: receiving data to be compressed; By using a sliding window, data comparison is performed on the data to be compressed to obtain a non-repetitive data set and a compression trajectory table; The non-repetitive data set and the compression trace table are determined as compressed data.
2. The method according to claim 1, characterized in that The data to be compressed is compared by sliding the window to obtain a non-repetitive data set and a compression trajectory table, including: Obtaining a first sliding window length of the sliding window; Obtaining a first sliding step length of the sliding window; According to the first sliding window length and the first sliding step length, using the sliding window to compare the data to be compressed to determine the non-repetitive data set and the index set; The compression trajectory table is determined according to the data to be compressed and the index set.
3. The method according to claim 2, characterized in that The comparing the data to be compressed using the sliding window according to the first sliding window length and the first sliding step length to determine the non-repetitive data set and the index set includes: Using the sliding window, obtaining a first data segment of the data to be compressed with the first sliding window length; determining a first encoding value of the first data segment; Using the sliding window, sequentially obtaining at least one second data segment with the first sliding window length; determining a second encoding value of the second data segment; The non-repetitive data set and / or the index set are updated according to the first encoding value and the second encoding value.
4. The method according to claim 3, characterized in that The updating of the non-repetitive data set and / or the index set according to the first encoding value and the second encoding value comprises: Determine whether the first encoding value is equal to the second encoding value; If the first encoding value is equal to the second encoding value, adding the first data segment to the non-repetitive data set, determining a first index value of the second data segment, and adding the first index value to the index set, wherein the first index value is an index of the first data segment in the non-repetitive data set; If the first encoding value is not equal to the second encoding value, the sliding window continues to slide until a third data segment or the end of the data to be compressed is obtained, wherein a third encoding value of the third data segment is equal to the first encoding value, and the second index value of the third data segment is added to the index set; Based on the data to be compressed, the first data segment, the second data segment and the third data segment, intermediate data is determined, and the intermediate data is compressed.
5. The method according to claim 4, characterized in that The determining of intermediate data based on the data to be compressed, the first data segment, the second data segment, and the third data segment, and compressing the intermediate data comprises: Based on the data to be compressed, a data segment between the first data segment and the fourth data segment is used as the intermediate data, and the fourth data segment is the second data segment or the third data segment; The intermediate data is compressed using the sliding window.
6. The method according to claim 5, characterized in that The using the sliding window to compress the intermediate data comprises: Determining the length of the intermediate data and the length of the first sliding window; If the length of the intermediate data is less than or equal to the first sliding window length, and the intermediate data does not exist in the non-repetitive data set, then the intermediate data is appended to the non-repetitive data set, or If the length of the intermediate data is less than or equal to the first sliding window length, and the intermediate data exists in the non-repetitive data set, then create an index pointing to an element in the non-repetitive data set that is equal to the intermediate data, and add the index to the index set; If the length of the intermediate data is greater than the first sliding window length, the sliding window is used to perform data comparison on the intermediate data in a recursive manner.
7. A data compression device, characterized in that: The device comprises: A receiving module, used for receiving data to be compressed; A compression module, used for performing data comparison on the data to be compressed through a sliding window to obtain a non-repetitive data set and a compression trajectory table; A determination module is used to determine the non-repetitive data set and the compression trajectory table as compressed data.
8. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-6.
10. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 6.
11. A chip, characterized in that: It comprises one or more interface circuits and one or more processors; the interface circuit is used to receive a signal from a memory of an electronic device and send the signal to the processor, the signal includes a computer instruction stored in the memory, and when the processor executes the computer instruction, the electronic device executes the method described in any one of claims 1 to 6.
