Data compression method and data decompression method

By converting floating-point number sequences into integer sequences and calculating the XOR result, and generating stored data after grouping, the problem of low lossless compression ratio of floating-point numbers is solved, and a more efficient data compression effect is achieved.

CN119512438AActive Publication Date: 2025-02-25HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202311069679.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-22
Publication Date
2025-02-25
Estimated Expiration
2043-08-22

AI Technical Summary

Technical Problem

The compression rate of the lossless compression method of floating point numbers in the prior art is far inferior to that of integers, making it difficult to effectively process a large amount of floating point data in IoT timing scenarios.

Method used

By converting the sequence of floating-point numbers to be compressed into a sequence of integers, and calculating the XOR result of each integer and the previous integer, grouping, determining the first and second combinations, generating corresponding stored data, and writing it to the preset storage space to form compressed data.

Benefits of technology

The compression rate of lossless compression of floating-point numbers can be improved, and floating-point data in IoT timing scenarios can be more efficiently processed, reducing storage and transmission costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512438A_ABST
    Figure CN119512438A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data compression method, and the method comprises the steps: converting a to-be-compressed floating-point number sequence into an integer sequence, writing a first integer in the integer sequence into a preset storage space, and then carrying out the XOR calculation of the integers in the integer sequence, and obtaining a result sequence; performing result group division on the result sequence to obtain a result group sequence; determining each first type of combination and each second type of combination in the result group sequence; determining first storage data of each first type of combination and second storage data of each second type of combination; writing the first storage data and the second storage data into a preset storage space; and determining the first integer written in the preset storage space, the first storage data and the second storage data as compressed data of the floating-point number sequence. By applying the data compression method provided by the embodiment of the invention, the compression rate of performing data compression on the floating-point number can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data compression, and in particular to a data compression method and a data decompression method. Background Art

[0002] With the explosive growth of IoT data, how to effectively process such a huge and rapidly growing data has become a big challenge for IoT devices, which currently have many characteristics such as low energy consumption, limited storage resources, and insufficient computing resources. Compression technology can be applied at the sensor end and the center end, greatly reducing the data space occupied and the cost of data storage and data transmission, playing an important role in time series scenarios.

[0003] In related technologies, integer compression technology is becoming increasingly mature. In most time series scenarios, integer compression can already achieve a relatively ideal compression rate, while the compression rate of floating-point lossless compression methods is far lower than that of integers. Since in most IoT scenarios, the data collected by sensors are of floating-point type, optimizing the compression of floating-point numbers is of great value in IoT time series scenarios.

[0004] Currently, there is an urgent need for a data compression method to improve the compression rate of lossless compression of floating-point numbers. Summary of the invention

[0005] The purpose of the embodiments of the present application is to provide a data compression method and a data decompression method to improve the compression rate of lossless compression of floating point numbers. The specific technical solution is as follows:

[0006] In a first aspect, an embodiment of the present application provides a data compression method, the method comprising:

[0007] Converting multiple floating-point numbers in the floating-point number sequence to be compressed into integers respectively to obtain an integer sequence, and writing the first integer in the integer sequence into a preset storage space;

[0008] Starting from the second integer in the integer sequence, calculating the XOR result of each integer and the integer before the integer to obtain a result sequence, and starting from the first XOR result in the result sequence, grouping the result sequence according to a preset number to obtain a result group sequence;

[0009] Determine a first type of combination and a second type of combination in the result group sequence; wherein the first type of combination is: a plurality of result groups whose XOR results are all 0 and are continuous, or a result group whose XOR results are all 0 and whose adjacent result groups all include XOR results that are not 0, and the second type of combination is: a result group including an XOR result that is not 0;

[0010] Generate first storage data about the first type of combination according to the number of result groups in each first type of combination, and generate second storage data about the second type of combination according to the XOR result in each second type of combination;

[0011] Starting from the storage position next to the storage position where the first integer is located in the preset storage space, the generated first storage data and the generated second storage data are sequentially written into the preset storage space according to the arrangement order of the result groups in each first type combination and each second type combination in the result group sequence;

[0012] The first integer, each first stored data and each second stored data written in the preset storage space are determined as compressed data of the floating-point number sequence.

[0013] Optionally, in a specific implementation, the determining the first type of combination and the second type of combination in the result group sequence includes:

[0014] According to the arrangement order of each result group in the result group sequence, each result group is traversed in turn, and when each result group is traversed, it is determined whether each XOR result included in the result group is 0;

[0015] If yes, then traverse the next result group until there is an XOR result that is not 0 in the traversed result group, and determine the traversed result group that is not classified into any combination and all the XOR results are 0 as the first type of combination;

[0016] If not, the result group is determined as a second type of combination.

[0017] Optionally, in a specific implementation, generating first stored data about the first type of combination according to the number of result groups in each first type of combination, and generating second stored data about the second type of combination according to the XOR result in each second type of combination, includes:

[0018] When each first-category combination is determined to be obtained, storage data including preset first identification information, a first byte number, and a first number of result groups in the first-category combination is generated as first storage data about the first-category combination; wherein the first byte number is used to represent the number of bytes occupied by the first number when the first number is stored;

[0019] When each second type combination is determined to be obtained, second storage data on the second type combination is generated according to the distribution of 0 in each XOR result in the second type combination.

[0020] Optionally, in a specific implementation, generating second storage data about the second type of combination according to the distribution of 0 in each XOR result in the second type of combination includes:

[0021] generating, according to the distribution of 0 in each XOR result in the second type of combination, the first information or the second information about the second type of combination as the second stored data about the second type of combination;

[0022] The first information includes: preset second identification information, the number of public valid bits, the number of public low-order 0 bits and valid bit information; the second information includes: preset third identification information, the number of public high-order 0 bits and data information;

[0023] The number of common low-order 0s is used to represent: the minimum number of bits or the minimum number of complete bytes occupied by the low-order 0s of each XOR result in the second type of combination; the low-order 0s of each XOR result are: the 0 before the first non-zero number in the order from the lowest bit to the highest bit;

[0024] The number of common valid bits is used to represent: the maximum number of valid bits in each XOR result in the second type of combination, and the valid bits of each XOR result are: the bits occupied by each XOR result, in the order from the highest bit to the lowest bit, from the first non-zero number to the last non-zero number;

[0025] The number of common high-order 0s is used to represent: the minimum number of bits or the minimum number of complete bytes occupied by the high-order 0s of each XOR result in the second type of combination; the high-order 0s of each XOR result are: the 0 before the first occurrence of a non-zero number in the order from the highest order to the lowest order;

[0026] The valid bit information is: the value of the common valid bit of each XOR result in the second type of combination arranged according to the arrangement information of each XOR result in the second type of combination; the common valid bit of each XOR result is: the bits occupied by each XOR result, in the order from the highest bit to the lowest bit, after removing the common high-order 0 number of bits, and in the order from the lowest bit to the highest bit, removing the common low-order 0 number of bits, the remaining bits;

[0027] The data information includes: target information of each XOR result in the second type of combination arranged according to the arrangement information of each XOR result in the second type of combination; for each XOR result in the second type of combination, if the XOR result is 0, then the target information of the XOR result is a first value, if the XOR result is not 0, then the target information of the XOR result includes: a second value, and the value of the remaining bits in the XOR result after removing the common high-order 0 bits in the XOR result in order from the highest bit to the lowest bit.

[0028] Optionally, in a specific implementation manner, the generating the first information or the second information about the second type of combination as the second stored data about the second type of combination includes:

[0029] If the number of XOR results of 0 included in the second type of combination is less than the specified number, generating first information about the second type of combination as second storage data about the second type of combination;

[0030] If the number of XOR results of 0 included in the second type of combination is not less than the specified number, generating second information about the second type of combination as second storage data about the second type of combination;

[0031] or,

[0032] determining a first data amount of the first information about the second type of combination and a second data amount of the second information about the second type of combination;

[0033] If the first data amount is smaller than the second data amount, generating first information about the second type of combination as second stored data about the second type of combination;

[0034] If the first data amount is not less than the second data amount, second information about the second type of combination is generated as second stored data about the second type of combination.

[0035] Optionally, in a specific implementation, starting from the storage position next to the storage position where the first integer is located in the preset storage space, the generated first storage data and the second storage data are sequentially written into the preset storage space according to the arrangement order of the result groups in each first-category combination and each second-category combination in the result group sequence, including:

[0036] Starting from the storage position next to the storage position where the first integer is located in the preset storage space, after each first storage data or second storage data is generated, the first storage data or the second storage data is sequentially written into the preset storage space.

[0037] Optionally, in a specific implementation, writing the first integer in the integer sequence into the preset storage space includes:

[0038] In a preset storage space, sequentially write the first integer in the integer sequence and the target number of integers in the integer sequence;

[0039] The step of sequentially writing each first storage data and each second storage data generated into the preset storage space starting from the storage position next to the storage position where the first integer is located in the preset storage space according to the arrangement order of the result groups in each first type combination and each second type combination in the result group sequence includes:

[0040] Starting from the storage position next to the storage position where the target number is located in the preset storage space, the generated first storage data and the generated second storage data are sequentially written into the preset storage space according to the arrangement order of the result groups in each first type combination and each second type combination in the result group sequence;

[0041] The step of determining the first integer, each first stored data, and each second stored data written in the preset storage space as compressed data of the floating-point number sequence includes:

[0042] The first integer, the target number, each first stored data and each second stored data written in the preset storage space are determined as compressed data of the floating point number sequence.

[0043] Optionally, in a specific implementation, before converting the plurality of floating-point numbers in the floating-point number sequence to be compressed into integers respectively to obtain the integer sequence, the method further includes:

[0044] After the last floating point number sequence in the floating point number sequence to be compressed, adding a preset floating point number; wherein the preset floating point number is different from each floating point number in the floating point number sequence to be compressed;

[0045] The step of converting multiple floating-point numbers in the floating-point number sequence to be compressed into integers respectively to obtain an integer sequence includes:

[0046] A plurality of floating-point numbers in a floating-point number sequence to which a preset floating-point number is added are respectively converted into integers to obtain an integer sequence.

[0047] Optionally, in a specific implementation, the method further includes:

[0048] The compressed data of the floating point number sequence is compressed using a preset compression method to obtain target compressed data.

[0049] Optionally, in a specific implementation, the floating-point number sequence is: a multimedia data sequence; the multimedia data includes: at least one of: video data, audio data and image data.

[0050] In a second aspect, an embodiment of the present application provides a data decompression method, the method comprising:

[0051] Obtaining data to be decompressed, and reading the first integer in the data to be decompressed; wherein the data to be decompressed is obtained by any of the above-mentioned data compression methods;

[0052] Reading each stored data in the data to be decompressed in sequence according to the arrangement order of each stored data in the data to be decompressed;

[0053] When each stored data is read, the stored data is parsed according to the data content of the stored data to obtain the XOR result corresponding to the stored data;

[0054] According to the order in which the XOR results are obtained, each XOR result is XORed with the last integer obtained to obtain the target integer corresponding to the XOR result;

[0055] The obtained integers are converted into floating-point numbers, and the floating-point numbers corresponding to the integers are written into a floating-point number sequence in the order in which the integers are obtained, so as to obtain decompressed data corresponding to the data to be decompressed.

[0056] In a third aspect, an embodiment of the present application provides a data compression device, the device comprising:

[0057] A data conversion module, used for converting multiple floating-point numbers in the floating-point number sequence to be compressed into integers respectively, obtaining an integer sequence, and writing the first integer in the integer sequence into a preset storage space;

