Data compression method and electronic device

By dynamically determining the clustering value according to the file type and data volume, and balancing the data compression rate and the proportion of uncompressed data, the problem of insufficient data compression rate in the existing technology is solved, and more efficient storage space utilization is achieved.

CN117708069BActive Publication Date: 2024-10-08HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310920380.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-24
Publication Date
2024-10-08
Estimated Expiration
2043-07-24

AI Technical Summary

Technical Problem

In the data compression process of existing electronic equipment, due to the fixed clustering value, the amount of data in clusters across nodes is large, and the overall compression rate is affected. Especially when the amount of data is large, the file cannot be effectively compressed and the storage space is lost. Not enough savings.

Method used

By obtaining the file type and data volume of the data to be compressed, the appropriate clustering value is determined, and the data compression rate of each cluster and the proportion of uncompressed data are balanced, thereby improving the overall compression rate. Specific methods include obtaining the file type and data volume, determining the clustering value, and using deduplication processing to obtain compressed data.

Benefits of technology

It improves the overall compression rate of data to be compressed, saves storage space, and is suitable for file data of different types and sizes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117708069B_ABST
    Figure CN117708069B_ABST
Patent Text Reader

Abstract

The embodiments of the present application are applicable to the field of data processing technology, and provide a data compression method and an electronic device, including obtaining a file type of data to be compressed and a first data amount of the data to be compressed, and then determining a first value of the data to be compressed based on the file type and the first data amount, and then compressing the data to be compressed based on the first value to obtain compressed data, wherein the clustering value refers to the number of data blocks in each cluster when the data is clustered, and since the value of the clustering value (the first value) is determined based on the first data amount of the data to be compressed of the file type, it is a value of the clustering value that better matches the data to be compressed, and thus when the value of the clustering value is the first value, it is possible to balance the data compression rate of each cluster of the data to be compressed and the proportion of uncompressed data in the data to be compressed, thereby improving the overall compression rate of the data to be compressed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and more specifically, to a data compression method and an electronic device. Background Art

[0002] At present, a large number of applications are installed in electronic devices. In the process of using these applications, it is usually necessary to store file data generated during the operation of the application. When storing the file data in the memory, the electronic device will compress the file data to save the storage space in the electronic device.

[0003] The electronic device compresses the file data in a process that usually compresses the data according to the clustering compression method. For example, the storage space used to store compressed file data in the electronic device is divided into multiple clusters, and each cluster is divided into multiple data blocks (for example, 8 data blocks). Among them, the electronic device can manage multiple data blocks through the node node, and the number of data blocks corresponding to each node is usually a fixed value (for example, 1018). It can be understood that the number of data blocks in each cluster is a fixed value N, and the data blocks corresponding to each node are also a fixed value i. In a possible case, for example, i cannot be divided by N, so that the data blocks in the same cluster belong to different nodes respectively, that is, there is a situation where the data blocks in the cluster cross nodes. Usually, for the convenience of management, the data in the cluster across nodes is not compressed. In the specific data compression process, if the amount of data in a cluster is large, the situation of compressible duplicate data in the same cluster is large, and the compression rate in the same cluster is high, but at the same time, the amount of data in the cluster across nodes is also large, and these data will not be compressed. Combining these two aspects, the overall compression rate of the data to be compressed will be affected.

[0004] Based on this, how to improve the overall compression rate of the data to be compressed has become an urgent problem to be solved. Summary of the invention

[0005] The present application provides a data compression method, which can improve the overall compression rate of data to be compressed.

[0006] In a first aspect, a data compression method is provided, comprising:

[0007] Obtaining a file type of the data to be compressed and a first data volume of the data to be compressed;

[0008] Determine a first value of the data to be compressed according to the file type and the first data amount, the first value refers to the value of a clustering value when clustering the data to be compressed, and the clustering value refers to the number of data blocks in each cluster when clustering the data;

[0009] The data to be compressed is compressed based on the first value to obtain compressed data.

[0010] The data compression method provided by the embodiment of the present application includes obtaining the file type of the data to be compressed and the first data amount of the data to be compressed, and then determining the first value of the data to be compressed based on the file type and the first data amount, and then compressing the data to be compressed based on the first value to obtain compressed data, wherein the clustering value refers to the number of data blocks in each cluster when the data is clustered. Since the value of the clustering value (the first value) is determined based on the first data amount of the data to be compressed of the file type, it is the value of the clustering value that better matches the first data amount and the file type of the data to be compressed. Therefore, when the value of the clustering value is the first value, the data compression rate of each cluster of the data to be compressed and the proportion of uncompressed data in the data to be compressed can be balanced, thereby improving the overall compression rate of the data to be compressed.

[0011] In combination with the first aspect, in certain embodiments of the first aspect, the above-mentioned determining the first value of the data to be compressed based on the file type and the first data value includes: obtaining a first parameter set based on the file type of the data to be compressed, the first parameter set including multiple first parameters, and the first parameter is used to indicate the data compression rate corresponding to a value of the clustering value; determining a second parameter set based on the first data volume, the second parameter set including multiple second parameters, and the second parameter is used to indicate the data volume of uncompressed data corresponding to a value of the clustering value when the data volume of the data to be compressed is the first data volume; determining the first value based on the first parameter set and the second parameter set.

