Data compression method and device, data decompression method and device, equipment and storage medium

By splitting and merging the number of bytes and offsets in the character sequence, the data compression and decompression methods are optimized, which solves the problem of low storage space utilization when APP frequently switches front and backend, and improves compression efficiency and operation efficiency.

CN118944675APending Publication Date: 2024-11-12NANJING OPPO SOFTWARE TECH CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310539090.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-12
Publication Date
2024-11-12

Smart Images

  • Figure CN118944675A_ABST
    Figure CN118944675A_ABST
Patent Text Reader

Abstract

The invention provides a data compression method and device, a data decompression method and device, equipment and a storage medium, and belongs to the technical field of application. Under the condition that the first byte number of a first character string in the character sequence to be compressed is greater than a first preset byte number, splitting the first byte number into a first preset byte number and a second byte number, and storing the first preset byte number into a first byte of the compression block, the first preset byte number is the maximum storage amount of the byte number used for storing the first character string in the first byte; determining the offset of a target character string, wherein the target character string is a character string with a matched character string in the compressed block; and merging the second byte number with the offset, and storing a first numerical value obtained by merging into a second byte of the compressed block. According to the invention, the space utilization rate can be improved, and a better compression effect can be obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of application technology, and in particular to a data compression method, a data decompression method, a device, a equipment and a storage medium. Background Art

[0002] In order to obtain greater operating memory utilization and application (APP) preservation rate, the terminal often compresses the APP running in the background through a compression algorithm. When the APP switches from the background to the foreground, the compressed APP is decompressed through the decompression algorithm corresponding to the compression algorithm. Since the APP may need to switch between the foreground and the background frequently, the compression algorithm often uses the Lz4 compression algorithm, which has a very fast compression speed and corresponding decompression speed. Summary of the invention

[0003] The embodiments of the present application provide a data compression method, a data decompression method, a device, a equipment and a storage medium, which can improve the utilization rate of storage space. The technical solution is as follows:

[0004] In one aspect, a data compression method is provided, the method comprising:

[0005] When the first byte number of the first character string in the character sequence to be compressed is greater than the first preset byte number, splitting the first byte number into the first preset byte number and the second byte number, and storing the first preset byte number in the first byte of the compressed block corresponding to the character sequence, wherein the first preset byte number is the maximum storage capacity of the byte number used to store the first character string in the first byte;

[0006] Determine an offset of a target string, wherein the target string is a string for which a matching string exists in the compressed block;

[0007] The second byte number and the offset are combined, and a first value obtained by the combination is stored in the second byte of the compressed block.

[0008] On the other hand, a data decompression method is provided, the method comprising:

[0009] Obtaining a compressed block, where the compressed block is a data block obtained by compressing a character sequence;

[0010] Read the number of bytes of the first character string to be decompressed currently stored in the first byte of the compressed block;

[0011] When the number of bytes of the first character string stored in the first byte is equal to a first preset number of bytes, reading a first value stored in a second byte in the compressed block, the first preset number of bytes being a maximum storage capacity of the number of bytes in the first byte for storing the first character string;

[0012] Splitting the first value into a second number of bytes and an offset;

[0013] Combining the first preset number of bytes and the second number of bytes into a first number of bytes, where the first number of bytes is the number of bytes of the first character string;

[0014] Based on the first number of bytes and the offset, the compressed block is decompressed to obtain the character sequence.

[0015] In another aspect, a data compression device is provided, the device comprising:

[0016] A first splitting module is used for splitting a first byte number into the first preset byte number and a second byte number when the first byte number of a first character string in the character sequence to be compressed is greater than a first preset byte number, and storing the first preset byte number in the first byte of a compression block corresponding to the character sequence, wherein the first preset byte number is a maximum storage capacity of the first byte for storing the byte number of the first character string;

[0017] A first determination module, configured to determine an offset of a target string, wherein the target string is a string for which a matching string exists in the compressed block;

[0018] The compression module is used to merge the second byte number with the offset, and store the merged first value into the second byte of the compression block.

[0019] In another aspect, a data decompression device is provided, the device comprising:

[0020] An acquisition module, used for acquiring a compressed block, wherein the compressed block is a data block obtained by compressing a character sequence;

[0021] A reading module, used for reading the number of bytes of the first character string to be decompressed currently stored in the first byte of the compressed block;

[0022] The reading module is further configured to read the first value stored in the second byte in the compressed block when the number of bytes of the first character string stored in the first byte is equal to a first preset number of bytes, where the first preset number of bytes is a maximum storage capacity of the number of bytes in the first byte for storing the first character string;

[0023] A second splitting module, used for splitting the first value into a second number of bytes and an offset;

[0024] a merging module, configured to merge the first preset number of bytes and the second number of bytes into a first number of bytes, where the first number of bytes is the number of bytes of the first character string;

[0025] A decompression module is used to decompress the compressed block based on the first number of bytes and the offset to obtain the character sequence.

[0026] On the other hand, a terminal is provided, comprising one or more processors and one or more memories, wherein at least one program code is stored in the one or more memories, and the at least one program code is loaded and executed by the one or more processors to implement the data compression method described in any of the above implementation methods.

[0027] On the other hand, a terminal is provided, comprising one or more processors and one or more memories, wherein at least one program code is stored in the one or more memories, and the at least one program code is loaded and executed by the one or more processors to implement the data decompression method described in any of the above implementation methods.

[0028] On the other hand, a computer-readable storage medium is provided, in which at least one program code is stored. The at least one program code is loaded and executed by a processor to implement the data compression method described in any of the above implementations.

[0029] On the other hand, a computer-readable storage medium is provided, in which at least one program code is stored. The at least one program code is loaded and executed by a processor to implement the data decompression method described in any of the above implementations.

[0030] On the other hand, a computer program product is provided, wherein the computer program product stores at least one program code, and the at least one program code is used to be executed by a processor to implement the data compression method as described in any of the above implementations.

[0031] On the other hand, a computer program product is provided, wherein the computer program product stores at least one program code, and the at least one program code is used to be executed by a processor to implement the data decompression method as described in any of the above implementations.

[0032] In an embodiment of the present application, when the first byte number of the first character string in the character sequence exceeds the first preset byte number, the excess second byte number in the first byte number is merged with the offset and stored in the second byte originally used to store the offset, thereby improving space utilization and achieving better compression effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 A flow chart of a data compression method shown in an exemplary embodiment of the present application is shown;

[0034] Figure 2 A flow chart of a data compression method shown in an exemplary embodiment of the present application is shown;

[0035] Figure 3 A flow chart of a data compression method shown in an exemplary embodiment of the present application is shown;

[0036] Figure 4 A schematic diagram of a storage structure of a compressed block shown in an exemplary embodiment of the present application is shown;