[0058] A result calculation module is used to calculate the XOR result of each integer and the previous integer of the integer starting from the second integer in the integer sequence to obtain a result sequence, and to group the result sequence according to a preset number starting from the first XOR result in the result sequence to obtain a result group sequence;

[0059] A combination determination module, used to determine a first type of combination and a second type of combination in the result group sequence; wherein the first type of combination is: a plurality of result groups whose XOR results are all 0 and are continuous, or a result group whose XOR results are all 0 and whose adjacent result groups all include XOR results that are not 0; and the second type of combination is: a result group including XOR results that are not 0;

[0060] A data generation module, used to generate first storage data about each first type combination according to the number of result groups in the first type combination, and to generate second storage data about each second type combination according to the XOR result in the second type combination;

[0061] a data writing module, configured to write the generated first storage data and the generated second storage data sequentially into the preset storage space, starting from a storage position next to the storage position where the first integer is located in the preset storage space, according to the arrangement order of the result groups in each first-category combination and each second-category combination in the result group sequence;

[0062] The data determination module is used to determine the first integer, each first storage data and each second storage data written in the preset storage space as compressed data of the floating-point number sequence.

[0063] Optionally, in a specific implementation, the combination determination module is specifically used to:

[0064] According to the arrangement order of each result group in the result group sequence, each result group is traversed in turn, and when each result group is traversed, it is determined whether each XOR result included in the result group is 0;

[0065] If yes, traverse the next result group until there is an XOR result that is not 0 in the traversed result group, and determine the traversed result group that is not divided into any combination and all the XOR results are 0 as the first combination;

[0066] If not, the result group is determined as a second type of combination;

[0067] Optionally, in a specific implementation, the data generation module includes:

[0068] A first generating submodule is used to generate storage data including preset first identification information, a first byte number and a first number of result groups in the first type of combination when each first type of combination is determined to be obtained, as first storage data about the first type of combination; wherein the first byte number is used to represent the number of bytes occupied by the first number when the first number is stored;

[0069] A second generating submodule is used for generating second storage data about each second type combination according to the distribution of 0 in each XOR result in the second type combination when it is determined that each second type combination is obtained;

[0070] Optionally, in a specific implementation, the second generating submodule is specifically used to:

[0071] generating, according to the distribution of 0 in each XOR result in the second type of combination, the first information or the second information about the second type of combination as the second stored data about the second type of combination;

[0072] The first information includes: preset second identification information, the number of public valid bits, the number of public low-order 0 bits and valid bit information; the second information includes: preset third identification information, the number of public high-order 0 bits and data information;

[0073] The number of common low-order 0s is used to represent: the minimum number of bits or the minimum number of complete bytes occupied by the low-order 0s of each XOR result in the second type of combination; the low-order 0s of each XOR result are: the 0 before the first non-zero number in the order from the lowest bit to the highest bit;

[0074] The number of common valid bits is used to represent: the maximum number of valid bits in each XOR result in the second type of combination, and the valid bits of each XOR result are: the bits occupied by each XOR result, in the order from the highest bit to the lowest bit, from the first non-zero number to the last non-zero number;

[0075] The number of common high-order 0s is used to represent: the minimum number of bits or the minimum number of complete bytes occupied by the high-order 0s of each XOR result in the second type of combination; the high-order 0s of each XOR result are: the 0 before the first occurrence of a non-zero number in the order from the highest order to the lowest order;

[0076] The valid bit information is: the value of the common valid bit of each XOR result in the second type of combination arranged according to the arrangement information of each XOR result in the second type of combination; the common valid bit of each XOR result is: the bits occupied by each XOR result, in the order from the highest bit to the lowest bit, after removing the common high-order 0 number of bits, and in the order from the lowest bit to the highest bit, removing the common low-order 0 number of bits, the remaining bits;

[0077] The data information includes: target information of each XOR result in the second type of combination arranged according to the arrangement information of each XOR result in the second type of combination; for each XOR result in the second type of combination, if the XOR result is 0, the target information of the XOR result is a first value, and if the XOR result is not 0, the target information of the XOR result includes: a second value, and the value of the remaining bits in the XOR result after removing the number of bits of the common high-order 0 in the XOR result in order from the highest bit to the lowest bit;

[0078] Optionally, in a specific implementation, the second generating submodule is specifically used to:

[0079] If the number of XOR results of 0 included in the second type of combination is less than the specified number, generating first information about the second type of combination as second storage data about the second type of combination;

[0080] If the number of XOR results of 0 included in the second type of combination is not less than the specified number, generating second information about the second type of combination as second storage data about the second type of combination;

[0081] or,

[0082] determining a first data amount of the first information about the second type of combination and a second data amount of the second information about the second type of combination;

[0083] If the first data amount is smaller than the second data amount, generating first information about the second type of combination as second stored data about the second type of combination;

[0084] If the first data amount is not less than the second data amount, generating second information about the second type of combination as second stored data about the second type of combination;

[0085] Optionally, in a specific implementation, the data writing module is specifically used to:

[0086] Starting from a storage position next to the storage position where the first integer is located in the preset storage space, after each first storage data or second storage data is generated, sequentially write the first storage data or the second storage data into the preset storage space;

[0087] Optionally, in a specific implementation, the data conversion module is specifically used to:

[0088] In a preset storage space, sequentially write the first integer in the integer sequence and the target number of integers in the integer sequence;

[0089] The data writing module is specifically used for:

[0090] Starting from the storage position next to the storage position where the target number is located in the preset storage space, the generated first storage data and the generated second storage data are sequentially written into the preset storage space according to the arrangement order of the result groups in each first type combination and each second type combination in the result group sequence;

[0091] The data determination module is specifically used for:

[0092] Determine the first integer, the target number, each first stored data and each second stored data written in the preset storage space as compressed data of the floating-point number sequence;

[0093] Optionally, in a specific implementation, the device further includes:

[0094] A floating point number adding module, used for adding a preset floating point number after the last floating point number sequence in the floating point number sequence to be compressed; wherein the preset floating point number is different from each floating point number in the floating point number sequence to be compressed;

[0095] The data conversion module is specifically used for:

[0096] Convert multiple floating-point numbers in the floating-point number sequence to which the preset floating-point number is added into integers respectively to obtain an integer sequence;

[0097] Optionally, in a specific implementation, the device further includes:

[0098] The data compression module is used to compress the compressed data of the floating point number sequence using a preset compression method to obtain target compressed data.

[0099] Optionally, in a specific implementation, the floating-point number sequence is: a multimedia data sequence; the multimedia data includes: at least one of: video data, audio data and image data.

[0100] In a fourth aspect, an embodiment of the present application provides a data decompression device, the device comprising:

[0101] A decompressed data acquisition module, used to acquire the data to be decompressed and read the first integer in the data to be decompressed; wherein the data to be decompressed is obtained by any of the above-mentioned data compression methods;

[0102] A data reading module, used for sequentially reading each stored data in the data to be decompressed according to the arrangement order of each stored data in the data to be decompressed;

[0103] A data analysis module is used to analyze each stored data according to the data content of the stored data when reading the stored data, and obtain the XOR result corresponding to the stored data;

[0104] An XOR calculation module, used to perform XOR calculation on each XOR result and the last integer obtained in the order in which the XOR results are obtained, to obtain a target integer corresponding to the XOR result;

[0105] The floating point conversion module is used to convert each obtained integer into a floating point number, and write each floating point number corresponding to each integer into a floating point number sequence according to the order in which each integer is obtained, so as to obtain the decompressed data corresponding to the data to be decompressed.

[0106] In a fifth aspect, an embodiment of the present application provides an electronic device, including:

[0107] Memory, used to store computer programs;

[0108] The processor is used to implement any of the above-mentioned data compression methods and / or data decompression methods when executing the program stored in the memory.

[0109] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the computer program implements any of the above-mentioned data compression methods and / or data decompression methods.

[0110] An embodiment of the present application also provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above-mentioned data compression methods and / or data decompression methods.

[0111] Beneficial effects of the embodiments of the present application:

[0112] Based on this, the data compression method provided by the embodiment of the present application is applied. Since the integer sequence is determined based on the floating-point sequence to be compressed, the result sequence is determined by starting from the second integer in the integer sequence and calculating the XOR result of each integer and the previous integer of the integer. Therefore, if there is no data fluctuation in the floating-point sequence, that is, each floating-point number in the floating-point sequence is the same, then each integer in the integer sequence is the same, and each XOR result in the result sequence is 0. It can be seen that each XOR result in the result sequence can reflect the data fluctuation of the floating-point sequence. Furthermore, for each result group, if the XOR results included in the result group are all 0, it means that there is no data fluctuation in the floating-point number corresponding to each XOR result in the result group; if the result group includes an XOR result that is not 0, it means that there is data fluctuation in the floating-point number corresponding to each XOR result in the result group. Since in the data compression method provided in the embodiment of the present application, the first type of combination is: a plurality of result groups whose XOR results are all 0 and continuous, or a result group whose XOR results are all 0 and whose adjacent result groups all include XOR results that are not 0, and the second type of combination is: a result group including XOR results that are not 0; the first storage data of each first type of combination is generated according to the number of result groups in the first type of combination; the second storage data of each second type of combination is generated according to the XOR results in the second type of combination; therefore, the embodiment of the present application can determine the storage data of each result group according to the data fluctuation of the floating-point numbers corresponding to each XOR result included in each result group in the result group sequence.

[0113] That is to say, in the embodiment of the present application, different data fluctuation situations can correspond to different data compression methods, and since in the embodiment of the present application, lossless compression of floating-point data can be achieved during the compression process of floating-point data, the data compression method provided in the embodiment of the present application can improve the compression rate of lossless compression of floating-point numbers. BRIEF DESCRIPTION OF THE DRAWINGS

[0114] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other embodiments can also be obtained based on these drawings.

[0115] Figure 1 A schematic diagram of a flow chart of a data compression method provided in an embodiment of the present application;

[0116] Figure 2 A schematic diagram of a data structure provided for an embodiment of the present application;

[0117] Figure 3Another schematic diagram of a data compression method according to an embodiment of the present invention;

[0118] Figure 4 A schematic diagram of a data storage structure provided in an embodiment of the present application;

[0119] FIG5( a) is a schematic diagram of a data structure provided in an embodiment of the present application;

[0120] FIG5( b ) is a schematic diagram of another data storage structure provided in an embodiment of the present application;

[0121] FIG5( c ) is a schematic diagram of another data storage structure provided in an embodiment of the present application;

[0122] Figure 6 A schematic diagram of a flow chart of a data decompression method provided in an embodiment of the present application;

[0123] Figure 7 A schematic diagram of another flow chart of the data compression method provided in the embodiment of the present application;

[0124] Figure 8 Another schematic diagram of a flow chart of a data decompression method provided in an embodiment of the present application;

[0125] 9(a)-(c) are schematic diagrams of a data compression effect provided in an embodiment of the present application;

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

[0127] Fig.11 A schematic diagram of the structure of a data decompression device provided in an embodiment of the present application;

[0128] Fig.12 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0129] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field based on the present application belong to the scope of protection of the present application.

[0130] In related technologies, integer compression technology is becoming increasingly mature. In most time series scenarios, integer compression can already achieve a relatively ideal compression rate, while the compression rate of floating-point lossless compression methods is far lower than that of integers. Since in most IoT scenarios, the data collected by sensors are of floating-point type, optimizing the compression of floating-point numbers is of great value in IoT time series scenarios.

[0131] Currently, there is an urgent need for a data compression method to improve the compression rate of lossless compression of floating-point numbers.

[0132] In order to solve the above problems, an embodiment of the present application provides a data compression method.