[0012] In combination with the first aspect, in certain embodiments of the first aspect, determining the first value according to the first parameter set and the second parameter set includes:

[0013] The first value is determined according to the first parameter set, the second parameter set and a first formula, where the first formula includes:

[0014]

[0015] in, represents the first parameter set, m represents the number of bytes of data stored in a data block, S represents the first data amount, N represents the number of data blocks in each cluster, represents the third parameter corresponding to different file types. The third parameter is the parameter that maximizes the covariance between the theoretical compression rate and the actual compression rate. Represents the second parameter set.

[0016] In combination with the first aspect, in certain embodiments of the first aspect, the above-mentioned determination of the first numerical value based on the first parameter set, the second parameter set and the first formula includes: using each parameter in the first parameter set and each parameter in the second parameter set to iterate the first formula, and obtaining N corresponding to the maximum value among multiple Fs as the first numerical value.

[0017] In combination with the first aspect, in certain implementations of the first aspect, the number of bytes m of data stored in a data block is 4096.

[0018] When the number of bytes of data stored in a data block is 4096, the first formula above can be:

[0019]

[0020] In conjunction with the first aspect, in certain embodiments of the first aspect, the value of the clustering value includes 2 n , where n is a positive integer.

[0021] In combination with the first aspect, in some implementations of the first aspect, the value range of the clustering value is [4, 8, 16, 32].

[0022] In the data compression method provided in the embodiment of the present application, the value range of the clustering value is [4, 8, 16, 32], which is equivalent to that the number of values ​​of the clustering value is a finite number, thereby making it possible to reduce the number of iterations in the process of iteratively obtaining the first value based on the clustering value, thereby improving the efficiency of obtaining the first data, that is, improving the efficiency of data compression.

[0023] In combination with the first aspect, in certain embodiments of the first aspect, data compression is performed on the data to be compressed based on the first numerical value to obtain compressed data, including: determining the number of data blocks in each cluster based on the first numerical value; and deduplicating the data in the data blocks in each cluster to obtain compressed data.

[0024] In a second aspect, a data compression device is provided, comprising a unit for executing any one of the methods in the first aspect. The device may be a server, a terminal device, or a chip in a terminal device. The device may include an input unit and a processing unit.

[0025] When the device is a terminal device, the processing unit may be a processor, and the input unit may be a communication interface; the terminal device may also include a memory, which is used to store computer program code. When the processor executes the computer program code stored in the memory, the terminal device executes any one of the methods in the first aspect.

[0026] When the device is a chip in a terminal device, the processing unit may be a processing unit inside the chip, and the input unit may be an output interface, a pin or a circuit, etc.; the chip may also include a memory, which may be a memory inside the chip (for example, a register, a cache, etc.) or a memory located outside the chip (for example, a read-only memory, a random access memory, etc.); the memory is used to store computer program code, and when the processor executes the computer program code stored in the memory, the chip executes any one of the methods in the first aspect.

[0027] In a possible implementation, a memory is used to store computer program code; a processor executes the computer program code stored in the memory, and when the computer program code stored in the memory is executed, the processor is used to perform the following: obtaining a file type of data to be compressed and a first data amount of the data to be compressed; determining a first value of the data to be compressed according to the file type and the first data amount, wherein the clustering value refers to the number of data blocks in each cluster when clustering the data; and compressing the data to be compressed based on the first value to obtain compressed data.

[0028] According to a third aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program code. When the computer program code is executed by a data compression device, the data compression device executes any one of the data compression methods according to the first aspect.

[0029] In a fourth aspect, a computer program product is provided, the computer program product comprising: a computer program code, when the computer program code is executed by a data compression device, the data compression device executes any one of the device methods in the first aspect.

[0030] The data compression method and electronic device provided by the embodiments of the present application include obtaining a file type of data to be compressed and a first data amount of the data to be compressed, and then determining a first value of the data to be compressed based on the file type and the first data amount, and then compressing the data to be compressed based on the first value to obtain compressed data, wherein the clustering value refers to the number of data blocks in each cluster when the data is clustered. Since the value of the clustering value (the first value) is determined based on the first data amount of the data to be compressed of the file type, it is a value of the clustering value that better matches the data to be compressed. Therefore, when the value of the clustering value is the first value, the data compression rate of each cluster of the data to be compressed and the proportion of uncompressed data in the data to be compressed can be balanced, thereby improving the overall compression rate of the data to be compressed. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 It is a schematic diagram of cluster compression;

[0032] Figure 2 It is a schematic diagram of the structure in which a node manages multiple clusters;

[0033] Figure 3 is a schematic diagram of a hardware system of an electronic device applicable to the present application;

[0034] Figure 4 It is a flowchart of a data compression method provided in an embodiment of the present application;