[0037] Figure 5 A schematic diagram of a storage structure of a compressed block shown in an exemplary embodiment of the present application is shown;

[0038] Figure 6 A flow chart of a data compression method shown in an exemplary embodiment of the present application is shown;

[0039] Figure 7 A schematic diagram of a storage structure of a compressed block shown in an exemplary embodiment of the present application is shown;

[0040] Figure 8 A schematic diagram of a data decompression method shown in an exemplary embodiment of the present application is shown;

[0041] Fig. 9 A flow chart of a data decompression method shown in an exemplary embodiment of the present application is shown;

[0042] Fig.10 A flow chart of a data decompression method shown in an exemplary embodiment of the present application is shown;

[0043] Fig.11 A flow chart of a data decompression method shown in an exemplary embodiment of the present application is shown;

[0044] Fig.12 A block diagram of a data compression device shown in an exemplary embodiment of the present application is shown;

[0045] Fig.13 A block diagram of a data decompression device shown in an exemplary embodiment of the present application is shown;

[0046] Fig.14 A block diagram of a terminal according to an exemplary embodiment of the present application is shown. DETAILED DESCRIPTION

[0047] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0048] The term "multiple" as used herein refers to two or more than two. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the related objects are in an "or" relationship.

[0049] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions. For example, the number of bytes and offsets involved in this application are all obtained with full authorization.

[0050] The data compression method and data decompression method provided in the embodiments of the present application are applied to a terminal. The terminal compresses a character sequence to be compressed by using a compression algorithm to obtain a compressed block. The terminal decompresses the compressed block by using a decompression algorithm corresponding to the compression algorithm to obtain a character sequence.

[0051] The character sequence to be compressed may be any character sequence; for example, the character sequence to be compressed may be a character sequence corresponding to an APP running in the background, a character sequence corresponding to a picture, a character sequence corresponding to a video, or a character sequence corresponding to an audio, etc. The terminal may be a mobile phone, a tablet computer, a vehicle-mounted terminal, or a wearable device, etc. In the embodiment of the present application, the character sequence to be compressed is taken as an example to be described as a character sequence corresponding to an APP running in the background.

[0052] Please refer to Figure 1 , which shows a flowchart of a data compression method shown in an exemplary embodiment of the present application. The execution subject in the embodiment of the present application is a terminal. Figure 1 , the method comprising:

[0053] Step 101: when the first byte number of the first character string in the character sequence to be compressed is greater than the first preset byte number, split the first byte number into the first preset byte number and the second byte number, and store the first preset byte number in the first byte of the compressed block corresponding to the character sequence.

[0054] The first string is the string to be stored in the character sequence; the terminal determines the difference between the first byte number and the first preset byte number to obtain the second byte number. The first preset byte number is the maximum storage capacity of the number of bytes used to store the first string in the first byte. The first byte can be one byte or multiple bytes; in the embodiment of the present application, the first byte is taken as an example for explanation. The first string can be a matching string or a non-matching string; and the first byte can be used to store a matching string, can be used to store a non-matching string, and can also be used to store a matching string and a non-matching string at the same time; and, in the case where the first byte is used to store a matching string and a non-matching string, the storage space used to store the matching string and the non-matching string in the first byte can be the same or different; in the embodiment of the present application, the first byte is taken as one byte, and the storage space used by the first byte to store the matching string and the non-matching string is the same as an example for explanation, that is, 4 bits in the first byte are used to store the matching string, and 4 bits are used to store the non-matching string; accordingly, the first preset byte number is 15.

[0055] Step 102: Determine the offset of the target string, where the target string is a string for which a matching string exists in the compressed block.

[0056] Prior to this step, the terminal performs a scanning operation on the character sequence to be compressed to obtain a scanning result of the first character string currently scanned, and the scanning result is used to indicate whether there is a second character string matching the first character string in the compressed block corresponding to the character sequence. In this step, the terminal determines the offset of the target character string based on the scanning result.

[0057] In the case where the scanning result is used to indicate that there is a second string matching the first string in the compressed block, that is, the first string is a matching string, and the first string has a corresponding offset, then the target string is the first string. In the case where the scanning result is used to indicate that there is no second string matching the first string in the compressed block, the first string is a non-matching string, and the first string has no corresponding offset, then the target string may be a matching string stored in the compressed block, that is, the target string is a string located before the first string in the character sequence.

[0058] The terminal compresses the character sequence through a compression algorithm to obtain a compressed block. The compression algorithm may be an Lz4 compression algorithm. The compression principle of the Lz4 algorithm is: by scanning each character string, and when a character string is scanned, determining whether there is a character string matching the character string in the compressed block; if there is no character string matching the character string in the compressed block, storing the character string in the compressed block; if there is a character string matching the character string in the compressed block, determining the number of bytes and the offset of the character string, and storing the number of bytes and the offset in the compressed block, so as to facilitate the subsequent recovery of the character string based on the number of bytes and the offset of the character string.

[0059] In some embodiments, the terminal performs a scanning operation on the character sequence to be compressed through a sliding window, and the first character string is a character string in the character sequence that is located within the sliding window. The length of the sliding window can be set and changed according to the compression algorithm used; for example, the compression algorithm used in this application is Lz4, and the length of the sliding window is 4. The character sequence to be compressed can be a character sequence corresponding to an APP running in the background; for example, when the terminal switches the APP from the foreground to the background, the terminal determines the character sequence corresponding to the APP, and then performs a scanning operation on the character sequence.

[0060] In some embodiments, when the scanning result is used to indicate that there is a second string matching the first string in the compressed block, the first string can be referred to as a matched string; and when the scanning result is used to indicate that there is no second string matching the first string in the compressed block, the first string can be referred to as an unmatched string.

[0061] Step 103: Combine the second byte number and the offset, and store the combined first value into the second byte of the compressed block.

[0062] The second byte can be multiple bytes; in the embodiment of the present application, the second byte is 2 bytes as an example for explanation. In some embodiments, the storage space of the second byte is not less than the storage space occupied by the character sequence to be compressed; therefore, after the offset is stored in the second byte, there is still a certain amount of remaining space, and the second byte number is stored in the remaining space. For example, the character sequence is compressed with 4kb as input; the second byte is 2 bytes, then the maximum supported compression length of 2byte (16 bits) is 65535, and the character sequence to be compressed of the terminal is compressed with 4kb pages as input, and the length of 4bk is 4096, only 12 bits are needed; therefore, a waste of storage space is caused. In the embodiment of the present application, the remaining 4 bits are used to store the second byte number, avoiding memory loss caused by premature use of subsequent space, thereby improving the compression rate.