[0133] The method can be applied to various scenarios of data compression of floating point numbers, for example, a scenario in which a device compresses data of a floating point number sequence generated by itself, a scenario in which a device compresses data of a floating point number sequence received by it, etc. The embodiments of the present application do not limit specific application scenarios.

[0134] In addition, the execution subject of the embodiments of the present application can be various electronic devices that can perform data processing, such as sensors, mobile phones, laptops, desktop computers, various Internet of Things devices, etc.; wherein, the electronic device can be an independent electronic device or a device cluster composed of multiple electronic devices. The embodiments of the present application do not make specific limitations on this, and are hereinafter referred to as electronic devices.

[0135] Optionally, the above-mentioned sensor with data processing function may include at least one of various sensors such as image sensors, infrared sensors, microphones, photosensors, sound sensors, pressure sensors, etc. The processor in the electronic device can convert the data collected by the sensor into floating point numbers and generate a floating point number sequence, thereby compressing the floating point number sequence generated by itself, and then storing the compressed data in the memory.

[0136] A data compression method provided in an embodiment of the present application may include the following steps:

[0137] Converting multiple floating-point numbers in the floating-point number sequence to be compressed into integers respectively to obtain an integer sequence, and writing the first integer in the integer sequence into a preset storage space;

[0138] Starting from the second integer in the integer sequence, calculating the XOR result of each integer and the integer before the integer to obtain a result sequence, and starting from the first XOR result in the result sequence, grouping the result sequence according to a preset number to obtain a result group sequence;

[0139] Determine a first type of combination and a second type of combination in the result group sequence; wherein the first type of combination is: a plurality of result groups whose XOR results are all 0 and are continuous, or a result group whose XOR results are all 0 and whose adjacent result groups all include XOR results that are not 0, and the second type of combination is: a result group including an XOR result that is not 0;

[0140] Generate first storage data about the first type of combination according to the number of result groups in each first type of combination, and generate second storage data about the second type of combination according to the XOR result in each second type of combination;

[0141] Starting from the storage position next to the storage position where the first integer is located in the preset storage space, the generated first storage data and the generated second storage data are sequentially written into the preset storage space according to the arrangement order of the result groups in each first type combination and each second type combination in the result group sequence;

[0142] The first integer, each first stored data and each second stored data written in the preset storage space are determined as compressed data of the floating-point number sequence.

[0143] Based on this, the data compression method provided by the embodiment of the present application is applied. Since the integer sequence is determined based on the floating-point sequence to be compressed, the result sequence is determined by starting from the second integer in the integer sequence and calculating the XOR result of each integer and the previous integer of the integer. Therefore, if there is no data fluctuation in the floating-point sequence, that is, each floating-point number in the floating-point sequence is the same, then each integer in the integer sequence is the same, and each XOR result in the result sequence is 0. It can be seen that each XOR result in the result sequence can reflect the data fluctuation of the floating-point sequence. Furthermore, for each result group, if the XOR results included in the result group are all 0, it means that there is no data fluctuation in the floating-point number corresponding to each XOR result in the result group; if the result group includes an XOR result that is not 0, it means that there is data fluctuation in the floating-point number corresponding to each XOR result in the result group. Since in the data compression method provided in the embodiment of the present application, the first type of combination is: a plurality of result groups whose XOR results are all 0 and continuous, or a result group whose XOR results are all 0 and whose adjacent result groups all include XOR results that are not 0, and the second type of combination is: a result group including XOR results that are not 0; the first storage data of each first type of combination is generated according to the number of result groups in the first type of combination; the second storage data of each second type of combination is generated according to the XOR results in the second type of combination; therefore, the embodiment of the present application can determine the storage data of each result group according to the data fluctuation of the floating-point numbers corresponding to each XOR result included in each result group in the result group sequence.

[0144] That is to say, in the embodiment of the present application, different data fluctuation situations can correspond to different data compression methods, and since in the embodiment of the present application, lossless compression of floating-point data can be achieved during the compression process of floating-point data, the data compression method provided in the embodiment of the present application can improve the compression rate of lossless compression of floating-point numbers.

[0145] Below, in conjunction with the accompanying drawings, a data compression method provided in an embodiment of the present application is specifically described.

[0146] Figure 1 A flow chart of a data compression method provided in an embodiment of the present application is shown as follows: Figure 1 As shown, the method may include the following steps S101-S106.

[0147] S101: Convert multiple floating-point numbers in a floating-point number sequence to be compressed into integers respectively to obtain an integer sequence, and write the first integer in the integer sequence into a preset storage space.

[0148] When compressing a floating-point number sequence to be compressed, multiple floating-point numbers in the floating-point number sequence to be compressed may be converted into integers to obtain an integer sequence, and the first integer in the integer sequence may be written into a preset storage space.

[0149] The arrangement order of the integers obtained by converting the floating-point numbers into integers in the integer sequence is the same as the arrangement order of the floating-point numbers in the floating-point number sequence to be compressed.

[0150] Optionally, in a specific implementation, multiple floating-point numbers in the floating-point number sequence to be compressed may be converted into integers respectively according to the IEEE745 standard.

[0151] For example, after converting a 64-bit floating point number into an integer representation according to the IEEE 745 standard, the format of the resulting integer can be as follows: Figure 2 As shown. It can be seen that after converting a 64-bit floating point number into an integer representation, the resulting integer may include: a sign bit, an exponent bit, and a mantissa bit, and the sign bit may occupy 1 bit (1 bit), the exponent bit may occupy 11 bits (11 bits), and the mantissa bit may occupy 52 bits (52 bits).

[0152] For example, after converting the floating point number 15.5 to an integer using the IEEE745 standard, the resulting integer is 0x402f0000000000000.

[0153] Optionally, in some specific implementations, the above floating point number sequence is: a multimedia data sequence; and the above multimedia data includes: at least one of video data, audio data and image data. Furthermore, in the field of multimedia technology, when compressing data of types such as video data, audio data and image data, the data compression method provided by the embodiment of the present application is applied to improve the data compression rate. Moreover, when transmitting or storing data of types such as video data, audio data and image data, the data compression method provided by the embodiment of the present application is first applied to compress the data, which can improve the data transmission efficiency and save storage space.

[0154] Of course, in the embodiment of the present application, the specific data type of each floating-point number in the above floating-point number sequence is not limited. For example, each floating-point number in the above floating-point number sequence may also be text data, etc.

[0155] S102: Starting from the second integer in the integer sequence, calculate the XOR result of each integer and the integer before the integer to obtain a result sequence, and starting from the first XOR result in the result sequence, group the result sequence according to a preset number to obtain a result group sequence.

[0156] After the first integer in the integer sequence is written into the preset storage space, the XOR result of each integer and the previous integer can be calculated starting from the second integer in the integer sequence to obtain a result sequence composed of the individual XOR results, and starting from the first XOR result in the result sequence, the result sequence is grouped according to a preset number to obtain a result group sequence.

[0157] For example, if the first two numbers in the floating-point number sequence are 15.5 and 14.0625 respectively, 15.5 can be converted to the integer 0x402f000000000000, and 14.0625 can be converted to the integer 0x402c200000000000, then the first integer in the obtained integer sequence is 0x402f000000000000, and the second integer is 0x402c200000000000, and then, the XOR result of the second integer and the first integer in the integer sequence is calculated, that is, 0x402f000000000000 and 0x402c2000000000000 are XORed, so as to obtain the first XOR result 0x0003200000000000 in the result sequence.

[0158] Among them, the above-mentioned preset number can be set by those skilled in the art according to actual application conditions, and the embodiments of the present application are not specifically limited here.

[0159] Optionally, the preset number may be 8, and then, starting from the first XOR result in the result sequence, every 8 consecutive XOR results may be divided into one result group to obtain a result group sequence.

[0160] Exemplarily, if the result sequence includes 30 XOR results, and the 30 XOR results are all 0, then every 8 consecutive XOR results are divided into 1 result group, and the resulting result group sequence may include: the first 3 result groups containing 8 XOR results of 0 and the 4th result group containing 6 XOR results of 0.

[0161] Optionally, you can start from the first XOR result in the result sequence, and traverse each XOR result in the result group sequence according to the arrangement order of each XOR result in the result group sequence, and after traversing a preset number of XOR results that have not been divided into a result group, divide the preset number of XOR results into a result group, thereby obtaining a result group sequence.

[0162] S103: Determine the first type of combination and the second type of combination in the result group sequence.

[0163] Among them, the first type of combination is: multiple result groups whose XOR results are all 0 and are continuous, or a result group whose XOR results are all 0 and whose adjacent result groups all include XOR results that are not 0; the second type of combination is: a result group including XOR results that are not 0.

[0164] After obtaining the result group sequence, for each result group in the result group sequence, a plurality of result groups whose XOR results are all 0 and are continuous, or a result group whose XOR results are all 0 and whose adjacent result groups all include XOR results that are not 0, can be determined as a first-category combination, and a result group including an XOR result that is not 0 can be determined as a second-category combination, thereby obtaining each first-category combination and each second-category combination.

[0165] S104: Generate first storage data about the first type of combination according to the number of result groups in each first type of combination, and generate second storage data about the second type of combination according to the XOR result in each second type of combination.

[0166] For each first-type combination, first storage data about the first-type combination can be generated according to the number of result groups in the first-type combination; for each second-type combination, second storage data about the second-type combination can be generated according to the XOR result in the second-type combination.

[0167] S105: Starting from the storage position next to the storage position where the first integer is located in the preset storage space, the generated first storage data and the generated second storage data are sequentially written into the preset storage space according to the arrangement order of the result groups in each first category combination and each second category combination in the result group sequence.

[0168] The stored data may include first stored data and second stored data, and after the stored data is obtained, it can be written into the storage space. When writing the stored data into the storage space, starting from the storage position next to the storage position where the first integer is located in the preset storage space, the generated first stored data and second stored data can be sequentially written into the preset storage space according to the arrangement order of the result groups in each first type combination and each second type combination in the result group sequence.

[0169] That is to say, the first integer, the target number, the first stored data and the second stored data are sequentially written into the preset storage space.

[0170] The preset storage space may be a memory space of an electronic device for executing the data compression method provided in the embodiment of the present application, or a disk installed in the electronic device, or a cloud storage space associated with the electronic device, which is reasonable. In this regard, the embodiment of the present application does not limit the specific type of the preset storage space, and in practical applications, it can be set according to the actual needs of the data compression scenario.

[0171] Optionally, in a specific implementation method, after generating all the first storage data about the first category combinations and generating all the second storage data about the second category combinations, starting from the storage position next to the storage position where the first integer is located in the preset storage space, the generated first storage data and second storage data are sequentially written into the preset storage space according to the arrangement order of the result groups in each first category combination and each second category combination in the result group sequence.

[0172] Optionally, in a specific implementation, the first storage data and the second storage data are generated according to the arrangement order of the result groups in each first-category combination and each second-category combination in the result group sequence. Furthermore, in this case, after each storage data is generated, the storage data can be written into the preset storage space.

[0173] Furthermore, the generated first storage data can be written into the preset storage space starting from the next storage position of the storage position where the first integer is located in the preset storage space; the generated second storage data can be written into the preset storage space starting from the next storage position of the storage position where the first storage data is located; the generated third storage data can be written into the preset storage space starting from the next storage position of the storage position where the second storage data is located; and so on, until all the first storage data regarding the first type of combination and all the second storage data regarding the second type of combination are written into the preset storage space.

[0174] S106: Determine the first integer, each first stored data, and each second stored data written in the preset storage space as compressed data of a floating-point number sequence.

