IP Library › Granted Patent US 12,463,662
Granted Patent B2
US 12,463,662 · App. 18/567,644 · Granted Nov 4, 2025

Data compression method and apparatus

Inventors: Chao Yu (Shenzhen, CN); Yi Chen (Shenzhen, CN); Guifu Li (Shenzhen, CN); Ge Qiu (Shanghai, CN); Zhipeng Li (Shenzhen, CN); Daiyue Zhang (Shanghai, CN); Jing Qian (Shanghai, CN)
Assignee: Huawei Technologies Co., Ltd.
H03M7/6047G06F3/0608G06F3/064G06F3/0641G06F3/0683
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,463,662
App. No.
18/567,644
Granted
Nov 4, 2025
Kind
B2
Abstract

This application discloses a data compression method and apparatus. The method includes: obtaining m data blocks in a data area of a readable and writable file system; compressing the m data blocks by using a preset compression algorithm, to sequentially obtain n compressed data blocks, where first capacities of the compressed data blocks are the same, and the first capacity represents a quantity of bytes of compressed data that can be included in the compressed data block; and establishing a first index of each of j data blocks corresponding to an i th compressed data block in the n compressed data blocks, and recording a mapping relationship between first indexes and the j data blocks. The first index is used to identify a storage location, in a storage medium, of each data block included in the j data blocks, and attribute information included in each of the j data blocks.

Claims (74)

1 . A data compression method, wherein the method comprises:

obtaining m data blocks in a data area of a readable and writable file system, wherein m is a positive integer greater than or equal to 1;

compressing the m data blocks by using a preset compression algorithm, to sequentially obtain n compressed data blocks, wherein first capacities of the compressed data blocks are the same, the first capacity represents a quantity of bytes of compressed data that can be comprised in the compressed data block, and n is a positive integer greater than or equal to 1; and

establishing a first index of each of j data blocks corresponding to an i th compressed data block in the n compressed data blocks, and recording a mapping relationship between first indexes and the j data blocks, wherein i is a positive integer greater than or equal to 1 and less than or equal to n, and j is a positive integer greater than or equal to 1 and less than or equal to m, wherein

the first index identifies a storage location, in a storage medium, of each data block comprised in the j data blocks, and attribute information comprised in each of the j data blocks.

2 . The method according to claim 1 , wherein the compressing the m data blocks by using a preset compression algorithm, to sequentially obtain n compressed data blocks comprises:

sequentially allocating data blocks in the m data blocks to a first set in a preset order; and

when a data capacity of the j data blocks in the first set is equal to a rated capacity of the first set, performing a compression operation on the j data blocks based on a specified compression threshold, to obtain the i th compressed data block.

3 . The method according to claim 2 , wherein the establishing a first index of each of j data blocks corresponding to an i th compressed data block in the n compressed data blocks comprises:

when a sum of a total data length of header data and compressed data of the i th compressed data block and the specified compression threshold is less than or equal to a total data length of the j data blocks, establishing the first index of each of the j data blocks.

4 . The method according to claim 1 , wherein the attribute information comprises at least one of the following:

a first attribute, representing whether a storage location of a compressed data block into which a data block is compressed is pre-allocated;

a second attribute, representing whether a data page of a data block is valid;

a third attribute, representing whether a data page of a data block is a first compressed page of a compressed data block of the data block;

a fourth attribute, representing whether a data page of a data block is comprised in compressed data pages of two compressed blocks;

a fifth attribute, representing whether a data page of a data block is a compressed page of a compressed data block obtained by compressing the data block;

a sixth attribute, representing an index address of a compressed data block in which a data page of a data block is located; or

a seventh attribute, representing that when a data page of a data block belongs to a first compressed page of a compressed data block of the data block, an attribute value of the seventh attribute is an offset of the data block in a set corresponding to the compressed data block; and when the data page of the data block does not belong to the first compressed page of the compressed data block of the data block, the attribute value of the seventh attribute is a distance between the data page of the data block and the first compressed page of the compressed data block.

5 . The method according to claim 4 , wherein the attribute information comprises the third attribute, and the establishing a first index of each of j data blocks corresponding to an i th compressed data block in the n compressed data blocks comprises:

when a data page of each of the j data blocks is a first compressed page of the i th compressed data block, assigning 1 to an attribute value of the third attribute; or