[0035] FIG5(a) is a schematic diagram of compression ratios corresponding to a file type when the clustering value has different values, provided in an embodiment of the present application;

[0036] FIG5(b) is a schematic diagram of compression ratios corresponding to a file type when the clustering value has different values, provided in an embodiment of the present application;

[0037] FIG5(c) is a schematic diagram of compression ratios corresponding to a file type when the clustering value has different values, provided in an embodiment of the present application;

[0038] FIG5(d) is a schematic diagram of compression ratios corresponding to a file type when the clustering value has different values, provided in an embodiment of the present application;

[0039] Figure 6 is a schematic diagram of a data compression device provided by the present application;

[0040] Figure 7 It is a schematic diagram of a data compression electronic device provided by the present application. DETAILED DESCRIPTION

[0041] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0042] In the following, the terms "first", "second", and "third" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first", "second", and "third" may explicitly or implicitly include one or more of the features.

[0043] At present, a large number of applications are installed in electronic devices. In the process of using these applications, it is usually necessary to store file data generated during the operation of the application. When storing the file data in the memory, the electronic device will compress the file data to save the storage space in the electronic device.

[0044] When electronic devices compress file data, they usually compress data using a clustering compression method. Figure 1 As shown in (a) of FIG. 1 , the storage space for storing compressed file data in the electronic device is divided into m clusters Cluster, and each cluster includes N data blocks. It should be understood that the number of data blocks in each cluster is determined based on the clustering value pre-stored in the electronic device. Usually, the number of data blocks in each cluster N, that is, the clustering value N, is 2. n , n is a positive integer. For example, Figure 1 As shown in (a), n is 2, that is, the number of data blocks in each cluster is 4. Data compression according to the clustering compression method generally refers to performing data deduplication processing in each cluster to obtain compressed data. For example, before compressing cluster 1, Figure 1 As shown in (a), data blocks 11, 12, 13, and 14 in cluster 1 store data. After cluster 1 is compressed, data blocks 11 and 12 still store data, and data blocks 13 and 14 are cleared. Compared with cluster 1 before compression, the data in data blocks 13 and 14 are released, saving space in cluster 1.

[0045] It should be understood that an electronic device can manage multiple data blocks through a node node. The number of data blocks corresponding to each node is usually a fixed value (e.g., 1018). It can be understood that the number of data blocks in each cluster is a fixed value N, and the number of data blocks corresponding to each node is also a fixed value i. In a possible case, i cannot be divided by N, so that the data blocks in the same cluster belong to different nodes, that is, there is a situation where the data blocks in the cluster cross nodes. For example, Figure 2 As shown, node1 manages data blocks m1 and m2 in cluster m, and node2 manages other data blocks in cluster m, including data block mN. That is, cluster m is a cross-node cluster. For ease of management, data in cross-node clusters is not compressed.

[0046] In the specific data compression process, if the number of data blocks in a cluster is large, the probability of compressible duplicate data appearing in the same cluster is high, which is equivalent to a high compression rate of the cluster. However, a large number of data blocks in a cluster will also lead to a large amount of data in the cluster across nodes, which in turn leads to a large amount of uncompressed data in the data to be compressed. For example, the default cluster value in the file system is 8, which means that each cluster includes 8 data blocks. Usually, the number of bytes that can be stored in a data block is 4096, which means that each cluster can store 8*4096=32768 bytes of data. In the case of a large amount of data to be stored, for example, when the amount of data to be stored is greater than 1MB, the probability of compressible duplicate data appearing in each cluster is high, which is equivalent to a high compression rate of the cluster. However, a large number of data blocks in a cluster will also lead to a large amount of data in the cluster across nodes, which in turn leads to a large amount of uncompressed data in the data to be compressed. When the amount of data to be stored is small, for example, less than 32KB, the amount of data to be stored is less than the amount of data in a cluster. Therefore, the file system will not compress the data to be stored, resulting in that small files cannot save storage space by compressing data. Combining these two aspects, the overall compression rate of the data to be compressed will be affected by the number of data blocks in each cluster.

[0047] In view of this, an embodiment of the present application provides a data compression method, including: obtaining a file type of data to be compressed and a first data amount of the data to be compressed, and then determining a first value of the data to be compressed based on the file type and the first data amount, and then compressing the data to be compressed based on the first value to obtain compressed data, wherein the clustering value refers to the number of data blocks in each cluster when the data is clustered. Since the value of the clustering value (the first value) is determined based on the first data amount of the data to be compressed of the file type, it is a value of the clustering value that better matches the data to be compressed. Therefore, when the value of the clustering value is the first value, the data compression rate of each cluster of the data to be compressed and the proportion of uncompressed data in the data to be compressed can be balanced, thereby improving the overall compression rate of the data to be compressed.