[0063] In an embodiment of the present application, when the first byte number of the first character string in the character sequence exceeds the first preset byte number, the excess second byte number in the first byte number is merged with the offset and stored in the second byte originally used to store the offset, thereby improving space utilization and achieving better compression effect.

[0064] Please refer to Figure 2 , which shows a flowchart of a data compression method shown in an exemplary embodiment of the present application. In the embodiment of the present application, an example is given in which the matching string and the offset are combined and stored in the second byte for storing the offset. Figure 2 , the method comprising:

[0065] Step 201: The terminal performs a scanning operation on the character sequence to be compressed to obtain a scanning result of the currently scanned first character string, where the scanning result is used to indicate whether there is a second character string matching the first character string in the compressed block corresponding to the character sequence.

[0066] In some embodiments, this step is the same as the scanning process in step 102 and will not be repeated here.

[0067] Step 202: If the scanning result indicates that a second character string matching the first character string exists in the compressed block corresponding to the character sequence, the terminal updates the first byte number of the first character string to the difference between the first byte number and the third preset byte number.

[0068] The first preset number of bytes is the maximum storage capacity of the number of bytes in the first byte for storing the first string. In the case where the scanning result is used to indicate that there is a second string matching the first string in the compressed block corresponding to the character sequence, the first string is a matching string. The third preset number of bytes is the minimum value of the matching number of bytes; for example, the compression algorithm is Lz4, and the minimum matching number of bytes supported by Lz4 is 4; then the third preset number of bytes can be 4.

[0069] In the embodiment of the present application, the terminal updates the first byte number of the first character string to the difference between the first byte number and the third preset byte number, which can reduce the storage space occupied by the first byte number, thereby improving the utilization of the storage space and further improving the compression effect.

[0070] For example, see Figure 3 , the terminal starts compressing the character sequence, the first string is the matching string, and the first byte number of the first string is N, then the terminal updates N to N-4.

[0071] Step 203: When the first byte number is greater than the first preset byte number, split the first byte number into the first preset byte number and the second byte number.

[0072] The terminal determines whether the first byte number of the first character string is greater than the first preset byte number; if the first byte number of the first character string is greater than the first preset byte number, determines the difference between the first byte number and the first preset byte number to obtain a second byte number.

[0073] Step 204: the terminal determines the fourth byte number of the unmatched character string, combines the first preset byte number and the fourth byte number, and stores the combined third value into the first byte of the compressed block.

[0074] Among them, the fourth byte number is the number of bytes of the unmatched string. When the fourth byte number of the unmatched string is not greater than the first preset byte number, the terminal merges the first preset byte number and the fourth byte number, and stores the merged third value in the first byte of the compressed block. When the fourth byte number is greater than the first preset byte number, the terminal splits the fourth byte number into the first preset byte number and the fifth byte number, merges the first preset byte number and the first preset byte number, stores the merged third value in the first byte of the compressed block, and stores the fifth byte number in the fifth byte of the compressed block. The fifth byte can be one byte or multiple bytes. For example, one byte can store 255 bits of data. When the fifth byte number does not exceed 255, the fifth byte is one byte; when the fifth byte number exceeds 255, the fifth byte is multiple bytes.

[0075] The step of the terminal combining the first preset byte number and the fourth byte number and storing the combined third value in the first byte of the compressed block may be: the terminal converts the first preset byte number and the fourth byte number into binary data respectively, and concatenates the binary data corresponding to the fourth byte number and the first preset byte number respectively to obtain the third value. For example, the first byte is 1 byte, and the third value is obtained by continuing to refer to Figure 3 , the fourth byte number of the unmatched string is N, the terminal merges M and N and stores them in 1byte, and when M is greater than the first preset byte number (15), M is updated to the first preset byte number (15), and when N is greater than the first preset byte number, N is updated to the first preset byte number (15). After the terminal stores the merged M and N, when M is greater than the first preset byte number, the terminal stores M-the first preset byte number.

[0076] For example, see Figure 4 , the terminal combines M (up to 15) and N (up to 15) and stores them in the first byte (1 byte) of the compressed block. When M exceeds the first preset number of bytes, the terminal stores M-the first preset number of bytes.

[0077] Step 205: The terminal stores the unmatched character string in the fourth byte of the compressed block.

[0078] The number of the fourth byte is the same as the number of the fourth byte of the unmatched string; for example, if the number of the fourth byte of the unmatched string is 2, then the number of the fourth byte is also 2. Figure 3 After the terminal stores M, the terminal stores the unmatched string. And, continue to refer to Figure 4 , the unmatched string is stored in the fourth byte after the M unmatched strings in the compressed block.

[0079] Step 206: The terminal determines the offset of the first character string.

[0080] The offset of the first character string is used to indicate the number of bytes that differ between the first character string and the second character string.

[0081] Step 207: The terminal combines the second byte number with the offset, and stores the combined first value into the second byte of the compressed block.

[0082] In some embodiments, the step of the terminal combining the second byte number with the offset may be implemented by the following steps (1) and (2), including:

[0083] (1) The terminal converts the second byte number and the offset into binary data respectively.

[0084] (2) The terminal combines the binary data corresponding to the second byte number and the offset to obtain a first value.

[0085] The value corresponding to the second byte number is less than the value corresponding to the offset; when the storage mode of the compressed block is the first storage mode, the terminal concatenates the binary data corresponding to the second byte number with the binary data corresponding to the offset, and the first storage mode is a mode in which bytes are stored in ascending order; the first storage mode may be a little-endian storage mode. For example, continue to refer to Figure 4 , in the second byte of the compressed block, the second byte number (N-15) is sorted before the offset (D).

[0086] When the storage mode of the compressed block is the second storage mode, the terminal concatenates the binary data corresponding to the offset with the binary data corresponding to the second value, and the second storage mode is a mode in which bytes are stored in descending order; the second storage mode may be a big-endian storage mode. For example, see Figure 5 , in the second byte of the compressed block, the second byte number (N-15) is sorted after the offset (D).

[0087] In some embodiments, when the second byte number is not greater than the second preset byte number, the terminal combines the second byte number with the offset, and stores the combined first value in the second byte of the compressed block; the second preset byte number is the maximum storage capacity of the number of bytes used to store the first character string in the second byte. When the second byte number is greater than the second preset byte number, the terminal splits the second byte number into the second preset byte number and the third byte number, combines the second preset byte number with the offset, stores the combined second value in the second byte of the compressed block, and stores the third byte number in the third byte of the compressed block.

[0088] The second preset number of bytes is the maximum storage capacity of the number of bytes used to store the first character string in the second byte; for example, 2 bits in the second byte are used to store the number of bytes of the first character string; then the second preset number of bytes is 30, and further see Figure 4 , when N is greater than 30, the terminal stores N-30 in the third byte of the compressed block.