[0175] After all the first storage data and the second storage data are written into the preset storage space, the first integer, the first storage data and the second storage data written into the preset storage space can be determined as compressed data of the above floating point number sequence.

[0176] Optionally, in a specific implementation, the data compression method provided in the embodiment of the present application may further include the following step 11.

[0177] Step 11: Compress the compressed data of the floating point number sequence using a preset compression method to obtain target compressed data.

[0178] In this specific implementation, after the compressed data of the floating-point number sequence is obtained, the obtained compressed data may be further compressed using a preset compression method to obtain target compressed data.

[0179] The preset compression method can be set by those skilled in the art according to specific application conditions, and the present application embodiment does not specifically limit it. For example, the preset compression method can be a general entropy coding method such as Huffman coding.

[0180] As can be seen from the above, the data compression method provided by the embodiment of the present application is applied. Since the integer sequence is determined based on the floating-point sequence to be compressed, the result sequence is determined by starting from the second integer in the integer sequence and calculating the XOR result of each integer and the previous integer of the integer. Therefore, if there is no data fluctuation in the floating-point sequence, that is, the floating-point numbers in the floating-point sequence are all the same, then the integers in the integer sequence are all the same, and the XOR results in the result sequence are all 0. It can be seen that the XOR results in the result sequence can reflect the data fluctuation of the floating-point sequence. Furthermore, for each result group, if the XOR results included in the result group are all 0, it means that there is no data fluctuation in the floating-point numbers corresponding to the XOR results in the result group; if the result group includes an XOR result that is not 0, it means that there is data fluctuation in the floating-point numbers corresponding to the XOR results in the result group. Since in the data compression method provided in the embodiment of the present application, the first type of combination is: a plurality of result groups whose XOR results are all 0 and continuous, or a result group whose XOR results are all 0 and whose adjacent result groups all include XOR results that are not 0, and the second type of combination is: a result group including XOR results that are not 0; the first storage data of each first type of combination is generated according to the number of result groups in the first type of combination; the second storage data of each second type of combination is generated according to the XOR results in the second type of combination; therefore, the embodiment of the present application can determine the storage data of each result group according to the data fluctuation of the floating-point numbers corresponding to each XOR result included in each result group in the result group sequence.

[0181] That is to say, in the embodiment of the present application, different data fluctuation situations can correspond to different data compression methods, and since in the embodiment of the present application, lossless compression of floating-point data can be achieved during the compression process of floating-point data, the data compression method provided in the embodiment of the present application can improve the compression rate of lossless compression of floating-point numbers.

[0182] Optionally, in a specific implementation, the above step S103: determining the first type of combination and the second type of combination in the result group sequence may include the following steps 21-23.

[0183] Step 21: traverse each result group in turn according to the arrangement order of each result group in the result group sequence, and when traversing to each result group, determine whether each XOR result included in the result group is 0.

[0184] If yes, go to step 22; if no, go to step 23.

[0185] Step 22: traverse the next result group until there is an XOR result that is not 0 in the traversed result group, and determine the traversed result group that is not divided into any combination and all the XOR results included are 0 as the first type of combination.

[0186] Step 23: Determine the result group as a second type of combination.

[0187] When determining the first type of combination and the second type of combination in the result group sequence, each result group may be traversed in sequence according to the arrangement order of each result group in the result group sequence, and when each result group is traversed, it is determined whether each XOR result included in the result group is all 0. If each XOR result included in the result group is all 0, the next result group may be traversed continuously until there is an XOR result that is not 0 in the traversed result group, and the traversed result group that is not classified into any combination and each XOR result included is 0 is determined as a first type of combination; if there is an XOR result that is not 0 in the result group, the result group may be determined as a second type of combination.

[0188] Exemplarily, a result group in which all XOR results are 0 can be regarded as a first result group, and a result group in which all XOR results are not 0 can be regarded as a second result group. Furthermore, if the result groups in the result group sequence A are arranged in the order of: first result group 1, second result group 2, first result group 3, first result group 4, and second result group 5, then when determining the first type of combination and the second type of combination in the result group sequence A, the first result group 1 can be traversed first. Since all XOR results included in the first result group 1 are 0, the second result group 2 can be traversed continuously. Since there are XOR results that are not 0 in the second result group 2, the first result group 1 that is not divided into any combination and in which all XOR results are 0 can be determined as a first type of combination, and the second result group 2 can be determined as a second type of combination. Similarly, the first result group 3 and the first result group 4 can be determined as a first type of combination, and the second result group 5 can be determined as a second type of combination, thereby obtaining the first type of combination and the second type of combination in the result group sequence A.

[0189] Optionally, in a specific implementation, the above step S104: generating first storage data about the first type combination according to the number of result groups in each first type combination, and generating second storage data about the second type combination according to the XOR result in each second type combination, may include the following steps 31-32.

[0190] Step 31: when each first-category combination is determined to be obtained, storage data including preset first identification information, a first number of bytes and a first number of result groups in the first-category combination is generated as first storage data about the first-category combination.

[0191] The first number of bytes is used to represent the number of bytes occupied by the first number when storing the first number.

[0192] When each first-category combination is determined to be obtained, storage data including preset first identification information, a first number of bytes and a first number of result groups in the first-category combination may be generated as first storage data on the first-category combination.

[0193] Among them, the above-mentioned first identification information can be set by technical personnel in this field according to specific application situations, and the number of bits occupied by the above-mentioned first byte number can also be set by technical personnel in this field according to specific application situations. This application does not make specific limitations on this.

[0194] 1 byte contains 8 bits, and the range of integer numbers that can be represented is 0-255; 2 bytes contain 16 bits, and the range of integer numbers that can be represented is 0-65535; and so on.

[0195] Exemplarily, the first identification information may be a number 0 occupying one bit, and the number of bits occupied by the first byte number may be 3. If the first type combination B includes 10 result groups, then the first number of result groups in the first type combination B may be 10. Since the first number 10 can be represented by 1 byte, the first byte number may be 1. Further, the data storage structure of the first storage data of the first type combination B may be as follows: Figure 4 shown.

[0196] Step 32: when each second type combination is determined to be obtained, second storage data about the second type combination is generated according to the distribution of 0 in each XOR result in the second type combination.

[0197] When each second type combination is determined to be obtained, second storage data on the second type combination may be generated according to the distribution of 0s in each XOR result in the second type combination.

[0198] Optionally, in a specific implementation method, the above-mentioned step S105: starting from the next storage position of the storage position where the first integer is located in the preset storage space, the generated first storage data and the second storage data are sequentially written into the preset storage space according to the arrangement order of the result groups in each first category combination and each second category combination in the result group sequence, which may include the following step 41.

[0199] Step 41: starting from the storage position next to the storage position where the first integer is located in the preset storage space, after each first storage data or second storage data is generated, the first storage data or the second storage data is sequentially written into the preset storage space.

[0200] When writing the storage data into the storage space, it can start from the storage position next to the storage position where the first integer is located in the preset storage space, and after generating each first storage data or second storage data, the first storage data or the second storage data is sequentially written into the preset storage space.

[0201] Optionally, in a specific implementation, such as Figure 3 As shown, the data compression method provided in the embodiment of the present application may include the following steps S301-S309.

[0202] S301: Convert multiple floating-point numbers in a floating-point number sequence to be compressed into integers respectively to obtain an integer sequence, and write the first integer in the integer sequence into a preset storage space.

[0203] S302: Starting from the second integer in the integer sequence, calculate the XOR result of each integer and the integer before the integer to obtain a result sequence, and starting from the first XOR result in the result sequence, group the result sequence according to a preset number to obtain a result group sequence.

[0204] S303: traverse each result group in turn according to the arrangement order of each result group in the result group sequence, and when traversing to each result group, determine whether each XOR result included in the result group is 0.

[0205] If yes, execute step S304; if no, execute step S306.

[0206] S304: traverse the next result group until there is an XOR result that is not 0 in the traversed result group, and determine the traversed result group that is not classified into any combination and all the XOR results are 0 as the first type of combination.

[0207] S305: When each first-category combination is determined to be obtained, storage data including preset first identification information, a first number of bytes, and a first number of result groups in the first-category combination is generated as first storage data about the first-category combination.

[0208] The first number of bytes is used to represent the number of bytes occupied by the first number when storing the first number.

[0209] S306: Determine the result group as a second type of combination.

[0210] S307: When it is determined that each second type of combination is obtained, second storage data about the second type of combination is generated according to the distribution of 0 in each XOR result in the second type of combination.

[0211] S308: Starting from the storage position next to the storage position where the first integer is located in the preset storage space, after each first storage data or second storage data is generated, the first storage data or the second storage data is sequentially written into the preset storage space.

[0212] S309: Determine the first integer, each first stored data, and each second stored data written in the preset storage space as compressed data of a floating-point number sequence.

[0213] Since the above-mentioned step S301 is the same as the above-mentioned step S101, the above-mentioned step S302 is the same as the above-mentioned step S102, the above-mentioned step S303 is the same as the above-mentioned step 21, the above-mentioned step S304 is the same as the above-mentioned step 22, the above-mentioned step S305 is the same as the above-mentioned step 31, the above-mentioned step S306 is the same as the above-mentioned step 23, the above-mentioned step S307 is the same as the above-mentioned step 32, the above-mentioned step S308 is the same as the above-mentioned step 41, and the above-mentioned step S309 is the same as the above-mentioned step S106, therefore, in this specific implementation method, steps S301-S309 are not repeated.

[0214] Optionally, in a specific implementation, in the above step S305, generating second storage data about the second type of combination according to the distribution of 0 in each XOR result in the second type of combination may include the following step 51.

[0215] Step 51: Generate first information or second information about the second type of combination as second storage data about the second type of combination according to the distribution of 0 in each XOR result in the second type of combination.

[0216] The first information includes: preset second identification information, number of public valid bits, number of public low-order 0 bits and valid bit information; the second information includes: preset third identification information, number of public high-order 0 bits and data information.

[0217] Among them, the above-mentioned second identification information and third identification information can be set by technical personnel in this field according to specific application situations, and the embodiments of the present application do not specifically limit them.

[0218] The above-mentioned number of common low-order 0s is used to represent: the minimum number of bits occupied by the low-order 0s of each XOR result in the second type of combination or the minimum number of complete bytes; the low-order 0 of each XOR result is: the 0 before the first appearance of a non-zero number in order from the lowest bit to the highest bit.

[0219] Exemplarily, as shown in FIG5(a), the low bit 0 of the XOR result 0000001010110000 which occupies 16 bits is the 0 in the last 4 bits of the XOR result.

[0220] Exemplarily, if the number of bits occupied by the low-order 0s of each XOR result in the second type of combination is 10, 20, 30, 15, 10 and 20 respectively, then if the above-mentioned number of common low-order 0s is used to represent the minimum number of bits occupied by the low-order 0s of each XOR result in the second type of combination, the above-mentioned number of common low-order 0s is 10; if the above-mentioned number of common low-order 0s is used to represent the minimum number of complete bytes occupied by the low-order 0s of each XOR result in the second type of combination, the above-mentioned number of common low-order 0s is 1.

[0221] The above-mentioned number of common valid bits is used to represent: the maximum value of the number of valid bits in each XOR result in the second type of combination, and the valid bits of each XOR result are: the bits occupied by each XOR result, in order from the highest bit to the lowest bit, from the first non-zero number that appears to the last non-zero number that appears.

[0222] Exemplarily, as shown in FIG5( a ), the valid digit of the XOR result 0000001010110000 which occupies 16 bits is 101011, and the number of valid digits is 6.