when a data page of each of the j data blocks is not a first compressed page of the i th compressed data block, assigning 0 to an attribute value of the third attribute.

6 . The method according to claim 4 , wherein the attribute information comprises the seventh attribute, and the method further comprises:

when the attribute value of the third attribute is 1, updating the attribute value of the seventh attribute to the offset of the data block in the set corresponding to the compressed data block; or

when the attribute value of the third attribute is 0, updating the attribute value of the seventh attribute to the distance between the data page of the data block and the first compressed page of the compressed data block.

7 . The method according to claim 4 , wherein the attribute information comprises the fourth attribute, and the establishing a first index of each of j data blocks corresponding to an i th compressed data block in the n compressed data blocks comprises:

when a data page of each of the j data blocks is comprised in compressed data pages of two compressed blocks, assigning 1 to an attribute value of the fourth attribute; or

when a data page of each of the j data blocks is not comprised in compressed data pages of two compressed blocks, assigning 0 to an attribute value of the fourth attribute.

8 . The method according to claim 4 , wherein the attribute information comprises the second attribute, and the establishing a first index of each of j data blocks corresponding to an i th compressed data block in the n compressed data blocks comprises:

when a data page of each of the j data blocks is valid, assigning 1 to an attribute value of the second attribute; or

when a data page of each of the j data blocks is invalid, assigning 0 to an attribute value of the second attribute.

9 . The method according to claim 1 , wherein before the compressing the m data blocks by using a preset compression algorithm, to sequentially obtain n compressed data blocks, the method further comprises:

obtaining a second set of to-be-overwritten data, wherein the second set comprises p compressed data blocks, and p is a positive integer greater than or equal to 1;

obtaining a compressed page of a first target compressed data block in the p compressed data blocks and q data blocks corresponding to the compressed page of the first target compressed data block, wherein q is a positive integer greater than or equal to 1;

determining, in the q data blocks, a location offset of a first target data block in the q data blocks; and

determining that a data page of the first target data block is a data page of the to-be-overwritten data.

10 . The method according to claim 1 , wherein the first index identifies a storage location of the i th compressed data block in the storage medium and the attribute information comprised in each of the j data blocks.

11 . A data compression apparatus, wherein the apparatus comprises:

at least one processor; and

one or more memories coupled to the at least one processor and storing programming instructions for execution by the at least one processor to cause the apparatus to:

obtain m data blocks in a data area of a readable and writable file system, wherein m is a positive integer greater than or equal to 1;

compress the m data blocks by using a preset compression algorithm, to sequentially obtain n compressed data blocks, wherein first capacities of the compressed data blocks are the same, the first capacity represents a quantity of bytes of compressed data that can be comprised in the compressed data block, and n is a positive integer greater than or equal to 1; and

establish a first index of each of j data blocks corresponding to an i th compressed data block in the n compressed data blocks, and record a mapping relationship between first indexes and the j data blocks, wherein i is a positive integer greater than or equal to 1 and less than or equal to n, and j is a positive integer greater than or equal to 1 and less than or equal to m, wherein

the first index identifies a storage location, in a storage medium, of each data block comprised in the j data blocks, and attribute information comprised in each of the j data blocks.

12 . The apparatus according to claim 11 , wherein the programming instructions, when executed by the at least one processor, cause the apparatus to:

sequentially allocate data blocks in the m data blocks to a first set in a preset order; and

when a data capacity of the j data blocks in the first set is equal to a rated capacity of the first set, perform a compression operation on the j data blocks based on a specified compression threshold, to obtain the i th compressed data block.

13 . The apparatus according to claim 12 , wherein the programming instructions, when executed by the at least one processor, cause the apparatus to:

when a sum of a total data length of header data and compressed data of the i th compressed data block and the specified compression threshold is less than or equal to a total data length of the j data blocks, establish the first index of each of the j data blocks.

14 . The apparatus according to claim 11 , wherein the attribute information comprises at least one of the following:

a first attribute, representing whether a storage location of a compressed data block into which a data block is compressed is pre-allocated;

a second attribute, representing whether a data page of a data block is valid;

a third attribute, representing whether a data page of a data block is a first compressed page of a compressed data block of the data block;

a fourth attribute, representing whether a data page of a data block is comprised in compressed data pages of two compressed blocks;