[0089] In the embodiment of the present application, if the size of N is between 15 and 30, the new storage structure will save 1 byte of space in each compressed block compared to the previous one. For a 4kb page, many compressed blocks may be formed after the compression algorithm, which can save considerable space.

[0090] In an embodiment of the present application, the second byte number that is extra in the first byte number of the matching string is combined with the offset and stored in the second byte originally used to store the offset, thereby improving space utilization and achieving better compression effect.

[0091] In addition, since a judgment statement for determining whether the first byte number is equal to the first preset byte number and a combined bit operation are added during the compression process, these two operations will basically not affect the original compression performance; therefore, the embodiment of the present application can achieve the purpose of saving space by adding a small number of steps.

[0092] Please refer to Figure 6 , which shows a flow chart of a data compression method shown in an exemplary embodiment of the present application. In the embodiment of the present application, an example is given in which the number of bytes and the offset of the unmatched string are combined and stored in the second byte for storing the offset. Figure 6 , the method comprising:

[0093] Step 601: The terminal performs a scanning operation on the character sequence to be compressed to obtain a scanning result of the first character string currently scanned, where the scanning result is used to indicate whether there is a second character string matching the first character string in the compressed block corresponding to the character sequence.

[0094] In some embodiments, this step is the same as the scanning process in step 102 and will not be repeated here.

[0095] Step 602: When the scanning result indicates that there is no second string matching the first string in the compressed block corresponding to the character sequence, and the first byte number of the first string is greater than the first preset byte number, the terminal splits the first byte number into the first preset byte number and the second byte number.

[0096] The first preset number of bytes is the maximum storage capacity of the number of bytes in the first byte for storing the first character string. When the scanning result is used to indicate that there is no second character string matching the first character string in the compressed block corresponding to the character sequence, the first character string is an unmatched character string, and the terminal determines the difference between the first number of bytes and the first preset number of bytes to obtain the second number of bytes.

[0097] Step 603: The terminal determines the fifth byte number of the matching character string.

[0098] The matching string refers to a string that matches the string in the compressed block. The matching string can be a string that is located before the first string in the character sequence.

[0099] Step 604: The terminal combines the first preset byte number and the fifth byte number, and stores the combined fourth value into the first byte of the compressed block.

[0100] In some embodiments, the process by which the terminal combines the first preset number of bytes and the fifth number of bytes is similar to the process by which the terminal combines the second number of bytes and the offset, and is not described in detail here.

[0101] In some embodiments, when the fifth byte number is not greater than the first preset byte number, the terminal combines the first preset byte number and the fifth byte number, and stores the combined fourth value in the first byte of the compressed block. When the fifth byte number is greater than the first preset byte number, the terminal splits the fifth byte number into the first preset byte number and the sixth byte number, combines the first preset byte number and the first preset byte number, stores the combined fifth value in the first byte of the compressed block, and stores the sixth byte number in the sixth byte of the compressed block.

[0102] For example, see Figure 7 , the first string is an unmatched string, the first byte number of the first string is M, the byte number of the matching string is N, and the terminal stores M and N in 1 byte of the compressed block.

[0103] Step 605: When the offset is stored in the second byte, the terminal reads the offset stored in the second byte.

[0104] The offset is the offset of the matching string that precedes the first string in the character sequence.

[0105] Step 606: The terminal combines the second byte number with the offset, and stores the combined first value into the second byte of the compressed block.

[0106] In some embodiments, this step is the same as step 207 and will not be repeated here.

[0107] In some embodiments, when the second byte number is not greater than the second preset byte number, the terminal combines the second byte number with the offset, and stores the combined first value in the second byte of the compressed block. When the second byte number is greater than the second preset byte number, the terminal splits the second byte number into the second preset byte number and the third byte number, combines the second preset byte number with the offset, stores the combined second value in the second byte of the compressed block, and stores the third byte number in the third byte of the compressed block. The third byte may be a byte in the compressed block that is adjacent to the first byte and located after the first byte; for example, continue to refer to Figure 6 The terminal merges M and N into 1 byte in the compressed block, then stores M-the third preset byte number (30) in the compressed block, and then stores the unmatched string M, and then stores the merged result of M-the first preset byte number (15) and D, and then stores N-the first preset byte number (15).

[0108] Step 607: When the offset is not stored in the second byte, the terminal stores the second byte number in the second byte of the compressed block.

[0109] In some embodiments, the terminal converts the second byte number into binary data, and stores the binary data corresponding to the second byte number into the second byte of the compressed block.

[0110] In an embodiment of the present application, the extra second byte number in the first byte number of the unmatched string is combined with the offset and stored in the second byte originally used to store the offset, thereby improving space utilization and achieving better compression effect.

[0111] Please refer to Figure 8 , which shows a flowchart of a data decompression method shown in an exemplary embodiment of the present application. The execution subject of the method is a terminal, see Figure 8 , the method comprising:

[0112] Step 801: Obtain a compressed block, where the compressed block is a data block obtained by compressing a character sequence.

[0113] The character sequence may be a character sequence corresponding to an APP running in the background; accordingly, when the terminal switches the APP from running in the background to running in the foreground, the terminal obtains a compressed block corresponding to the APP, and then decompresses the compressed block using a decompression algorithm corresponding to the compression algorithm.

[0114] Step 802: Read the number of bytes of the first character string to be decompressed currently stored in the first byte of the compressed block.

[0115] The first byte can store the number of bytes of the first string and the number of bytes of other strings; for example, if the first string is a matching string, the first byte stores the number of bytes of the first string and the number of bytes of other non-matching strings. For another example, if the first string is a non-matching string, the first byte stores the number of bytes of the first string and the number of bytes of other matching strings.

[0116] Step 803: When the number of bytes storing the first character string in the first byte is equal to the first preset number of bytes, split the first value into a second number of bytes and an offset.

[0117] The first preset number of bytes is the maximum storage capacity of the first byte for storing the number of bytes of the first character string to be decompressed. The terminal splits the first value into binary data corresponding to the second byte number and the offset, respectively, and converts the binary data corresponding to the second byte number and the offset into decimal data to obtain the second byte number and the offset.

[0118] In some embodiments, when the storage mode of the compressed block is the first storage mode, the terminal splits the first value into binary data corresponding to the second byte number and the offset based on the proportion of bit bits occupied by the second byte number and the offset respectively; for example, the second byte number occupies 4 bits and the offset occupies 12 bits, then the terminal determines the first 4 bits of the first value as the binary data corresponding to the second byte number, and determines the last 12 bits of the first value as the binary data corresponding to the offset.