[0223] Exemplarily, if the numbers of valid bits in each XOR result in the second type of combination are 30, 30, 30, 30, 40, 50, 40 and 35 respectively, then the number of common valid bits of each XOR result in the second type of combination is 50.

[0224] The above-mentioned number of common high-order 0s is used to represent: the minimum number of bits occupied by the high-order 0s of each XOR result in the second type of combination or the minimum number of complete bytes; the high-order 0 of each XOR result is: the 0 before the first appearance of a non-zero number in order from the highest bit to the lowest bit.

[0225] Exemplarily, as shown in FIG5(a), the high bit 0 of the XOR result 0000001010110000 which occupies 16 bits is 0 in the first 6 bits of the XOR result.

[0226] Exemplarily, if the number of bits occupied by the high-order 0s of each XOR result in the second type of combination is 10, 20, 30, 15, 10 and 20 respectively, then if the above-mentioned number of common high-order 0s is used to represent the minimum number of bits occupied by the high-order 0s of each XOR result in the second type of combination, the above-mentioned number of common high-order 0s is 10; if the above-mentioned number of common high-order 0s is used to represent the minimum number of complete bytes occupied by the high-order 0s of each XOR result in the second type of combination, the above-mentioned number of common high-order 0s is 1.

[0227] The above-mentioned valid bit information is: the value of the common valid bit of each XOR result in the second type of combination arranged according to the arrangement information of each XOR result in the second type of combination; the common valid bit of each XOR result is: the bits occupied by each XOR result, in the order from the highest bit to the lowest bit, after removing the common high-order 0 number of bits, and in the order from the lowest bit to the highest bit, after removing the common low-order 0 number of bits. The remaining bits.

[0228] For example, the number of high-order 0s in the XOR result 00101000 is 2, and the number of low-order 0s is 3; the number of high-order 0s in the XOR result 00011100 is 3, and the number of low-order 0s is 2; furthermore, the number of common high-order 0s of the two XOR results is 2, the number of common low-order 0s is 2, and the common valid bits are the 3rd, 4th, 5th, and 6th valid bits in order from the highest bit to the lowest bit; furthermore, the valid bit information of the XOR result 00101000 is 1010, and the valid bit information of the XOR result 00011100 is 0111.

[0229] Exemplarily, the preset second identification information may be 11, and the data storage structure of the above-mentioned first information may be as shown in FIG5(b), wherein data 11-data 1n are valid bit information of each XOR result in the second type of combination. It can be seen that for each second type of combination, the preset second identification information, the number of common valid bits of each XOR result in the second type of combination, the number of common low-order 0s of each XOR result in the second type of combination, and the valid bit information of each XOR result in the second type of combination can constitute the first information about the second type of combination by sequential arrangement.

[0230] The above-mentioned data information includes: target information of each XOR result in the second type of combination arranged according to the arrangement information of each XOR result in the second type of combination; for each XOR result in the second type of combination, if the XOR result is 0, then the target information of the XOR result is a first value, if the XOR result is not 0, then the target information of the XOR result includes: a second value, and the value of the remaining bits in the XOR result after removing the number of common high-order 0 bits in the XOR result in order from the highest bit to the lowest bit.

[0231] Among them, the above-mentioned first numerical value and second numerical value can be set by those skilled in the art according to specific application conditions, and are not specifically limited in the embodiments of the present application.

[0232] Exemplarily, if the second numerical value is 1, the XOR result is 00011100, and the number of common high-order 0s is 2, then the target information of the XOR result is 1011100.

[0233] Exemplarily, the preset third identification information can be 10, the above-mentioned first value can be 0, and the above-mentioned second value can be 1. Furthermore, the data storage structure of the above-mentioned first information can be as shown in Figure 5(c), wherein data 21-data 2n represent the values ​​of the remaining bits in the XOR result after removing the number of common high-order 0 bits in the XOR result in the order from the highest bit to the lowest bit when the XOR result is not 0. It can be seen that for each second-class combination, the preset third identification information, the number of common high-order 0s of each XOR result in the second-class combination, and the data information of each XOR result in the second-class combination can constitute the second information about the second-class combination by sequential arrangement.

[0234] Optionally, in a specific implementation, in the above step 51, generating the first information or the second information about the second type of combination as the second storage data about the second type of combination may include the following steps 61-62.

[0235] Step 61: If the number of XOR results of 0 included in the second type of combination is less than the specified number, generate first information about the second type of combination as second storage data about the second type of combination.

[0236] For each second type combination, when determining the second stored data about the second type combination, if the number of XOR results of 0 included in the second type combination is less than a specified number, first information about the second type combination can be generated as the second stored data about the second type combination.

[0237] Step 62: If the number of XOR results of 0 included in the second type of combination is not less than the specified number, generate second information about the second type of combination as second storage data about the second type of combination.

[0238] If the number of XOR results of 0 included in the second type of combination is not less than a specified number, second information about the second type of combination may be generated as second storage data about the second type of combination.

[0239] The above-mentioned specified number can be set by those skilled in the art according to specific application conditions, and is not specifically limited in this specific embodiment.

[0240] Optionally, in a specific implementation, in the above step 51, generating the first information or the second information about the second type of combination as the second storage data about the second type of combination may include the following steps 63-65.

[0241] Step 63: Determine a first data volume of the first information about the second type of combination and a second data volume of the second information about the second type of combination.

[0242] For each second type combination, when determining the second stored data about the second type combination, a first data amount of the first information about the second type combination and a second data amount of the second information about the second type combination may be determined first.

[0243] Step 64: If the first data amount is smaller than the second data amount, generating first information about the second type of combination as second stored data about the second type of combination.

[0244] If the first data amount is smaller than the second data amount, first information on the second type of combination may be generated as second stored data on the second type of combination.

[0245] Step 65: If the first data amount is not less than the second data amount, generating second information about the second type of combination as second stored data about the second type of combination.

[0246] If the first data amount is not less than the second data amount, second information on the second type of combination may be generated as second stored data on the second type of combination.

[0247] Based on this, by applying the present specific implementation method, for each second type combination, when determining the second storage data about the second type combination, the information with smaller data volume between the first information and the second information can be determined as the second storage data about the second type combination, thereby further improving the compression rate of the floating-point number.

[0248] Optionally, in a specific implementation, in the above step S101, writing the first integer in the integer sequence into the preset storage space may include the following step 71.

[0249] Step 71: In a preset storage space, sequentially write the first integer in the integer sequence and the target number of integers in the integer sequence.

[0250] Correspondingly, the above-mentioned step S105: starting from the next storage position of the storage position where the first integer is located in the preset storage space, the generated first storage data and the second storage data are sequentially written into the preset storage space according to the arrangement order of the result groups in each first category combination and each second category combination in the result group sequence, which may include the following step 72.

[0251] Step 72: Starting from the next storage position of the storage position where the target number is located in the preset storage space, the generated first storage data and the second storage data are sequentially written into the preset storage space according to the arrangement order of the result groups in each first category combination and each second category combination in the result group sequence.

[0252] Correspondingly, the above step S106: determining the first integer, each first stored data and each second stored data written in the preset storage space as compressed data of the floating point number sequence may include the following step 73.

[0253] Step 73: Determine the first integer, the target number, each first stored data and each second stored data written in the preset storage space as compressed data of the floating point number sequence.

[0254] After converting multiple floating-point numbers in the floating-point number sequence to be compressed into integers respectively to obtain an integer sequence, the first integer in the integer sequence and the target number of integers in the integer sequence can be sequentially written into the preset storage space. Then, when writing the generated first storage data and second storage data into the preset storage space, starting from the next storage position of the storage position where the target number is located in the preset storage space, the generated first storage data and second storage data can be sequentially written into the preset storage space according to the arrangement order of the result groups in each first-type combination and each second-type combination in the result group sequence. Then, the first integer, the target number, the first storage data and the second storage data written in the preset storage space can be determined as the compressed data of the floating-point number sequence.

[0255] Based on this, when decompressing the compressed data, the first integer and the target number in the compressed data can be read first, and then the first stored data and the second stored data included in the compressed data can be read in sequence according to the arrangement order of the stored data in the compressed data. When each stored data is read, the stored data is parsed to obtain the XOR result corresponding to the stored data. When the number of XOR results obtained reaches the difference between the target number and 1, it means that all the first stored data and the second stored data have been read, and then, the compressed data can be stopped when the number of XOR results obtained reaches the difference between the target number and 1. According to the order in which each XOR result is obtained, each XOR result and the previous integer obtained are XORed in turn, and the target integer corresponding to the XOR result can be obtained. Finally, each integer is converted into a floating point number, and each floating point number corresponding to each integer is written into the floating point number sequence according to the order in which each integer is obtained, so that the decompressed data corresponding to the compressed data can be obtained.

[0256] Optionally, after reading the first integer, the first integer can be written into the first sequence, and after each XOR result is obtained, the XOR result is written into the second sequence. Furthermore, when the number of XOR results in the second sequence reaches the difference between the above target number and 1, starting from the first XOR result in the second sequence, for each XOR result in the second sequence, the XOR result and the last integer obtained are XORed to obtain the target integer corresponding to the XOR result, and the target integer is written into the first sequence. After writing the target integer corresponding to the last XOR result in the second sequence into the first sequence, each integer in the integer sequence can be converted into a floating point number, and each floating point number corresponding to each integer is written into the floating point number sequence in the order in which each integer is written into the first sequence, thereby obtaining the decompressed data corresponding to the above compressed data.

[0257] Optionally, when writing the first integer and the target number into the preset storage space, the target number and the first integer can also be written sequentially into the preset storage space. Furthermore, when writing the generated first storage data and second storage data into the preset storage space, the generated first storage data and second storage data can be written sequentially into the preset storage space starting from the storage position next to the storage position where the first integer is located in the preset storage space, according to the arrangement order of the result groups in each first-type combination and each second-type combination in the result group sequence.

[0258] Optionally, in a specific implementation, in the above step S101, before converting multiple floating-point numbers in the floating-point number sequence to be compressed into integers respectively to obtain the integer sequence, a data compression method provided in an embodiment of the present application may also include the following step 81.

[0259] Step 81: Add a preset floating point number after the last floating point number sequence in the floating point number sequence to be compressed.

[0260] The preset floating-point number is different from each floating-point number in the floating-point number sequence to be compressed.

[0261] Correspondingly, in the above step S101, converting the plurality of floating-point numbers in the floating-point number sequence to be compressed into integers respectively to obtain an integer sequence may include the following step 82.

[0262] Step 82: converting multiple floating-point numbers in the floating-point number sequence to which the preset floating-point number is added into integers respectively to obtain an integer sequence.

[0263] Before converting the multiple floating-point numbers in the floating-point number sequence to be compressed into integers, a preset floating-point number may be added after the last floating-point number sequence in the floating-point number sequence to be compressed, and the preset floating-point number may be different from the floating-point numbers in the floating-point number sequence to be compressed. Accordingly, when converting the multiple floating-point numbers in the floating-point number sequence to be compressed into integers, the multiple floating-point numbers in the floating-point number sequence to which the preset floating-point number is added may be converted into integers, thereby obtaining an integer sequence.

[0264] Furthermore, when decompressing the compressed data, the first integer in the compressed data can be read first, and then the first stored data and the second stored data included in the compressed data can be read in sequence according to the arrangement order of the stored data in the compressed data. When each stored data is read, the stored data is parsed to obtain the XOR result corresponding to the stored data. After obtaining each XOR result, the XOR result and the previous integer obtained can be XORed to obtain the target integer corresponding to the XOR result, and the target integer corresponding to the XOR result can be converted into a floating point number. After obtaining each floating point number, it can be determined whether the floating point number is a preset floating point number. If the floating point number is not a preset floating point number, the floating point number can be written into a floating point number sequence; if the floating point number is a floating point number, the decompression is completed. Then, the current floating point number sequence can be determined as the decompressed data corresponding to the data to be decompressed.