a fifth attribute, representing whether a data page of a data block is a compressed page of a compressed data block obtained by compressing the data block;

a sixth attribute, representing an index address of a compressed data block in which a data page of a data block is located; and

a seventh attribute, representing that when a data page of a data block belongs to a first compressed page of a compressed data block of the data block, an attribute value of the seventh attribute is an offset of the data block in a set corresponding to the compressed data block; and when the data page of the data block does not belong to the first compressed page of the compressed data block of the data block, the attribute value of the seventh attribute is a distance between the data page of the data block and the first compressed page of the compressed data block.

15 . The apparatus according to claim 14 , wherein the attribute information comprises the third attribute, and the programming instructions, when executed by the at least one processor, cause the apparatus to:

when a data page of each of the j data blocks is a first compressed page of the i th compressed data block, assign 1 to an attribute value of the third attribute; or

when a data page of each of the j data blocks is not a first compressed page of the i th compressed data block, assign 0 to an attribute value of the third attribute.

16 . The apparatus according to claim 14 , wherein the attribute information comprises the seventh attribute, and the programming instructions, when executed by the at least one processor, cause the apparatus to:

when the attribute value of the third attribute is 1, update the attribute value of the seventh attribute to the offset of the data block in the set corresponding to the compressed data block; or

when the attribute value of the third attribute is 0, update the attribute value of the seventh attribute to the distance between the data page of the data block and the first compressed page of the compressed data block.

17 . The apparatus according to claim 14 , wherein the attribute information comprises the fourth attribute, and the programming instructions, when executed by the at least one processor, cause the apparatus to:

when a data page of each of the j data blocks is comprised in compressed data pages of two compressed blocks, assign 1 to an attribute value of the fourth attribute; or

when a data page of each of the j data blocks is not comprised in compressed data pages of two compressed blocks, assign 0 to an attribute value of the fourth attribute.

18 . The apparatus according to claim 14 , wherein the attribute information comprises the second attribute, and the programming instructions, when executed by the at least one processor, cause the apparatus to:

when a data page of each of the j data blocks is valid, assign 1 to an attribute value of the second attribute; or

when a data page of each of the j data blocks is invalid, assign 0 to an attribute value of the second attribute.

19 . The apparatus according to claim 11 , wherein the programming instructions, when executed by the at least one processor, cause the apparatus to:

obtain a second set of to-be-overwritten data, wherein the second set comprises p compressed data blocks, and p is a positive integer greater than or equal to 1;

obtain a compressed page of a first target compressed data block in the p compressed data blocks and q data blocks corresponding to the compressed page of the first target compressed data block, wherein q is a positive integer greater than or equal to 1;

determine, in the q data blocks, a location offset of a first target data block in the q data blocks; and

determine that a data page of the first target data block is a data page of the to-be-overwritten data.

20 . The apparatus according to claim 11 , wherein the first index identifies a storage location of the i th compressed data block in the storage medium and the attribute information comprised in each of the j data blocks.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jul 30, 2025
From: YU, CHAO; CHEN, YI; LI, GUIFU; QIU, GE; LI, ZHIPENG; ZHANG, DAIYUE; QIAN, JING
To: HUAWEI TECHNOLOGIES CO., LTD.
Reel/Frame 071879/0633 →
Priority Claims (1)
CN 202110667882.7 · Jun 16, 2021 · national
Continuity (1)
Related Publication 20240283463A1 · Aug 22, 2024
References Cited (11)
US 5305295A · Chu · 1994 [cited by applicant]
US 20200366314A1 · Romanovskii et al. · 2020 [cited by applicant]
US 20210173811A1 · Agrawal · 2021 [cited by examiner]
CN 103516369A · 2014 [cited by applicant]
CN 107947799A · 2018 [cited by applicant]
CN 110557124A · 2019 [cited by applicant]
JP 2013127802A · 2013 [cited by applicant]
JP 2018530053A · 2018 [cited by applicant]
International Search Report and Written Opinion in International Appln. No. PCT/CN2022/085621, mailed on Jun. 15, 2022, 17 pages (with English translation). [cited by applicant]
Extended European Search Report in European Appln. No. 22823871.3, mailed on Oct. 8, 2024, 11 pages. [cited by applicant]
Office Action in Japanese Appln. No. 2023-577669, mailed on Mar. 4, 2025, 10 pages (with English translation). [cited by applicant]