[0119] In some embodiments, when the storage mode of the compressed block is the second storage mode, the terminal splits the first value into binary data corresponding to the offset and the second byte number based on the proportion of the second byte number and the offset respectively; for example, the second byte number occupies 4 bits and the offset occupies 12 bits, then the terminal determines the first 12 bits of the first value as the binary data corresponding to the offset, and determines the last 4 bits of the first value as the binary data corresponding to the second byte number.

[0120] Step 804: Combine the first preset byte number and the second byte number into a first byte number, where the first byte number is the byte number of the first character string.

[0121] The terminal determines the sum of the first preset byte number and the second byte number to obtain the first byte number.

[0122] Step 805: Based on the first byte number and the offset, decompress the compressed block to obtain a character sequence.

[0123] In the embodiment of the present application, the second byte stores the value of the second byte number in excess of the first byte number combined with the offset, thereby improving space utilization and achieving better compression effect.

[0124] Please refer to Fig. 9 , which shows a flow chart of a data decompression method shown in an exemplary embodiment of the present application. In the embodiment of the present application, when performing data compression, the number of bytes of the matching string and the offset are combined and stored in the second byte for storing the offset. See Fig. 9 , the method comprising:

[0125] Step 901: The terminal obtains a compressed block, which is a data block obtained by compressing a character sequence.

[0126] In some embodiments, this step is the same as step 901 and will not be repeated here.

[0127] Step 902: The terminal reads the number of bytes of the first character string to be decompressed stored in the first byte of the compressed block.

[0128] Step 903: The terminal determines a fourth byte number, where the fourth byte number is the number of bytes of the unmatched character string.

[0129] In an embodiment of the present application, the first string is taken as the matching string, and the number of bytes of the matching string and the number of bytes of the non-matching string are stored in the first byte; accordingly, steps 902-903 may be: the terminal reads the third value stored in the first byte in the compressed block and splits it into the fourth byte number and the number of bytes of the first string.

[0130] For example, see Fig.10 , terminal decompression begins, separating the number of bytes M of the unmatched string and the number of bytes N of the matched string from the first 1 byte of the compressed block to obtain M and N.

[0131] Step 904: The terminal reads the unmatched character string from the compressed block based on the fourth byte number.

[0132] In some embodiments, when the fourth byte number is not equal to the first preset byte number, the terminal copies the fourth byte from the memory address of the unmatched string in the compressed block to the memory address of the stored string. When the fourth byte number is equal to the first preset byte number, the terminal determines the value stored in the next byte of the first byte in the compressed block; when the value stored in the next byte is not equal to the fourth preset byte number, the fourth byte number is updated to the sum of the fourth byte number and the value stored in the next byte, and based on the updated fourth byte number, the unmatched string is read from the compressed block.

[0133] When the value stored in the next byte is equal to the fourth preset byte number, the terminal determines the value stored in the next byte of the next byte in the compressed block; when the value stored in the next byte of the next byte is not equal to the fourth preset byte number, the terminal updates the fourth byte number to the sum of the fourth byte number, the value stored in the next byte, and the value stored in the next byte of the next byte, and then reads the unmatched string from the compressed block based on the updated fourth byte number, and so on, until the unmatched string is obtained.

[0134] The fourth preset number of bytes may be the maximum number of bytes allowed to be stored in one byte; for example, the fourth preset number of bytes is 255. Fig.10 , the terminal determines whether M is equal to 15. If M is not equal to 15, the terminal copies M bytes from the next src to dst; if M is equal to 15, the terminal determines whether b is equal to 255; if b is not equal to 255, M is updated to M+b; if b is equal to 255, it determines whether the b stored in the next byte of the next byte is equal to 255, and M bytes are copied from the next src to dst until M is updated. Among them, src refers to the memory address of the character to be decompressed during the decompression process, and dst refers to the memory address to be stored after decompression during the decompression process.

[0135] Step 905: When the number of bytes of the first character string stored in the first byte is equal to the first preset number of bytes, the terminal reads the first value stored in the second number of bytes in the compressed block.

[0136] The first value is a value obtained by combining the second byte number of the additional matching string and the offset.

[0137] Step 906: The terminal splits the first value into a second number of bytes and an offset.

[0138] In some embodiments, this step is the same as the step of splitting the first value into the second number of bytes and the offset in step 903, and will not be repeated here.

[0139] For example, see Fig.10 , the first 4 bits of the first value are N_tmp (the second byte number) and the last 12 bits are the offset.

[0140] Step 907: when the number of bytes of the first character string read from the first byte is equal to the first preset number of bytes, the terminal combines the first preset number of bytes and the second number of bytes into a first number of bytes, where the first number of bytes is the number of bytes of the first character string.

[0141] In some embodiments, the terminal determines the sum of the first preset number of bytes and the second number of bytes to obtain the first number of bytes, and updates the first number of bytes to the sum of the first number of bytes and the third preset number of bytes. Since the first number of bytes is updated to the difference between the first number of bytes and the third preset number of bytes when data compression is performed; therefore, when data decompression is performed, the first number of bytes is updated to the sum of the first number of bytes and the third preset number of bytes. For example, the third preset number of bytes may be 4. In some embodiments, when the number of bytes of the first character string read from the first byte is not equal to the first preset number of bytes, the terminal determines the sum of the number of bytes of the first character string read from the first byte and the third preset number of bytes as the first number of bytes.

[0142] In some embodiments, when the second byte number is not less than the second preset byte number, the third byte number is read from the third byte of the compressed block; the second byte number is updated to the sum of the second byte number and the third byte number; the first preset byte number and the updated second byte number are combined into the first byte number. The third byte is the byte after the first byte; for example, continue to refer to Fig.10 , the terminal determines whether N is equal to 15; when N is equal to 15, N is updated to N+N_tmp+4; when N is not equal to 15, N is updated to N+4.

[0143] In some embodiments, when the first byte number is large, for example, when the first byte number exceeds 30, the terminal stores the portion exceeding 30 in the next byte when compressing the character sequence; therefore, in this step, the terminal determines whether the first byte number is equal to the fifth preset byte number. When the first byte number is equal to the fifth preset byte number, the terminal determines the value stored in the next byte of the second byte in the compressed block. When the value stored in the next byte of the second byte is not equal to the fourth preset byte number, the first byte number is updated to the sum of the first byte number and the value stored in the next byte.

[0144] When the value stored in the next byte of the second byte is equal to the fourth preset byte number, the terminal determines the value stored in the next byte of the next byte of the second byte; when the value stored in the next byte of the next byte is not equal to the fourth preset byte number, the terminal updates the first byte number to the sum of the first byte number and the value stored in the next byte and the value stored in the next byte of the next byte, and so on, until the first byte number is updated and obtained. The fifth preset byte number can be 30.