[0048] The data compression method provided in the embodiment of the present application can be applied to electronic devices. Optionally, the electronic device includes a terminal device, which can also be called a terminal, a user equipment (UE), a mobile station (MS), a mobile terminal (MT), etc. The terminal device can be a mobile phone, a smart TV, a wearable device, a tablet computer (Pad), a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, etc. The embodiment of the present application does not limit the specific technology and specific device form adopted by the terminal device.

[0049] For example, Figure 3 1 shows a schematic diagram of the structure of the electronic device 100. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0050] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0051] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0052] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0053] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0054] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0055] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.

[0056] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0057] It should be noted that any electronic device mentioned in the embodiments of the present application may include more or fewer modules in the electronic device 100.

[0058] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.

[0059] The layered architecture of the electronic device 100 divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Android runtime) and the system library, and the kernel layer.

[0060] The application layer can include a series of application packages.

[0061] The application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, etc.

[0062] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0063] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.

[0064] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0065] The kernel layer is the layer between hardware and software. The kernel layer includes at least display driver, camera driver, audio driver, sensor driver, Wi-Fi driver, etc.

[0066] It should be noted that the electronic device mentioned in the embodiments of the present application may include more or fewer modules in the above-mentioned electronic device.

[0067] Combine the following Figure 4 The data compression method provided in the embodiment of the present application is described in detail.

[0068] Figure 4 A flow chart of a data compression method provided in an embodiment of the present application is shown as follows: Figure 4 As shown, the method includes:

[0069] S101: Obtain a file type of data to be compressed and a first data volume of the data to be compressed.

[0070] It should be understood that the data to be compressed may refer to various types of data generated by the application in the electronic device during operation. In order to reduce the memory occupied by these data in the electronic device, the electronic device usually compresses these data and then stores them in the corresponding storage address. It should be understood that different data have corresponding file types. For example, the file types may include odex format, vdex format, SO format, APK format, MP4 format, jpg format and db format.

[0071] Among them, the file in odex format is an executable file extracted from the application APK in the Android system, that is, the classes.dex file in the APK is generated into an .odex file through dex optimization. This file is usually stored separately. The classes.dex file in the original APK file can be retained or deleted.

[0072] The vdex format is an executable file format for Android applications, designed to improve application startup time and memory usage efficiency on Android devices. It is designed based on the DEX file (Dalvik Executable) and contains pre-calculated parsing data to reduce the operations required for class loading at runtime by the application. The vdex file is usually used together with the odex file to optimize the startup and performance of the application on Android devices.

[0073] APK is an application package file format used by the Android operating system. If you want to run the code of an Android application on an Android device, you must first compile it and package it into a file that can be recognized by the Android system before it can be run. The file format that can be recognized and run by the Android system is the APK format.

[0074] SO format is the ELF file format, which is a unified format for executable files, shared library files, and target files under Linux.

[0075] MP4 is a commonly used video format, and its file extension is mainly .mp4 or .avi. The main advantage of MP4 video format is that it has high encoding efficiency, can process a large amount of data in a relatively short time, and can provide higher quality video images.

[0076] The jpg format is a common image file format and a standard that can be used for continuous-tone static image compression. The image compression corresponding to the jpg format file is lossy compression. While compressing the data image in a small storage space, it will cause damage to the image data.

[0077] db format is a database file format, which is a file format used by software to store data and can be equivalent to a database.

[0078] It can be understood that the file of the data to be stored may include information indicating the file type, and the electronic device can determine the file type of the data to be stored by reading the information.

[0079] Similarly, the file of the data to be stored may also include information indicating the file size, and the electronic device may obtain the data volume of the data to be stored, that is, the first data volume, by reading the information.

[0080] S102: Determine a first value of the data to be compressed according to the file type and the first data amount.

[0081] The first value refers to the value of the clustering value when clustering and compressing the data to be compressed, and the clustering value refers to the number of data blocks in each cluster when clustering the data.

[0082] It should be understood that the number of data blocks included in each cluster is the same, for example Figure 1 (a) or Figure 1 As shown in (b) in Figure 1, the number of data blocks in cluster 1 is 4, and the number of data blocks in cluster 2 to cluster m is 4. In other words, for Figure 1 (a) or Figure 1 The first value corresponding to the data to be compressed shown in (b) is 4.

[0083] By the above Figure 2 It can be seen from the description that the value of the clustering value will affect the overall compression rate of the data to be compressed, because the value of the clustering value will affect the amount of uncompressed data in the data to be compressed, and the repetition rate of data in the same cluster in the data to be compressed. At the same time, different file types will also affect the compression rate of data in the same cluster. Therefore, a first value that is more suitable for the current data to be compressed can be determined according to the file type and the first data amount of the data to be compressed, so that when the value of the clustering value is the first value, the proportion of uncompressed data in the data to be compressed is minimized, thereby improving the overall compression rate of the data to be compressed.

[0084] Exemplarily, a possible implementation of S102 “determining a first value of the data to be compressed according to the file type and the first data amount” includes:

[0085] Step 1: acquiring a first parameter set according to the file type of the data to be compressed, wherein the first parameter set includes a plurality of first parameters, and the first parameter is used to indicate a data compression rate corresponding to a value of the clustering value.