[0265] Among them, the embodiments of the present application do not specifically limit the above-mentioned preset floating-point number, and those skilled in the art can set the above-mentioned preset floating-point number according to specific application conditions.

[0266] Exemplarily, the preset floating point number may be a NAN (Not A Number) floating point number.

[0267] Corresponding to the data compression method provided in the embodiment of the present application, the embodiment of the present application also provides a data decompression method, such as Figure 6 As shown, the data decompression method may include the following steps S601-S605.

[0268] S601: Obtain the data to be decompressed, and read the first integer in the data to be decompressed.

[0269] The data to be decompressed is obtained by any of the above-mentioned data compression methods.

[0270] Since the data to be decompressed is obtained by any of the above-mentioned data compression methods, when decompressing the data to be decompressed, the data to be decompressed may be obtained first, and then the first integer in the data to be decompressed may be read.

[0271] Optionally, the position of the first integer in the data to be decompressed and the number of bytes it occupies are known. Then, after obtaining the data to be decompressed, the first integer in the data to be decompressed can be read according to the position of the first integer in the data to be decompressed and the number of bytes it occupies.

[0272] Exemplarily, in the data to be decompressed, the first integer is represented by a bytes located at the starting position. Then, after obtaining the data to be decompressed, a bytes can be read first to obtain the first integer in the data to be decompressed.

[0273] S602: Reading each stored data in the data to be decompressed in sequence according to the arrangement order of each stored data in the data to be decompressed.

[0274] According to any of the above-mentioned data compression methods, the data to be decompressed may include a first integer, each first stored data and each second stored data. Therefore, after obtaining the first integer in the data to be decompressed, each stored data in the data to be decompressed may be read in sequence according to the arrangement order of each stored data in the data to be decompressed.

[0275] S603: When each stored data is read, the stored data is parsed according to the data content of the stored data to obtain an XOR result corresponding to the stored data.

[0276] According to any of the above-mentioned data compression methods, the first stored data is generated based on a first type of combination, and the second stored data is generated based on a second type of combination; the first type of combination is: a result group sequence includes a plurality of result groups whose XOR results are all 0 and are continuous, or a result group whose XOR results are all 0 and adjacent result groups include XOR results that are not 0; the second type of combination is: a result group whose result group sequence includes an XOR result that is not 0; the result group sequence is obtained by grouping the result sequence according to a preset number starting from the first XOR result in the result sequence; the result sequence is obtained by calculating the XOR result of each integer and the integer before the integer starting from the second integer in the integer sequence; therefore, when each stored data is read, the stored data can be parsed according to the data content of the stored data to obtain the XOR result corresponding to the stored data.

[0277] S604: performing XOR calculation on each XOR result and the last integer obtained in the order in which the XOR results are obtained, to obtain a target integer corresponding to the XOR result.

[0278] Since the order of obtaining each XOR result in the data decompression process is the same as the order of obtaining each XOR result in the data compression process, each XOR result in the data compression process is obtained by calculating the XOR result of each integer and the integer before the integer, starting from the second integer in the integer sequence. Therefore, by performing XOR calculation on the first XOR result obtained in the data decompression process and the previous integer obtained, that is, the first integer, the target integer corresponding to the first XOR result can be obtained, that is, the second integer in the integer sequence in the data compression process; by performing XOR calculation on the second XOR result obtained in the data decompression process and the previous integer obtained, that is, the second integer, the target integer corresponding to the second XOR result can be obtained, that is, the third integer in the integer sequence in the data compression process. And so on, all the integers in the integer sequence in the data compression process can be obtained.

[0279] S605: Convert each obtained integer into a floating point number, and write each floating point number corresponding to each integer into a floating point number sequence in the order in which each integer is obtained, to obtain decompressed data corresponding to the data to be decompressed.

[0280] Convert each obtained integer into a floating-point number, and write each floating-point number corresponding to each integer into a floating-point number sequence in the order in which the integers are obtained. After all floating-point numbers corresponding to all integers are written into the floating-point number sequence, the current floating-point number sequence can be used as the decompressed data corresponding to the data to be decompressed.

[0281] Optionally, the data to be decompressed may be compressed data determined based on the data compression method corresponding to the steps 71-73. Then, when decompressing the data to be decompressed, the first integer and the target number in the data to be decompressed may be read first, and then the first stored data and the second stored data included in the data to be decompressed may be read in sequence according to the arrangement order of the stored data in the data to be decompressed. When each stored data is read, the stored data may be parsed according to the data content of the stored data to obtain the XOR result corresponding to the stored data. When the number of XOR results obtained reaches the difference between the target number and 1, it means that all the first stored data and the second stored data have been read. Then, when the number of XOR results obtained reaches the difference between the target number and 1, the reading of the data to be decompressed may be stopped. According to the order in which the XOR results are obtained, each XOR result and the last integer obtained may be XORed to obtain the target integer corresponding to the XOR result. Finally, each obtained integer is converted into a floating-point number, and each floating-point number corresponding to each integer is written into a floating-point number sequence in the order in which each integer is obtained, so that the decompressed data corresponding to the data to be decompressed can be obtained.

[0282] Optionally, the data to be decompressed may be compressed data determined based on the data compression method corresponding to the above steps 81-82. Then, when decompressing the data to be decompressed, the first integer in the data to be decompressed may be read first, and then the first stored data and the second stored data included in the data to be decompressed may be read in sequence according to the arrangement order of the stored data in the data to be decompressed. When each stored data is read, the stored data is parsed to obtain the XOR result corresponding to the stored data. After obtaining each XOR result, the XOR result and the last integer obtained may be XORed to obtain the target integer corresponding to the XOR result, and the target integer corresponding to the XOR result may be converted into a floating point number. After obtaining each floating point number, it may be determined whether the floating point number is a preset floating point number. If the floating point number is not a preset floating point number, the floating point number may be written into a floating point number sequence; if the floating point number is a floating point number, it indicates that the decompression is completed, and then the current floating point number sequence may be determined as the decompressed data corresponding to the data to be decompressed.

[0283] For example, in order to better understand a data compression method provided in an embodiment of the present application, Figure 7 As shown, a data compression method provided in an embodiment of the present application may include the following steps S701-S7011.

[0284] Among them, in this example, the first type of combination is: multiple result groups whose XOR results are all 0 and are continuous, or, a result group whose XOR results are all 0 and adjacent result groups all include XOR results that are not 0; the second type of combination is: a result group including XOR results that are not 0; the first byte number is used to represent the number of bytes occupied by the first quantity when storing the first quantity; the first information includes: a preset second identification information, the number of common valid bits, the number of common low-order 0s and valid bit information; the second information includes: a preset third identification information, the number of common high-order 0s and data information.

[0285] S701: According to the IEEE754 standard, multiple floating-point numbers in a floating-point number sequence to be compressed are respectively converted into integers to obtain an integer sequence, and the first integer in the integer sequence and the target number of integers in the integer sequence are sequentially written into a preset storage space.

[0286] The first integer is represented by a bytes, the target number is represented by b bytes, and both a and b are integers that are not 0.

[0287] When compressing a floating-point number sequence to be compressed, multiple floating-point numbers in the floating-point number sequence to be compressed can be converted into integers according to the IEEE754 standard to obtain an integer sequence, and the first integer in the integer sequence (occupying a bytes) and the target number of integers in the integer sequence (occupying b bytes) are sequentially written into a preset storage space.

[0288] S702: Starting from the second integer in the integer sequence, calculate the XOR result of each integer and the integer before the integer to obtain a result sequence, and starting from the first XOR result in the result sequence, group the result sequence according to a preset number to obtain a result group sequence.

[0289] After obtaining the integer sequence, starting from the second integer in the integer sequence, the XOR result of each integer and the integer before the integer can be calculated to obtain a result sequence, and starting from the first XOR result in the result sequence, the result sequence can be grouped according to a preset number to obtain a result group sequence, and then each result group in the result group sequence can include a preset number of XOR results.

[0290] S703: traverse each result group in turn according to the arrangement order of each result group in the result group sequence, and when traversing to each result group, determine whether each XOR result included in the result group is 0.

[0291] If yes, execute step S704; if no, execute step S706.

[0292] After obtaining the result group sequence, each result group may be traversed in sequence according to the arrangement order of each result group in the result group sequence, and when traversing to each result group, it is determined whether each XOR result included in the result group is 0.

[0293] S704: traverse the next result group until there is an XOR result that is not 0 in the traversed result group, and determine the traversed result group that is not divided into any combination and all the XOR results are 0 as the first type of combination.

[0294] For each result group, if when traversing to the result group, it is determined that all the XOR results included in the result group are 0, then the traversal can continue to the next result group until there is an XOR result that is not 0 in the traversed result group, and then the traversed result group that has not been divided into any combination and in which all the XOR results are 0 can be determined as a first-class combination.

[0295] S705: When it is determined that each first-category combination is obtained, storage data including preset first identification information, a first number of bytes and a first number of result groups in the first-category combination is generated as first storage data about the first-category combination, and the first storage data is written into a preset storage space.

[0296] The preset first identification information is the number 0 occupying one bit, the first byte number is represented by c bits, and c is an integer not equal to 0.

[0297] When each first-class combination is determined, storage data including preset first identification information (0), a first byte number and a first number of result groups in the first-class combination (occupying c bytes) can be generated as the first storage data about the first-class combination, and the first storage data is written into the preset storage space.

[0298] S706: Determine the result group as a second type of combination.

[0299] For each result group, if, when traversing to the result group, it is determined that all XOR results included in the result group are not all 0, the result group can be determined as a second type of combination.

[0300] S707: When each second type combination is determined, determine a first data amount of the first information about the second type combination and a second data amount of the second information about the second type combination.

[0301] The first information includes: a preset second identification information (11), the number of common valid bits (occupying d bits), the number of common low-order 0s (occupying e bits) and valid bit information; the second information includes: a preset third identification information (10), the number of common high-order 0s (occupying f bits) and data information.

[0302] The above-mentioned data information includes: target information of each XOR result in the second type of combination arranged according to the arrangement information of each XOR result in the second type of combination; for each XOR result in the second type of combination, if the XOR result is 0, then the target information of the XOR result is a first value (0); if the XOR result is not 0, then the target information of the XOR result includes: a second value (1), and the value of the remaining bits in the XOR result (occupying g bits) after removing the common high-order 0 bits in the XOR result (occupying g bits) in order from the highest bit to the lowest bit.

[0303] S708: If the first data amount is smaller than the second data amount, generate first information about the second type of combination as second stored data about the second type of combination.

[0304] If the first data amount is smaller than the second data amount, first information on the second type of combination is generated as second stored data on the second type of combination.

[0305] S709: If the first data amount is not less than the second data amount, generate second information about the second type of combination as second stored data about the second type of combination.

[0306] If the first data amount is not less than the second data amount, second information on the second type of combination is generated as second stored data on the second type of combination.

[0307] S7010: After traversing the last result group in the result group sequence, the first integer, the target number, each first stored data and each second stored data written in the preset storage space are determined as compressed data of the floating point number sequence.

[0308] S7011: Compress the compressed data through Huffman coding to obtain target compressed data.