[0145] For example, see Fig.10 , the terminal determines whether N is equal to 34; when N is equal to 34, the terminal determines whether b stored in the next byte of the second byte is equal to 255; when b is not equal to 255, N is updated to N+b; when b is equal to 255, N is updated to N+255, and then it is determined whether b stored in the next byte of the next byte of the second byte is equal to 255. When b stored in the next byte of the next byte of the second byte is equal to 255, the terminal updates N to N+255 again, and so on, until it is obtained that b is not 255, at which time N is updated to N+b to obtain the final updated b.

[0146] Step 908: The terminal reads a first character string from the compressed block based on the first byte number and the offset.

[0147] For example, see Fig.10 , the terminal copies the N-byte string from src to dst according to D and N.

[0148] Step 909: The terminal combines the unmatched character string and the first character string into a character sequence.

[0149] In the embodiment of the present application, the second byte stores the value of the second byte number in excess of the first byte number combined with the offset, thereby improving space utilization and achieving better compression effect.

[0150] Please refer to Fig.11 , which shows a flow chart of a data decompression method shown in an exemplary embodiment of the present application. In the embodiment of the present application, when performing data compression, the number of bytes and the offset of the unmatched string are combined and stored in the second byte for storing the offset. See Fig.11 , the method comprising:

[0151] Step 1101: The terminal obtains a compressed block, which is a data block obtained by compressing a character sequence.

[0152] In some embodiments, this step is the same as step 801 and will not be repeated here.

[0153] Step 1102: The terminal reads the number of bytes of the first character string to be decompressed stored in the first byte of the compressed block.

[0154] Step 1103: The terminal determines the fifth byte number, which is the number of bytes of the matching character string.

[0155] In an embodiment of the present application, the first string is taken as a non-matching string, and the number of bytes of the matching string and the number of bytes of the non-matching string are stored in the first byte; accordingly, steps 1102-1103 may be: the terminal reads the third value stored in the first byte in the compressed block and splits it into the fifth byte number and the number of bytes of the first string.

[0156] Step 1104: when the number of bytes of the first character string stored in the first byte is equal to the first preset number of bytes, the terminal reads the first value stored in the second number of bytes in the compressed block.

[0157] The first value is a value obtained by combining the second byte number of the additional non-matching string and the offset.

[0158] Step 1105: The terminal splits the first value into a second number of bytes and an offset.

[0159] In some embodiments, this step is the same as the step of splitting the first value into the second number of bytes and the offset in step 803, and will not be repeated here.

[0160] Step 1106: when the number of bytes of the first character string read from the first byte is equal to the first preset number of bytes, the terminal combines the first preset number of bytes and the second number of bytes into a first number of bytes, where the first number of bytes is the number of bytes of the first character string.

[0161] In some embodiments, this step is the same as step 906 and will not be repeated here.

[0162] Step 1107: The terminal reads the unmatched character string from the compressed block based on the first byte number.

[0163] In some embodiments, this step is similar to the step in step 904 where the terminal reads the unmatched character string from the compressed block based on the fourth byte number, and will not be described in detail here.

[0164] Step 1108: The terminal reads the first character string from the compressed block based on the fifth byte number and the offset.

[0165] Step 1109: The terminal combines the unmatched character string and the first character string into a character sequence.

[0166] In the embodiment of the present application, the second byte stores the value of the second byte number in excess of the first byte number combined with the offset, thereby improving space utilization and achieving better compression effect.

[0167] Please refer to Fig.12 , which shows a block diagram of a data compression device shown in an exemplary embodiment of the present application, the device includes:

[0168] A first splitting module 1201 is used for splitting the first byte number into a first preset byte number and a second byte number when the first byte number of the first character string in the character sequence to be compressed is greater than a first preset byte number, and storing the first preset byte number in the first byte of the compressed block corresponding to the character sequence, wherein the first preset byte number is a maximum storage capacity of the byte number for storing the first character string in the first byte;

[0169] A first determination module 1202 is used to determine an offset of a target string, where the target string is a string for which a matching string exists in a compressed block;

[0170] The compression module 1203 is used to merge the second byte number with the offset, and store the merged first value into the second byte of the compressed block.

[0171] In some embodiments, the compression module 1203 is used to convert the second byte number and the offset into binary data respectively; and merge the binary data corresponding to the second byte number and the offset respectively to obtain the first value.

[0172] In some embodiments, the value corresponding to the second byte number is less than the value corresponding to the offset;

[0173] The compression module 1203 is used to concatenate the binary data corresponding to the second number of bytes with the binary data corresponding to the offset when the storage mode of the compression block is the first storage mode, and the first storage mode is a mode in which bytes are stored in ascending order;

[0174] The compression module 1203 is used to concatenate the binary data corresponding to the offset with the binary data corresponding to the second value when the storage mode of the compression block is the second storage mode, and the second storage mode is a mode in which bytes are stored in descending order.

[0175] In some embodiments, the apparatus further comprises:

[0176] A scanning module, used to perform a scanning operation on the character sequence to obtain a scanning result of the first character string currently scanned;

[0177] The first determination module 1202 is configured to determine an offset of the target character string based on the scanning result.

[0178] In some embodiments, the first determination module 1202 is used to determine the offset of the first string when the scanning result indicates that there is a second string matching the first string in the compressed block, and the offset is used to indicate the number of characters that differ between the first string and the second string.

[0179] In some embodiments, the first determination module 1202 is configured to read the offset stored in the second byte when the scanning result indicates that there is no second string matching the first string in the compressed block, but the offset is stored in the second byte.

[0180] In some embodiments, the apparatus further comprises:

[0181] The storage module is used to store the second byte number in the second byte of the compressed block when the scanning result is used to indicate that there is no second string matching the first string in the compressed block and the offset is not stored in the second byte.

[0182] In some embodiments, the compression module 1203 is used to merge the second byte number with the offset when the second byte number is not greater than the second preset byte number, and store the merged first value in the second byte of the compressed block, where the second preset byte number is the maximum storage capacity of the number of bytes in the second byte used to store the first character string.

[0183] In some embodiments, the apparatus further comprises:

[0184] The first splitting module 1201 is further used for splitting the second byte number into the second preset byte number and the third byte number when the second byte number is greater than the second preset byte number, merging the second preset byte number with the offset, and storing the merged second value into the second byte of the compressed block;

[0185] The storage module is used to store the third byte number into the third byte of the compressed block.

[0186] In an embodiment of the present application, when the first byte number of the first character string in the character sequence exceeds the first preset byte number, the excess second byte number in the first byte number is merged with the offset and stored in the second byte originally used to store the offset, thereby improving space utilization and achieving better compression effect.