[0086] The clustering value refers to the number of data blocks in each cluster when clustering the data. Different from the first value, the first value is the specific number of data blocks in each cluster when clustering and compressing the data to be stored. The clustering value refers to the range of the number of data blocks in each cluster when clustering the data. It is equivalent to the first value being a specific value, and the clustering value is a value range of a value, including multiple values, that is, the first value is a value of the clustering value. When the clustering value is the first value, the proportion of uncompressed data in the data to be compressed is the smallest.

[0087] For example, the clustering value may include 2 n , where n is a positive integer. That is to say, the value of the cluster value can be an integer power of 2.

[0088] It should be understood that different values ​​of the clustering value will affect the overall compression rate of the data to be compressed. Exemplarily, as shown in Figures 5(a), 5(b), 5(c) and 5(d), when the clustering value of the data to be compressed of different file types takes different values, the overall compression rate of the data to be compressed changes accordingly. Among them, Figure 5(a) refers to the overall compression rate of the data to be compressed in APK format when the clustering value takes different values, Figure 5(b) refers to the overall compression rate of the data to be compressed in db format when the clustering value takes different values, Figure 5(c) refers to the overall compression rate of the data to be compressed in SO format when the clustering value takes different values, and Figure 5(d) refers to the overall compression rate of the data to be compressed in mp4 format when the clustering value takes different values. It can be seen that when the clustering value takes a value greater than 32, the overall compression rate of the data to be compressed will decrease.

[0089] Optionally, the clustering value ranges from [4, 8, 16, 32].

[0090] In the data compression method provided in the embodiment of the present application, the value range of the clustering value is [4, 8, 16, 32], which is equivalent to that the number of values ​​of the clustering value is a finite number, thereby making it possible to reduce the number of iterations in the process of iteratively obtaining the first value based on the clustering value, thereby improving the efficiency of obtaining the first data, that is, improving the efficiency of data compression.

[0091] The first parameter set may include multiple first parameters, each of which is the data compression rate of the data to be stored corresponding to the same file type and a cluster value. It should be understood that the first parameter may refer to the data compression rate obtained by the user according to actual tests. For example, the file type may be marked as Ta , where a=1,2,3...; that is, when a takes the value of 1, the file type of the data to be stored is the file type corresponding to the value 1, when a takes the value of 2, the file type of the data to be stored is the file type corresponding to the value 2, ... It should be understood that the electronic device has a pre-stored correspondence between the value and the file type, so the file type of the data to be stored can be determined according to the different values ​​of a. In addition, it can be seen from the above description that the values ​​of the clustering value can include 2 n , where n is a positive integer. That is, the value N of the cluster value can include [2, 4, 8, 16, 32, 64, ...].

[0092] Therefore, you can set the file type to T a The data compression rate of the data to be stored when the cluster value is N is recorded as Understandably, It can be a value obtained by the user based on actual testing. Afterwards, you can Pre-stored in the electronic device for easy retrieval by the electronic device.

[0093] Step 2: determining a second parameter set according to the first data volume, the second parameter set including a plurality of second parameters, the second parameter being used to indicate the amount of uncompressed data corresponding to a value of the clustering value when the amount of the data to be compressed is the first data volume.

[0094] In the process of compressing the data to be stored, the amount of data to be stored is usually not a positive integer multiple of the amount in a cluster, so there is a part of the data that cannot occupy the storage space of a cluster, and this part of the data can be called the end-of-file data. It can be understood that data is stored in sequence, and the data in the cluster across nodes is also the above-mentioned end-of-file data. In other words, in the process of data compression, the end-of-file data is not compressed.

[0095] For example, if the amount of data to be stored occupies 63 data blocks, and the cluster value is 32, that is, there are 32 data blocks in a cluster, then the tail data of the data to be stored will also occupy 31 data blocks to store, but it does not completely occupy all the data blocks in a cluster, and this part of the data will not be compressed. This is equivalent to nearly half of the data to be stored not being compressed. Since the proportion of uncompressed data is large, it will affect the overall compression rate of the data to be stored.

[0096] The amount of data at the end of the file can be Indicates, where m represents the number of bytes of data stored in a data block, S represents the amount of data to be stored, that is, the first amount of data, and N is the value of the clustering value. Indicates that the value obtained by S / m is rounded up, mod is the modulus operator, It represents the remainder obtained by dividing the value obtained by rounding up the value of S / m by N. Since N has different values, It can represent the file end data corresponding to different clustering values, that is, when the data amount of the to-be-compressed data is the first data amount, the data amount of the uncompressed data corresponding to different clustering values, which is equivalent to the second parameter set.

[0097] Optionally, the number of bytes of data stored in one data block is 4096.

[0098] When the number of bytes stored in a data block is 4096, the number of bytes at the end of the file can be To represent, where S represents the amount of data to be stored, that is, the first amount of data, and N is the value of the clustering value. Indicates that the value obtained from S / 4096 is rounded up, and mod is the modulus operator. Represents the remainder obtained by dividing the value obtained by rounding up the value obtained by S / 4096 by N.