[0309] Correspondingly, for Figure 7 The data compression method shown is Figure 8 As shown, a data decompression method provided in an embodiment of the present application may include the following steps S801-S8010.

[0310] S801: Decode the data to be decompressed by Huffman decoding to obtain compressed data; read the first a bytes in the compressed data to obtain the first integer in the integer sequence.

[0311] The data to be decompressed is based on Figure 6 The data compression method shown in the figure is used to obtain the target compressed data corresponding to the target compressed data in the above step S7011.

[0312] S802: Continue to read b bytes sequentially to obtain the target number of integers in the integer sequence, and initialize an empty first sequence.

[0313] S803: Determine whether the number of XOR results in the first sequence is less than the difference between the target number and 1.

[0314] If it is less than, execute step S804; if it is not less than, execute step S809.

[0315] S804: Continue to read 1 bit in sequence, and determine whether the data on the bit is 0.

[0316] If it is 0, execute step S805; if it is not 0, execute step S806.

[0317] S805: Continue to read c bits sequentially to obtain the first number of bytes occupied by the first quantity; continue to read the first number of bytes sequentially to obtain the first quantity; write the product of the first quantity and the preset quantity, the XOR result 0, into the first sequence; return to step S803.

[0318] S806: Continue to read 1 bit in sequence, and determine whether the data on the bit is 1.

[0319] If it is 1, execute step S807; if it is not 1, execute step S808.

[0320] S807: Continue to read d bits sequentially to obtain the number of common valid bits; continue to read e bits sequentially to obtain the number of common low-order zeros; continue to read the product of the number of common valid bits and a preset number of bits sequentially to obtain a preset number of common valid bits of XOR results; add a preset number of common low-order zeros after each common valid bit to obtain a preset number of XOR results; write the obtained preset number of XOR results into the first sequence; return to step S803.

[0321] S808: Continue to read f bits sequentially to obtain the number of common high-order 0s; determine whether the number of XOR results obtained in this step is less than the preset number; if less than, continue to read one bit; if the bit is 0, write an XOR result 0 into the first sequence, and return to determine whether the number of XOR results obtained in this step is less than the preset number; if the bit is 1, continue to read the difference between g and the number of common high-order 0s, obtain an XOR result, write the XOR result into the first sequence, and return to determine whether the number of XOR results obtained in this step is less than the preset number; if not less than, return to step S803.

[0322] S809: Initialize an empty second sequence, write the first integer obtained into the second sequence; traverse each XOR result in the first sequence in the order in which each XOR result in the first sequence is written, and when each XOR result is traversed, perform XOR calculation on the XOR result and the integer written most recently in the second sequence to obtain an integer, and write the integer into the second sequence.

[0323] S8010: After traversing the first sequence, each integer in the second sequence is converted into a floating point number according to the IEEE754 standard to obtain decompressed data corresponding to the above-mentioned data to be decompressed.

[0324] In order to verify the data compression performance of the data compression method provided in the embodiment of the present application, a comparative test was conducted on the data compression method provided in the embodiment of the present application and the Gorrila compression method.

[0325] As shown in Figure 9(a), compared with the Gorrila compression method, using Figure 7 The data compression method shown in FIG. 9 can improve the average compression rate of the data set UCR (including 129 real time series floating point data of different scenes) by 22%. As shown in FIG. 9( b), using Figure 7 The data compression method shown in FIG. 9 has a data compression speed similar to that of the Gorrila compression method for the data set UCR. As shown in FIG. 9( c ), compared with the compressed data obtained based on the Gorrila compression method, the compression speed of the data set UCR based on the Gorrila compression method is similar to that of the Gorrila compression method. Figure 7 The compressed data obtained by the data compression method shown can be decompressed faster.

[0326] Corresponding to the data compression method provided in the above-mentioned embodiment of the present application, the embodiment of the present application also provides a data compression device.

[0327] Fig.10 A schematic diagram of the structure of a data compression device provided in an embodiment of the present application is shown in FIG. Fig.10 As shown, the data compression device may include the following modules:

[0328] The data conversion module 1001 is used to convert multiple floating-point numbers in the floating-point number sequence to be compressed into integers respectively, obtain an integer sequence, and write the first integer in the integer sequence into a preset storage space;

[0329] A result calculation module 1002 is used to calculate the XOR result of each integer and the previous integer of the integer starting from the second integer in the integer sequence to obtain a result sequence, and to group the result sequence according to a preset number starting from the first XOR result in the result sequence to obtain a result group sequence;

[0330] The combination determination module 1003 is used to determine the first type of combination and the second type of combination in the result group sequence; wherein the first type of combination is: a plurality of result groups whose XOR results are all 0 and are continuous, or a result group whose XOR results are all 0 and whose adjacent result groups all include XOR results that are not 0; and the second type of combination is: a result group including XOR results that are not 0;

[0331] The data generating module 1004 is used to generate first storage data about the first type of combination according to the number of result groups in each first type of combination, and to generate second storage data about the second type of combination according to the XOR result in each second type of combination;

[0332] A data writing module 1005 is used to write the generated first storage data and the generated second storage data sequentially into the preset storage space, starting from the storage position next to the storage position where the first integer is located in the preset storage space, according to the arrangement order of the result groups in each first type combination and each second type combination in the result group sequence;

[0333] The data determination module 1006 is used to determine the first integer, each first stored data and each second stored data written in the preset storage space as compressed data of the floating-point number sequence.

[0334] Based on this, the data compression method provided by the embodiment of the present application is applied. Since the integer sequence is determined based on the floating-point sequence to be compressed, the result sequence is determined by starting from the second integer in the integer sequence and calculating the XOR result of each integer and the previous integer of the integer. Therefore, if there is no data fluctuation in the floating-point sequence, that is, each floating-point number in the floating-point sequence is the same, then each integer in the integer sequence is the same, and each XOR result in the result sequence is 0. It can be seen that each XOR result in the result sequence can reflect the data fluctuation of the floating-point sequence. Furthermore, for each result group, if the XOR results included in the result group are all 0, it means that there is no data fluctuation in the floating-point number corresponding to each XOR result in the result group; if the result group includes an XOR result that is not 0, it means that there is data fluctuation in the floating-point number corresponding to each XOR result in the result group. Since in the data compression method provided in the embodiment of the present application, the first type of combination is: a plurality of result groups whose XOR results are all 0 and continuous, or a result group whose XOR results are all 0 and whose adjacent result groups all include XOR results that are not 0, and the second type of combination is: a result group including XOR results that are not 0; the first storage data of each first type of combination is generated according to the number of result groups in the first type of combination; the second storage data of each second type of combination is generated according to the XOR results in the second type of combination; therefore, the embodiment of the present application can determine the storage data of each result group according to the data fluctuation of the floating-point numbers corresponding to each XOR result included in each result group in the result group sequence.

[0335] That is to say, in the embodiment of the present application, different data fluctuation situations can correspond to different data compression methods, and since in the embodiment of the present application, lossless compression of floating-point data can be achieved during the compression process of floating-point data, the data compression method provided in the embodiment of the present application can improve the compression rate of lossless compression of floating-point numbers.

[0336] Optionally, in a specific implementation, the combination determination module is specifically used to:

[0337] According to the arrangement order of each result group in the result group sequence, each result group is traversed in turn, and when each result group is traversed, it is determined whether each XOR result included in the result group is 0;

[0338] If yes, traverse the next result group until there is an XOR result that is not 0 in the traversed result group, and determine the traversed result group that is not divided into any combination and all the XOR results are 0 as the first combination;

[0339] If not, the result group is determined as a second type of combination;

[0340] Optionally, in a specific implementation, the data generation module includes:

[0341] A first generating submodule is used to generate storage data including preset first identification information, a first byte number and a first number of result groups in the first type of combination when each first type of combination is determined to be obtained, as first storage data about the first type of combination; wherein the first byte number is used to represent the number of bytes occupied by the first number when the first number is stored;

[0342] A second generating submodule is used for generating second storage data about each second type combination according to the distribution of 0 in each XOR result in the second type combination when it is determined that each second type combination is obtained;

[0343] Optionally, in a specific implementation, the second generating submodule is specifically used to:

[0344] generating, according to the distribution of 0 in each XOR result in the second type of combination, the first information or the second information about the second type of combination as the second stored data about the second type of combination;

[0345] The first information includes: preset second identification information, the number of public valid bits, the number of public low-order 0 bits and valid bit information; the second information includes: preset third identification information, the number of public high-order 0 bits and data information;

[0346] The number of common low-order 0s is used to represent: the minimum number of bits or the minimum number of complete bytes occupied by the low-order 0s of each XOR result in the second type of combination; the low-order 0s of each XOR result are: the 0 before the first non-zero number in the order from the lowest bit to the highest bit;

[0347] The number of common valid bits is used to represent: the maximum number of valid bits in each XOR result in the second type of combination, and the valid bits of each XOR result are: the bits occupied by each XOR result, in the order from the highest bit to the lowest bit, from the first non-zero number to the last non-zero number;

[0348] The number of common high-order 0s is used to represent: the minimum number of bits or the minimum number of complete bytes occupied by the high-order 0s of each XOR result in the second type of combination; the high-order 0s of each XOR result are: the 0 before the first occurrence of a non-zero number in the order from the highest order to the lowest order;

[0349] The valid bit information is: the value of the common valid bit of each XOR result in the second type of combination arranged according to the arrangement information of each XOR result in the second type of combination; the common valid bit of each XOR result is: the bits occupied by each XOR result, in the order from the highest bit to the lowest bit, after removing the common high-order 0 number of bits, and in the order from the lowest bit to the highest bit, removing the common low-order 0 number of bits, the remaining bits;

[0350] The data information includes: target information of each XOR result in the second type of combination arranged according to the arrangement information of each XOR result in the second type of combination; for each XOR result in the second type of combination, if the XOR result is 0, the target information of the XOR result is a first value, and if the XOR result is not 0, the target information of the XOR result includes: a second value, and the value of the remaining bits in the XOR result after removing the number of bits of the common high-order 0 in the XOR result in order from the highest bit to the lowest bit;

[0351] Optionally, in a specific implementation, the second generating submodule is specifically used to:

[0352] If the number of XOR results of 0 included in the second type of combination is less than the specified number, generating first information about the second type of combination as second storage data about the second type of combination;

[0353] If the number of XOR results of 0 included in the second type of combination is not less than the specified number, generating second information about the second type of combination as second storage data about the second type of combination;

[0354] or,

[0355] determining a first data amount of the first information about the second type of combination and a second data amount of the second information about the second type of combination;

[0356] If the first data amount is smaller than the second data amount, generating first information about the second type of combination as second stored data about the second type of combination;

[0357] If the first data amount is not less than the second data amount, generating second information about the second type of combination as second stored data about the second type of combination;

[0358] Optionally, in a specific implementation, the data writing module is specifically used to:

[0359] Starting from a storage position next to the storage position where the first integer is located in the preset storage space, after each first storage data or second storage data is generated, sequentially write the first storage data or the second storage data into the preset storage space;

[0360] Optionally, in a specific implementation, the data conversion module is specifically used to:

[0361] In a preset storage space, sequentially write the first integer in the integer sequence and the target number of integers in the integer sequence;

[0362] The data writing module is specifically used for:

[0363] Starting from the storage position next to the storage position where the target number is located in the preset storage space, the generated first storage data and the generated second storage data are sequentially written into the preset storage space according to the arrangement order of the result groups in each first type combination and each second type combination in the result group sequence;

[0364] The data determination module is specifically used for:

[0365] Determine the first integer, the target number, each first stored data and each second stored data written in the preset storage space as compressed data of the floating-point number sequence;