[0187] It should be noted that the data compression device provided in the above embodiment only uses the division of the above functional modules as an example when performing data compression. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the terminal is divided into different functional modules to complete all or part of the functions described above. In addition, the data compression device provided in the above embodiment and the data compression method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0188] Please refer to Fig.13 , which shows a block diagram of a data compression device shown in an exemplary embodiment of the present application, the device includes:

[0189] An acquisition module 1301 is used to acquire a compressed block, where the compressed block is a data block obtained by compressing a character sequence;

[0190] The reading module 1302 is used to read the number of bytes of the first character string to be decompressed currently stored in the first byte of the compressed block;

[0191] The reading module 1302 is further configured to read the first value stored in the second byte in the compressed block when the number of bytes of the first character string stored in the first byte is equal to a first preset number of bytes, where the first preset number of bytes is a maximum storage capacity of the number of bytes in the first byte for storing the first character string;

[0192] A second splitting module 1303, used for splitting the first value into a second number of bytes and an offset;

[0193] A merging module 1304 is used to merge the first preset byte number and the second byte number into a first byte number, where the first byte number is the byte number of the first character string;

[0194] The decompression module 1305 is used to decompress the compressed block based on the first byte number and the offset to obtain a character sequence.

[0195] In some embodiments, the first number of bytes is the number of bytes of the matching string; the apparatus further comprises:

[0196] A second determining module is used to determine a fourth byte number, where the fourth byte number is the number of bytes of the unmatched character string;

[0197] The reading module is further used to read the unmatched string from the compressed block based on the fourth byte number;

[0198] The decompression module is used to read a first string from the compressed block based on the first byte number and the offset; and compose a character sequence by combining the unmatched string and the first string.

[0199] In some embodiments, the first number of bytes is the number of bytes of the unmatched string; the apparatus further comprises:

[0200] A third determination module is used to determine a fifth byte number, where the fifth byte number is the number of bytes of the matching character string;

[0201] The decompression module 1305 is configured to read an unmatched string from the compressed block based on the first byte number; read a first string from the compressed block based on the fifth byte number and the offset; and combine the unmatched string and the first string into a character sequence.

[0202] In some embodiments, the merging module 1304 is used to read a third byte number from the third byte of the compressed block when the second byte number is not less than the second preset byte number; update the second byte number to the sum of the second byte number and the third byte number; and merge the first preset byte number and the updated second byte number into the first byte number.

[0203] In the embodiment of the present application, the second byte stores the value of the second byte number in excess of the first byte number combined with the offset, thereby improving space utilization and achieving better compression effect.

[0204] It should be noted that the data decompression device provided in the above embodiment only uses the division of the above functional modules as an example when performing data decompression. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the terminal is divided into different functional modules to complete all or part of the functions described above. In addition, the data decompression device provided in the above embodiment and the data decompression method embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0205] Please refer to Fig.14 , which shows a block diagram of a terminal 1400 provided by an exemplary embodiment of the present application. The terminal 1400 in the present application may include one or more of the following components: a processor 1410 , a memory 1420 , and a display screen 1430 .