[0099] Step 3: Determine a first value according to the first parameter set and the second parameter set.

[0100] Optionally, “determining the first value according to the first parameter set and the second parameter set” may include: determining the first value according to the first parameter set, the second parameter set and a first formula, wherein the first formula includes:

[0101]

[0102] in, represents the first parameter set, m represents the number of bytes of data stored in a data block, S represents the first data amount, N represents the number of data blocks in each cluster, represents the third parameter corresponding to different file types, and the third parameter refers to the parameter that maximizes the covariance between the theoretical compression rate and the actual compression rate, wherein, Represents the second parameter set.

[0103] in, It can refer to the file type of the data to be stored as T a The parameter that maximizes the covariance between the theoretical compression rate and the actual compression rate. It can be a value obtained by the user based on actual tests. It can be pre-stored in the electronic device.

[0104] Understandably, It can be a value obtained by the user based on actual tests. Can be pre-stored in electronic devices, It can be pre-stored in the electronic device.

[0105] It should be understood that when the number of bytes of data stored in a data block is 4096, the first formula above may be:

[0106]

[0107] When the first value needs to be determined according to the first parameter set, the second parameter set and the first formula, the pre-stored and Substitute into the first formula to obtain the first value.

[0108] For example, each parameter in the first parameter set and each parameter in the second parameter set may be used to iterate the first formula, and N corresponding to the maximum value among the multiple Fs may be obtained as the first value.

[0109] For example, the values ​​of the clustering value include [4, 8, 16, 32]. When the clustering value is 4, the compression rate is And the cluster value 4 is substituted into the first formula to get F4; when the cluster value is 8, the compression rate is And the cluster value 8 is substituted into the first formula to get F8; when the cluster value is 16, the compression rate is And the value of clustering value 16 is substituted into the first formula to get F 16 ; The compression ratio when the cluster value is 32 And the value of clustering value 32 is substituted into the first formula to get F 32 ; then from F4, F8, F 16 and F 32 The value of the cluster value corresponding to the maximum value is selected as the first value.

[0110] For example, F 16 F4, F8, F 16 and F 32 The largest value among them is taken as the first value. When compressing the data to be compressed, the number of data blocks in each cluster is 16, that is, the first value is 16.

[0111] S103 . Compress the data to be compressed based on the first value to obtain compressed data.

[0112] Usually, when compressing data, it is necessary to read three compression parameters, namely, the type of compression algorithm, the value of the clustering value, and the compression level, from the file system, and then perform data compression based on these three parameters. However, in the data compression method provided in the embodiment of the present application, the value of the clustering value is not a preset value, but is obtained according to the file type and the first data volume. Therefore, when compressing the data to be compressed, the two compression parameters, namely, the type of compression algorithm and the compression level, can be read from the file system, and the first value obtained according to the file type and the first data volume is used as the value of the clustering value, and then the data to be compressed is compressed to obtain the compressed data.

[0113] The compression algorithm types may include LZO algorithm, LZ4 algorithm, ZSTD algorithm and LZORLE algorithm.

[0114] The LZO algorithm refers to the Lempel-Ziv-Oberhumer algorithm. The LZO algorithm is a lossless algorithm, and the reference implementation program is thread-safe.

[0115] The LZ4 algorithm is a fast compression algorithm suitable for high-performance compression and decompression applications. The main advantages of the LZ4 algorithm are high compression and decompression efficiency, fast compression speed, especially very fast decompression speed, and low CPU usage.

[0116] The ZSTD algorithm is a real-time encoding algorithm that can compress data faster and more efficiently when processing big data. Compared with other algorithms, the ZSTD algorithm can effectively improve the data compression rate while taking into account the compression speed.

[0117] The LZORLE algorithm is an improved algorithm of the LZO algorithm, where RLE refers to Run-length Encoding. The LZORLE algorithm can provide better compression performance while maintaining the compression ratio of the LZO algorithm.

[0118] Optionally, compressing the data to be compressed based on the first value to obtain the compressed data may include:

[0119] Step 1: Determine the number of data blocks in each cluster based on a first value.

[0120] Step 2: De-duplicate the data in each data block in each cluster to obtain compressed data.

[0121] De-duplicate the data in each data block in the cluster. Figure 1 (a) Figure 1 The process shown in (b) is similar and will not be repeated here.

[0122] The data compression method provided by the embodiment of the present application includes obtaining the file type of the data to be compressed and the first data amount of the data to be compressed, and then determining the first value of the data to be compressed based on the file type and the first data amount, and then compressing the data to be compressed based on the first value to obtain compressed data, wherein the clustering value refers to the number of data blocks in each cluster when the data is clustered. Since the value of the clustering value (the first value) is determined based on the first data amount of the data to be compressed of the file type, it is a value of the clustering value that better matches the data to be compressed. Therefore, when the value of the clustering value is the first value, the data compression rate of each cluster of the data to be compressed and the proportion of uncompressed data in the data to be compressed can be balanced, thereby improving the overall compression rate of the data to be compressed.