[0366] Optionally, in a specific implementation, the device further includes:

[0367] A floating point number adding module, used for adding a preset floating point number after the last floating point number sequence in the floating point number sequence to be compressed; wherein the preset floating point number is different from each floating point number in the floating point number sequence to be compressed;

[0368] The data conversion module is specifically used for:

[0369] Convert multiple floating-point numbers in the floating-point number sequence to which the preset floating-point number is added into integers respectively to obtain an integer sequence;

[0370] Optionally, in a specific implementation, the device further includes:

[0371] The data compression module is used to compress the compressed data using a preset compression method to obtain target compressed data.

[0372] Optionally, in a specific implementation, the floating-point number sequence is: a multimedia data sequence; the multimedia data includes: at least one of: video data, audio data and image data.

[0373] Corresponding to the data decompression method provided in the above embodiment of the present application, the embodiment of the present application also provides a data decompression device, such as Fig.11 As shown, the data decompression device may include the following modules:

[0374] The decompressed data acquisition module 1101 is used to acquire the data to be decompressed and read the first integer in the data to be decompressed; wherein the data to be decompressed is obtained by any of the above-mentioned data compression methods;

[0375] A data reading module 1102, configured to read each stored data in the data to be decompressed in sequence according to the arrangement order of each stored data in the data to be decompressed;

[0376] The data analysis module 1103 is used to analyze each stored data according to the data content of the stored data when reading the stored data, and obtain the XOR result corresponding to the stored data;

[0377] An XOR calculation module 1104 is used to perform an XOR calculation on each XOR result and the last integer obtained in the order in which the XOR results are obtained, to obtain a target integer corresponding to the XOR result;

[0378] The floating point number conversion module 1105 is used to convert each obtained integer into a floating point number, and write each floating point number corresponding to each integer into a floating point number sequence according to the order in which the integers are obtained, so as to obtain the decompressed data corresponding to the data to be decompressed.

[0379] The present application also provides an electronic device, such as Fig.12 As shown, including:

[0380] Memory 1201, used for storing computer programs;

[0381] The processor 1202 is used to implement the steps of any data compression method provided in the embodiments of the present application and / or the steps of any data decompression method provided in the embodiments of the present application when executing the program stored in the memory 1201.

[0382] Furthermore, the electronic device may further include a communication bus and / or a communication interface, and the processor 1202, the communication interface, and the memory 1201 communicate with each other via the communication bus.

[0383] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0384] The communication interface is used for communication between the above electronic device and other devices.

[0385] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0386] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0387] In another embodiment provided in the present application, a computer-readable storage medium is also provided, which stores a computer program. When the computer program is executed by a processor, the steps of any data compression method provided in the embodiments of the present application and / or the steps of any data decompression method provided in the embodiments of the present application are implemented.

[0388] In another embodiment provided in the present application, a computer program product comprising instructions is also provided, which, when executed on a computer, enables the computer to execute any data compression method provided in the embodiments of the present application and / or any data decompression method provided in the embodiments of the present application.

[0389] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a solid-state hard disk (SSD), etc.

[0390] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0391] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, electronic device embodiment, computer-readable storage medium embodiment, and computer program product embodiment, since they are basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0392] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims

1. A data compression method, characterized in that: The method comprises: Converting multiple floating-point numbers in the floating-point number sequence to be compressed into integers respectively to obtain an integer sequence, and writing the first integer in the integer sequence into a preset storage space; Starting from the second integer in the integer sequence, calculating the XOR result of each integer and the integer before the integer to obtain a result sequence, and starting from the first XOR result in the result sequence, grouping the result sequence according to a preset number to obtain a result group sequence; Determine a first type of combination and a second type of combination in the result group sequence; wherein the first type of combination is: a plurality of result groups whose XOR results are all 0 and are continuous, or a result group whose XOR results are all 0 and whose adjacent result groups all include XOR results that are not 0, and the second type of combination is: a result group including an XOR result that is not 0; Generate first storage data about the first type of combination according to the number of result groups in each first type of combination, and generate second storage data about the second type of combination according to the XOR result in each second type of combination; Starting from the storage position next to the storage position where the first integer is located in the preset storage space, the generated first storage data and the generated second storage data are sequentially written into the preset storage space according to the arrangement order of the result groups in each first type combination and each second type combination in the result group sequence; The first integer, each first stored data and each second stored data written in the preset storage space are determined as compressed data of the floating-point number sequence.

2. The method according to claim 1, characterized in that Determining the first type of combination and the second type of combination in the result group sequence comprises: According to the arrangement order of each result group in the result group sequence, each result group is traversed in turn, and when each result group is traversed, it is determined whether each XOR result included in the result group is 0; If yes, then traverse the next result group until there is an XOR result that is not 0 in the traversed result group, and determine the traversed result group that is not classified into any combination and all the XOR results are 0 as the first type of combination; If not, the result group is determined as a second type of combination.

3. The method according to claim 2, characterized in that The step of generating first storage data about the first type of combination according to the number of result groups in each first type of combination, and generating second storage data about the second type of combination according to the XOR result in each second type of combination, comprises: When each first-category combination is determined to be obtained, storage data including preset first identification information, a first byte number, and a first number of result groups in the first-category combination is generated as first storage data about the first-category combination; wherein the first byte number is used to represent the number of bytes occupied by the first number when the first number is stored; When each second type combination is determined to be obtained, second storage data on the second type combination is generated according to the distribution of 0 in each XOR result in the second type combination.

4. The method according to claim 3, characterized in that The step of generating second storage data about the second type of combination according to the distribution of 0 in each XOR result in the second type of combination comprises: generating, according to the distribution of 0 in each XOR result in the second type of combination, the first information or the second information about the second type of combination as the second stored data about the second type of combination; The first information includes: preset second identification information, the number of public valid bits, the number of public low-order 0 bits and valid bit information; the second information includes: preset third identification information, the number of public high-order 0 bits and data information; The number of common low-order 0s is used to represent: the minimum number of bits or the minimum number of complete bytes occupied by the low-order 0s of each XOR result in the second type of combination; the low-order 0s of each XOR result are: the 0 before the first non-zero number in the order from the lowest bit to the highest bit; The number of common valid bits is used to represent: the maximum number of valid bits in each XOR result in the second type of combination, and the valid bits of each XOR result are: the bits occupied by each XOR result, in the order from the highest bit to the lowest bit, from the first non-zero number to the last non-zero number; The number of common high-order 0s is used to represent: the minimum number of bits or the minimum number of complete bytes occupied by the high-order 0s of each XOR result in the second type of combination; the high-order 0s of each XOR result are: the 0 before the first occurrence of a non-zero number in the order from the highest order to the lowest order; The valid bit information is: the value of the common valid bit of each XOR result in the second type of combination arranged according to the arrangement information of each XOR result in the second type of combination; the common valid bit of each XOR result is: the bits occupied by each XOR result, in the order from the highest bit to the lowest bit, after removing the common high-order 0 number of bits, and in the order from the lowest bit to the highest bit, removing the common low-order 0 number of bits, the remaining bits; The data information includes: target information of each XOR result in the second type of combination arranged according to the arrangement information of each XOR result in the second type of combination; for each XOR result in the second type of combination, if the XOR result is 0, then the target information of the XOR result is a first value, if the XOR result is not 0, then the target information of the XOR result includes: a second value, and the value of the remaining bits in the XOR result after removing the common high-order 0 bits in the XOR result in order from the highest bit to the lowest bit.

5. The method according to claim 4, characterized in that The generating the first information or the second information about the second type of combination as the second stored data about the second type of combination comprises: If the number of XOR results of 0 included in the second type of combination is less than the specified number, generating first information about the second type of combination as second storage data about the second type of combination; If the number of XOR results of 0 included in the second type of combination is not less than the specified number, generating second information about the second type of combination as second storage data about the second type of combination; or, determining a first data amount of the first information about the second type of combination and a second data amount of the second information about the second type of combination; If the first data amount is smaller than the second data amount, generating first information about the second type of combination as second stored data about the second type of combination; If the first data amount is not less than the second data amount, second information about the second type of combination is generated as second stored data about the second type of combination.

6. The method according to claim 3, characterized in that The step of sequentially writing each first storage data and each second storage data generated into the preset storage space starting from the storage position next to the storage position where the first integer is located in the preset storage space according to the arrangement order of the result groups in each first type combination and each second type combination in the result group sequence includes: Starting from the storage position next to the storage position where the first integer is located in the preset storage space, after each first storage data or second storage data is generated, the first storage data or the second storage data is sequentially written into the preset storage space.

7. The method according to any one of claims 1 to 6, characterized in that: Writing the first integer in the integer sequence into the preset storage space includes: In a preset storage space, sequentially write the first integer in the integer sequence and the target number of integers in the integer sequence; The step of sequentially writing each first storage data and each second storage data generated into the preset storage space starting from the storage position next to the storage position where the first integer is located in the preset storage space according to the arrangement order of the result groups in each first type combination and each second type combination in the result group sequence includes: Starting from the storage position next to the storage position where the target number is located in the preset storage space, the generated first storage data and the generated second storage data are sequentially written into the preset storage space according to the arrangement order of the result groups in each first type combination and each second type combination in the result group sequence; The step of determining the first integer, each first stored data, and each second stored data written in the preset storage space as compressed data of the floating-point number sequence includes: The first integer, the target number, each first stored data and each second stored data written in the preset storage space are determined as compressed data of the floating point number sequence.

8. The method according to any one of claims 1 to 6, characterized in that: Before converting the plurality of floating-point numbers in the floating-point number sequence to be compressed into integers respectively to obtain the integer sequence, the method further comprises: After the last floating point number sequence in the floating point number sequence to be compressed, adding a preset floating point number; wherein the preset floating point number is different from each floating point number in the floating point number sequence to be compressed; The step of converting multiple floating-point numbers in the floating-point number sequence to be compressed into integers respectively to obtain an integer sequence includes: A plurality of floating-point numbers in a floating-point number sequence to which a preset floating-point number is added are respectively converted into integers to obtain an integer sequence.

9. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: The compressed data of the floating point number sequence is compressed using a preset compression method to obtain target compressed data.

10. The method according to any one of claims 1 to 6, characterized in that: The floating point number sequence is a multimedia data sequence; the multimedia data includes at least one of video data, audio data and image data.

11. A data decompression method, characterized in that: The method comprises: Obtaining data to be decompressed, and reading a first integer in the data to be decompressed; wherein the data to be decompressed is obtained by the data compression method according to any one of claims 1 to 10; Reading each stored data in the data to be decompressed in sequence according to the arrangement order of each stored data in the data to be decompressed; When each stored data is read, the stored data is parsed according to the data content of the stored data to obtain the XOR result corresponding to the stored data; According to the order in which the XOR results are obtained, each XOR result is XORed with the last integer obtained to obtain the target integer corresponding to the XOR result; The obtained integers are converted into floating-point numbers, and the floating-point numbers corresponding to the integers are written into a floating-point number sequence in the order in which the integers are obtained, so as to obtain decompressed data corresponding to the data to be decompressed.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in any one of claims 1 to 10 and / or the method described in claim 11 is implemented.

Citation Information

Patent Citations

  • Convolutional neural network compression method and face detection method

    CN108960340A

  • Data compression method and device, computer readable storage medium and electronic equipment

    CN112527752A

  • Simple encoding and decoding method suitable for time sequence database

    CN113078908A

  • Data compression algorithm based on XOR exponentiation and modulo operation

    CN115765751A

  • Lossless compression and decompression method for high-precision floating point type time series data

    CN116089385A