[0206] The processor 1410 may include one or more processing cores. The processor 1410 uses various interfaces and lines to connect the various parts of the entire terminal 1400, and executes various functions and processes data of the terminal 1400 by running or executing instructions, programs, code sets or instruction sets stored in the memory 1420, and calling data stored in the memory 1420. Optionally, the processor 1410 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 1410 can integrate one or more combinations of a central processing unit (CPU), a graphics processing unit (GPU), a neural network processor (NPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing the content that needs to be displayed on the display screen 1430; the NPU is used to implement artificial intelligence (AI) functions; and the modem is used to process wireless communications. It is understandable that the above-mentioned modem may not be integrated into the processor 1410, but may be implemented by a separate chip.

[0207] The memory 1420 may include a random access memory (RAM) or a read-only memory (ROM). Optionally, the memory 1420 includes a non-transitory computer-readable storage medium. The memory 1420 may be used to store instructions, programs, codes, code sets, or instruction sets. The memory 1420 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc.; the data storage area may store data (such as audio data, a phone book), etc., created according to the use of the terminal 1400.

[0208] The display screen 1430 is a display component for displaying a user interface. Optionally, the display screen 1430 is a display screen with a touch function, through which the user can use any suitable object such as a finger, a touch pen, etc. to perform touch operations on the display screen 1430.

[0209] The display screen 1430 is usually arranged on the front panel of the terminal 1400. The display screen 1430 can be designed as a full screen, a curved screen, a special-shaped screen, a double-sided screen or a folding screen. The display screen 1430 can also be designed as a combination of a full screen and a curved screen, a combination of a special-shaped screen and a curved screen, etc., which is not limited in this embodiment.

[0210] In addition, those skilled in the art can understand that the structure of the terminal 1400 shown in the above drawings does not constitute a limitation on the terminal 1400, and the terminal 1400 may include more or fewer components than shown, or combine certain components, or arrange the components differently. For example, the terminal 1400 also includes an audio acquisition device, a speaker, a radio frequency circuit, an input unit, a sensor, an audio circuit, a wireless fidelity (Wireless Fidelity, Wi-Fi) module, a power supply, a Bluetooth module and other components, which will not be repeated here.

[0211] An embodiment of the present application further provides a computer-readable medium, which stores at least one program code, and the at least one program code is loaded and executed by the processor to implement the data compression method shown in the above embodiments.

[0212] An embodiment of the present application further provides a computer-readable medium, which stores at least one program code, and the at least one program code is loaded and executed by the processor to implement the data decompression method shown in the above embodiments.

[0213] An embodiment of the present application further provides a computer program product, which stores at least one program code, and the at least one program code is loaded and executed by the processor to implement the data compression method shown in the above embodiments.

[0214] An embodiment of the present application further provides a computer program product, which stores at least one program code, and the at least one program code is loaded and executed by the processor to implement the data decompression method shown in the above embodiments.

[0215] In some embodiments, the computer program product involved in the embodiments of the present application may be deployed and executed on one terminal, or on multiple terminals located at one location, or on multiple terminals distributed at multiple locations and interconnected by a communication network. Multiple terminals distributed at multiple locations and interconnected by a communication network may constitute a blockchain system.

[0216] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the embodiments of the present application can be implemented with hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein the communication media include any media that facilitates the transmission of a computer program from one place to another. The storage medium can be any available medium that a general or special-purpose computer can access.

[0217] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A data compression method, It is characterized in that The method comprises: When the first byte number of the first character string in the character sequence to be compressed is greater than the first preset byte number, splitting the first byte number into the first preset byte number and the second byte number, and storing the first preset byte number in the first byte of the compressed block corresponding to the character sequence, wherein the first preset byte number is the maximum storage capacity of the byte number used to store the first character string in the first byte; Determine an offset of a target string, wherein the target string is a string for which a matching string exists in the compressed block; The second byte number and the offset are combined, and a first value obtained by the combination is stored in the second byte of the compressed block.

2. The method according to claim 1, It is characterized in that The merging of the second number of bytes with the offset comprises: Convert the second byte number and the offset into binary data respectively; The binary data corresponding to the second byte number and the offset are combined to obtain the first value.

3. The method according to claim 2, It is characterized in that The value corresponding to the second byte number is less than the value corresponding to the offset; and the binary data corresponding to the second byte number and the offset are merged to obtain the first value, including: When the storage mode of the compressed block is a first storage mode, concatenating the binary data corresponding to the second number of bytes with the binary data corresponding to the offset, wherein the first storage mode is a mode in which bytes are stored in ascending order; When the storage mode of the compressed block is the second storage mode, the binary data corresponding to the offset and the binary data corresponding to the second value are concatenated, and the second storage mode is a mode in which bytes are stored in descending order.

4. The method according to claim 1, It is characterized in that The method further comprises: Performing a scanning operation on the character sequence to obtain a scanning result of the first character string currently scanned; Determining the offset of the target string includes: Based on the scanning result, an offset of the target character string is determined.

5. The method according to claim 4, It is characterized in that Determining the offset of the target string based on the scanning result includes: In a case where the scanning result is used to indicate that a second string matching the first string exists in the compressed block, determining an offset of the first string, the offset being used to indicate the number of characters that differ between the first string and the second string; When the scanning result indicates that there is no second string matching the first string in the compressed block, but an offset is stored in the second byte, the offset stored in the second byte is read.

6. The method according to claim 5, It is characterized in that The method further comprises: When the scanning result indicates that there is no second string matching the first string in the compressed block and the offset is not stored in the second byte, the second byte number is stored in the second byte of the compressed block.

7. The method according to claim 1, It is characterized in that The step of merging the second byte number with the offset and storing the first value obtained by merging into the second byte of the compressed block includes: When the second byte number is not greater than a second preset byte number, the second byte number is merged with the offset, and the merged first value is stored in the second byte of the compressed block, where the second preset byte number is the maximum storage capacity of the number of bytes in the second byte for storing the first character string.

8. The method according to claim 7, It is characterized in that The method further comprises: When the second byte number is greater than the second preset byte number, split the second byte number into the second preset byte number and a third byte number, merge the second preset byte number with the offset, and store the merged second value into the second byte of the compressed block; The third byte number is stored in a third byte of the compressed block.

9. A data decompression method, It is characterized in that The method comprises: Obtaining a compressed block, where the compressed block is a data block obtained by compressing a character sequence; Read the number of bytes of the first character string to be decompressed currently stored in the first byte of the compressed block; When the number of bytes of the first character string stored in the first byte is equal to a first preset number of bytes, reading a first value stored in a second byte in the compressed block, the first preset number of bytes being a maximum storage capacity of the number of bytes in the first byte for storing the first character string; Splitting the first value into a second number of bytes and an offset; Combining the first preset number of bytes and the second number of bytes into a first number of bytes, where the first number of bytes is the number of bytes of the first character string; Based on the first number of bytes and the offset, the compressed block is decompressed to obtain the character sequence.

10. The method according to claim 9, It is characterized in that The first number of bytes is the number of bytes of the matching string; the method further includes: Determine a fourth byte number, where the fourth byte number is the number of bytes of the unmatched character string; Based on the fourth byte number, reading the unmatched string from the compressed block; The decompressing the compressed block based on the first number of bytes and the offset to obtain the character sequence includes: Reading a first string from the compressed block based on the first number of bytes and the offset; The unmatched character string and the first character string are combined into the character sequence.

11. The method according to claim 9, It is characterized in that The first number of bytes is the number of bytes of the unmatched character string; the method further comprises: Determine a fifth byte number, where the fifth byte number is the number of bytes of the matching character string; The decompressing the compressed block based on the first number of bytes and the offset to obtain the character sequence includes: Based on the first number of bytes, reading the unmatched character string from the compressed block; Reading the first string from the compressed block based on the fifth byte number and the offset; The unmatched character string and the first character string are combined into the character sequence.

12. The method according to claim 9, It is characterized in that The step of combining the first preset number of bytes and the second number of bytes into a first number of bytes includes: When the second byte number is not less than a second preset byte number, reading a third byte number from a third byte of the compressed block; Update the second byte number to the sum of the second byte number and the third byte number; The first preset number of bytes and the updated second number of bytes are combined into the first number of bytes.

13. A data compression device, It is characterized in that The device comprises: A first splitting module is used for splitting a first byte number into the first preset byte number and a second byte number when the first byte number of a first character string in the character sequence to be compressed is greater than a first preset byte number, and storing the first preset byte number in the first byte of a compression block corresponding to the character sequence, wherein the first preset byte number is a maximum storage capacity of the first byte for storing the byte number of the first character string; A first determination module, configured to determine an offset of a target string, wherein the target string is a string for which a matching string exists in the compressed block; The compression module is used to merge the second byte number with the offset, and store the merged first value into the second byte of the compression block.

14. A data decompression device, It is characterized in that The device comprises: An acquisition module, used for acquiring a compressed block, wherein the compressed block is a data block obtained by compressing a character sequence; A reading module, used for reading the number of bytes of the first character string to be decompressed currently stored in the first byte of the compressed block; The reading module is further configured to read the first value stored in the second byte in the compressed block when the number of bytes of the first character string stored in the first byte is equal to a first preset number of bytes, where the first preset number of bytes is a maximum storage capacity of the number of bytes in the first byte for storing the first character string; A second splitting module, used for splitting the first value into a second number of bytes and an offset; a merging module, configured to merge the first preset number of bytes and the second number of bytes into a first number of bytes, where the first number of bytes is the number of bytes of the first character string; A decompression module is used to decompress the compressed block based on the first number of bytes and the offset to obtain the character sequence.

15. A terminal, It is characterized in that The terminal includes one or more processors and one or more memories, and at least one program code is stored in the one or more memories. The at least one program code is loaded and executed by the one or more processors to implement the data compression method as described in any one of claims 1 to 8, or to implement the data decompression method as described in any one of claims 9-12.

16. A computer-readable storage medium, It is characterized in that The storage medium stores at least one program code, and the at least one program code is loaded and executed by the processor to implement the data compression method according to any one of claims 1 to 8, or to implement the data decompression method according to any one of claims 9 to 12.

17. A computer program product, It is characterized in that The computer program product stores at least one program code, and the at least one program code is used to be executed by a processor to implement the data compression method according to any one of claims 1 to 8, or to implement the data decompression method according to any one of claims 9-12.