[0123] It should be understood that, although each step in the flow chart in the above-described embodiment is shown in sequence according to the indication of the arrow, these steps are not necessarily performed in sequence according to the order indicated by the arrow. Unless there is clear explanation in this article, the execution of these steps does not have strict order restriction, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the flow chart may include a plurality of sub-steps or a plurality of stages, and these sub-steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these sub-steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with at least a portion of other steps or sub-steps or stages of other steps.

[0124] It is understandable that in order to implement the above functions, the electronic device includes hardware and / or software modules corresponding to the execution of each function. In combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered to be beyond the scope of the present application.

[0125] The embodiment of the present application can divide the functional modules of the electronic device according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one module. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. It should be noted that the names of the modules in the embodiment of the present application are schematic and are not limited to the names of the modules in actual implementation.

[0126] Figure 6A schematic diagram of the structure of a data compression device provided in an embodiment of the present application.

[0127] It should be understood that the data compression device 600 can perform Figure 4 The data compression method shown; the data compression device 600 includes: an acquisition unit 610 and a processing unit 620.

[0128] The acquisition unit 610 is used to acquire the file type of the data to be compressed and the first data volume of the data to be compressed;

[0129] The processing unit 620 is used to determine a first value of the data to be compressed according to the file type and the first data amount, where the clustering value refers to the number of data blocks in each cluster when clustering the data;

[0130] The processing unit 620 is configured to perform data compression on the data to be compressed based on the first value to obtain compressed data.

[0131] In one embodiment, the processing unit 620 is specifically used to obtain a first parameter set according to the file type of the data to be compressed, the first parameter set including multiple first parameters, the first parameter being used to indicate the data compression rate corresponding to a value of the clustering value; determine a second parameter set according to the first data volume, the second parameter set including multiple second parameters, the second parameter being used to indicate the data volume of uncompressed data corresponding to a value of the clustering value when the data volume of the data to be compressed is the first data volume; determine the first value according to the first parameter set and the second parameter set.

[0132] In one embodiment, the processing unit 620 is specifically configured to determine the first value according to the first parameter set, the second parameter set, and a first formula, where the first formula includes:

[0133]

[0134] in, represents the first parameter set, m represents the number of bytes of data stored in a data block, S represents the first data amount, N represents the number of data blocks in each cluster, represents the third parameter corresponding to different file types. The third parameter is the parameter that maximizes the covariance between the theoretical compression rate and the actual compression rate. Represents the second parameter set.

[0135] In one embodiment, the processing unit 620 is specifically configured to use each parameter in the first parameter set and each parameter in the second parameter set to iterate the first formula, and obtain N corresponding to the maximum value of multiple Fs as the first value.

[0136] In one embodiment, the number m of bytes storing data in a data block is 4096.

[0137] In one embodiment, the clustering value includes 2 n , where n is a positive integer.

[0138] In one embodiment, the clustering value ranges from [4, 8, 16, 32].

[0139] In one embodiment, the processing unit 620 is specifically configured to determine the number of data blocks in each cluster based on the first value; and perform deduplication processing on the data in the data blocks in each cluster to obtain compressed data.

[0140] The data compression device provided in this embodiment is used to execute the data compression method of the above embodiment. The technical principle and technical effect are similar and will not be described in detail here.

[0141] It should be noted that the data compression device 600 is implemented in the form of a functional unit. The term "unit" here can be implemented in the form of software and / or hardware, and is not specifically limited to this.

[0142] For example, a "unit" may be a software program, a hardware circuit, or a combination of the two that implements the above functions. The hardware circuit may include an application specific integrated circuit (ASIC), an electronic circuit, a processor (e.g., a shared processor, a dedicated processor, or a group processor, etc.) and a memory for executing one or more software or firmware programs, a combined logic circuit, and / or other suitable components that support the described functions.

[0143] Therefore, the units of each example described in the embodiments of the present application can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.

[0144] Figure 7 A structural schematic diagram of an electronic device provided by the present application is shown. Figure 7 The dotted line in indicates that the unit or the module is optional. The electronic device 700 can be used to implement the data compression method described in the above method embodiment.

[0145] The electronic device 700 includes one or more processors 701, which can support the data compression method in the method embodiment implemented by the electronic device 700. The processor 701 can be a general-purpose processor or a special-purpose processor. For example, the processor 701 can be a central processing unit (CPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, such as discrete gates, transistor logic devices or discrete hardware components.

[0146] The processor 701 may be used to control the electronic device 700, execute software programs, and process data of the software programs. The electronic device 700 may also include a communication unit 705 to implement input (reception) and output (transmission) of signals.

[0147] For example, the electronic device 700 may be a chip, the communication unit 705 may be an input and / or output circuit of the chip, or the communication unit 705 may be a communication interface of the chip, and the chip may be a component of a terminal device or other electronic devices.

[0148] For another example, the electronic device 700 may be a terminal device, and the communication unit 705 may be a transceiver of the terminal device, or the communication unit 705 may be a transceiver circuit of the terminal device.

[0149] The electronic device 700 may include one or more memories 702 on which a program 704 is stored. The program 704 can be executed by the processor 701 to generate instructions 703, so that the processor 701 executes the impedance matching method described in the above method embodiment according to the instructions 703.

[0150] Optionally, data may be stored in the memory 702. Optionally, the processor 701 may read data stored in the memory 702. The data may be stored at the same storage address as the program 704, or may be stored at a different storage address than the program 704.

[0151] The processor 701 and the memory 702 may be provided separately or integrated together; for example, integrated on a system on chip (SOC) of a terminal device.

[0152] Exemplarily, the memory 702 can be used to store the related program 704 of the data compression method provided in the embodiment of the present application, and the processor 701 can be used to call the related program 704 of the data compression method stored in the memory 702 when performing data compression, and execute the data compression method of the embodiment of the present application; including: obtaining the file type of the data to be compressed and the first data amount of the data to be compressed; determining the first value of the data to be compressed according to the file type and the first data amount, the clustering value refers to the number of data blocks in each cluster when the data is clustered; compressing the data to be compressed based on the first value to obtain compressed data.

[0153] The present application also provides a computer program product, which, when executed by the processor 701, implements the data compression method described in any method embodiment of the present application.

[0154] The computer program product may be stored in the memory 702 , for example, a program 704 , which is converted into an executable target file that can be executed by the processor 701 after preprocessing, compiling, assembling, and linking.

[0155] The present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a computer, the data compression method described in any method embodiment of the present application is implemented. The computer program can be a high-level language program or an executable target program.

[0156] The computer-readable storage medium is, for example, a memory 702. The memory 702 may be a volatile memory or a nonvolatile memory, or the memory 702 may include both a volatile memory and a nonvolatile memory. Among them, the nonvolatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).

[0157] In this application, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can be represented by: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.

[0158] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0159] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0160] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0161] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic; for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0162] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0163] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0164] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A data compression method, characterized in that: include: Acquire a file type of the data to be compressed and a first data volume of the data to be compressed; Determining a first value of the data to be compressed according to the file type and the first data amount, wherein the first value refers to a value of a clustering value when clustering the data to be compressed is performed, and the clustering value refers to the number of data blocks in each cluster when clustering the data; Compressing the data to be compressed based on the first value to obtain compressed data; The step of determining the first value of the data to be compressed according to the file type and the first data amount includes: Acquire a first parameter set according to the file type of the data to be compressed, the first parameter set including a plurality of first parameters, the first parameter being used to indicate a data compression rate corresponding to a value of the clustering value; Determine a second parameter set according to the first data amount, the second parameter set including a plurality of second parameters, the second parameters being used to indicate the amount of uncompressed data corresponding to a value of the clustering value when the amount of data to be compressed is the first data amount; Determine the first value according to the first parameter set and the second parameter set; The determining the first value according to the first parameter set and the second parameter set includes: The first value is determined according to the first parameter set, the second parameter set and a first formula, where the first formula includes: in, represents the first parameter set, m represents the number of bytes of data stored in a data block, S represents the first data amount, N represents the number of data blocks in each cluster, represents the third parameter corresponding to different file types, and the third parameter refers to the parameter that maximizes the covariance between the theoretical compression rate and the actual compression rate, wherein, Represents the second parameter set.

2. The method according to claim 1, characterized in that The determining the first value according to the first parameter set, the second parameter set and a first formula includes: The first formula is iterated using each parameter in the first parameter set and each parameter in the second parameter set, and N corresponding to the maximum value of multiple Fs is obtained as the first value.

3. The method according to claim 1 or 2, characterized in that: m is 4096.

4. The method according to claim 1 or 2, characterized in that: The clustering value includes 2 n , where n is a positive integer.

5. The method according to claim 4, characterized in that The value range of the clustering value is [4, 8, 16, 32].

6. The method according to claim 1 or 2, characterized in that: The step of compressing the data to be compressed based on the first value to obtain compressed data includes: determining the number of data blocks in each cluster based on the first value; The data in the data blocks in each cluster are deduplicated to obtain compressed data.

7. An electronic device, characterized in that: The electronic device comprises means for performing the method as claimed in any one of claims 1 to 6.

8. An electronic device, characterized in that: include: one or more processors; Memory; and one or more computer programs, wherein the one or more computer programs are stored in the memory, and when the computer programs are executed by the one or more processors, the electronic device performs the method as claimed in any one of claims 1 to 6.

9. A chip system, characterized in that: The chip system includes a processor for calling and running a computer program from a memory, so that an electronic device equipped with the chip system executes the method as described in any one of claims 1 to 6.

10. A computer-readable storage medium comprising a computer program, characterized in that: When the computer program is executed on an electronic device, the electronic device is caused to execute the method according to any one of claims 1 to 6.