A data adaptive storage method, device, electronic device and storage medium

By classifying data types and selecting the best compression algorithm based on statistical information, the data is adaptively compressed and decompressed, which solves the problem of low decompression efficiency in the data lake environment in the existing technology and improves the data compression rate and storage performance.

CN117786169BActive Publication Date: 2024-08-30BEIJING DIGITAL TRANSFORMATION TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202410211041.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-26
Publication Date
2024-08-30
Estimated Expiration
2044-02-26

AI Technical Summary

Technical Problem

Existing open storage formats such as Apache Parquet and Apache ORC do not decompress efficiently in remote data lakes and high-throughput network environments, resulting in increased query times and costs.

Method used

By dividing the data types, determine the compression algorithm list for different data types, obtain the target data and select the best compression method based on its statistical information, compress and decompress the data, and use header information to optimize the decompression process.

Benefits of technology

The compression rate of data is improved, storage space requirements are reduced, storage costs are saved, and access time is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117786169B
    Figure CN117786169B
Patent Text Reader

Abstract

The present invention discloses a data adaptive storage method, device, electronic device and storage medium. The method comprises: dividing the data types, determining the compression algorithm list corresponding to data of different data types; acquiring target data, determining the target compression algorithm list corresponding to the target data; selecting the best compression method corresponding to the target data from the target compression algorithm list based on the statistical information of the target data; compressing the target data using the best compression method to obtain compressed data; writing header information at the head of the compressed data to decompress the data based on the header information. The method optimizes the compression storage of data by sampling and analyzing the data, and adaptively selecting the best compression algorithm according to the type of the data, which can improve the data reading performance while ensuring the data compression ratio.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the technical field of database management, and in particular to a data adaptive storage method, device, electronic device and storage medium. Background Art

[0002] With the rise of cloud computing and data lake technology, data storage and analysis are gradually moving from traditional databases to cloud platforms, such as Amazon S3 and other Blob storage services. These services support seamless data sharing and system interoperability.

[0003] Existing open storage formats, such as Apache Parquet and Apache ORC, are not optimized for remote data lakes and high-throughput network environments, resulting in poor decompression efficiency, which increases query time and cost.

[0004] Therefore, how to adaptively compress storage formats is a problem that needs to be solved urgently. Summary of the invention

[0005] The present invention provides a data adaptive storage method, device, electronic device and storage medium to solve the problem of low data compression and decompression efficiency faced by the prior art in cloud infrastructure and data lake environments.

[0006] According to one aspect of the present invention, there is provided a data adaptive storage method, comprising:

[0007] Classify the data types and determine the compression algorithm list corresponding to the data of different data types;

[0008] Acquire target data, and determine a target compression algorithm list corresponding to the target data;

[0009] Selecting the best compression method corresponding to the target data from the target compression algorithm list based on the statistical information of the target data;

[0010] Using the optimal compression method to compress the target data to obtain compressed data;

[0011] Header information is written into the head of the compressed data so as to decompress the data based on the header information.

[0012] According to another aspect of the present invention, there is provided a data adaptive storage device, comprising:

[0013] A division module is used to divide the data types and determine the compression algorithm list corresponding to the data of different data types;

[0014] A determination module, used to obtain target data and determine a target compression algorithm list corresponding to the target data;

[0015] A selection module, configured to select an optimal compression method corresponding to the target data from the target compression algorithm list based on the statistical information of the target data;

[0016] A compression module, used for compressing the target data using the optimal compression method to obtain compressed data;

[0017] The decompression module is used to write header information into the header of the compressed data to decompress the data based on the header information.

[0018] According to another aspect of the present invention, there is provided an electronic device, the electronic device comprising:

[0019] at least one processor;

[0020] and a memory communicatively coupled to the at least one processor;

[0021] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the data adaptive storage method described in any embodiment of the present invention.

[0022] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the data adaptive storage method described in any embodiment of the present invention when executed.

[0023] The technical solution of the embodiment of the present invention divides the data types to determine a list of compression algorithms corresponding to data of different data types; obtains target data and determines a list of target compression algorithms corresponding to the target data; selects the best compression method corresponding to the target data from the list of target compression algorithms based on statistical information of the target data; compresses the target data using the best compression method to obtain compressed data; writes header information into the header of the compressed data to decompress the data based on the header information, thereby solving the problem of low data compression and decompression efficiency faced by the prior art in cloud infrastructure and data lake environments, and achieves the beneficial effect of improving the compression rate of data, thereby reducing storage space, saving storage costs, and reducing access time.

[0024] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0026] Figure 1 A schematic diagram of a flow chart of a data adaptive storage method provided in Embodiment 1 of the present invention;

[0027] Figure 2 A schematic diagram of a compression algorithm list provided by an embodiment of the present invention;

[0028] Figure 3 A schematic diagram of a flow chart of a data adaptive storage method provided in Embodiment 2 of the present invention;

[0029] Figure 4 A schematic diagram of a data writing process in a data adaptive storage method provided by an exemplary embodiment of the present invention;

[0030] Figure 5 A schematic diagram of a data reading process in a data adaptive storage method provided by an exemplary embodiment of the present invention;

[0031] Figure 6 A schematic diagram of the structure of a data adaptive storage device provided in Embodiment 3 of the present invention;

[0032] Figure 7 A schematic diagram of the structure of an electronic device for a data adaptive storage method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0033] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is only an embodiment of a part of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work should belong to the scope of protection of the present invention. It should be understood that the various steps recorded in the method implementation of the present invention can be performed in different orders and / or in parallel. In addition, the method implementation may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.

[0034] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0035] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0036] It should be noted that the modifications of "one" and "plurality" mentioned in the present invention are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0037] The names of the messages or information exchanged between multiple devices in the embodiments of the present invention are only used for illustrative purposes, and are not used to limit the scope of these messages or information.

[0038] Embodiment 1

[0039] Figure 1 The present invention provides a flowchart of a data adaptive storage method provided in the first embodiment of the present invention. The method can be applied to data compression and decompression, and is particularly applicable to the adaptive storage of column-based databases in online analytical processing scenarios. The method can be executed by a data adaptive storage device, wherein the device can be implemented by software and / or hardware and is generally integrated on an electronic device. In this embodiment, the electronic device includes but is not limited to: a computer device.

[0040] like Figure 1 As shown, a data adaptive storage method provided by Embodiment 1 of the present invention includes the following steps:

[0041] S110: Classify the data types and determine a list of compression algorithms corresponding to data of different data types.

[0042] Among them, the data can include multiple, in the database, common data types can be roughly divided into two types: numeric type and string type.

[0043] In this embodiment, for numerical data, the encoding methods applicable to numerical data can be integrated to form its corresponding compression algorithm list; for string data, the encoding methods applicable to string data can be integrated to form its corresponding compression algorithm list.

[0044] Exemplarily, the list of compression algorithms corresponding to numerical data may include Dict encoding, OneValue encoding, and Frequency encoding, etc.; the list of compression algorithms corresponding to string data may include FSST encoding, Dict encoding, and OneValue encoding, etc.

[0045] S120: Acquire target data, and determine a target compression algorithm list corresponding to the target data.

[0046] The target data may be understood as data to be compressed, and the length of the target data is not specifically limited here.

[0047] In this embodiment, the target data may be acquired in a variety of ways, such as directly from a database or from other devices, which are not specifically limited here.

[0048] In this embodiment, after the target data is obtained, a compression algorithm list corresponding to the target data can be directly obtained from the compression algorithm lists corresponding to data of different data types according to the type of the target data as the target compression algorithm list. The target compression algorithm list can be understood as a compression algorithm list corresponding to the target data.

[0049] S130. Selecting the best compression method corresponding to the target data from the target compression algorithm list based on the statistical information of the target data.

[0050] In this embodiment, statistical information can be obtained after analyzing and counting the target data, and the maximum and minimum values ​​in the target data, the number of null values ​​in the target data, and the number of unique values ​​can be counted.

[0051] In this embodiment, the interface of the estimation function can be directly called. The compression rate corresponding to the target data can be estimated based on the statistical information of the target data using the estimation function. According to the compression rate, the corresponding compression method is selected from the target compression algorithm list as the most optimal compression method.

[0052] In this embodiment, if the target data is too large, the target data can be sampled to obtain data segments, and then the compression ratios corresponding to different data segments in the target data can be estimated using an estimation function based on the statistical information of the target data. The higher the compression ratio, the better the compression effect. Then, the compression method corresponding to the maximum compression ratio can be selected from the target compression algorithm list as the best compression method. It should be noted that the compression ratios corresponding to different compression methods are known.

[0053] Among them, the estimation function can use Estimate, which refers to a rule. This rule can be used to estimate the value of the variable of interest from the measured data (estimator). It can be said that Estimate is a function, the input of the function is the measured data, and the output is the estimated value.

[0054] S140: compress the target data using the optimal compression method to obtain compressed data.

[0055] It can be understood that if the best compression method is FSST encoding, FSST encoding is used to compress the target data, and the specific compression process is not repeated; if the best compression method is Dict encoding, Dict encoding is used to compress the target data, and the specific compression process is not repeated.

[0056] S150: Write header information into the header of the compressed data to decompress the data based on the header information.

[0057] The header information may be metadata Header, and the header information may record a compression method used for data compression, that is, an optimal compression method.

[0058] Exemplarily, the header information may be a 9-byte metadata Header, and the 9 bytes may include 4 bytes occupied by the data before compression, 4 bytes occupied by the data after compression, and 1 byte occupied by the compression method.

[0059] In this embodiment, after data compression is completed, the number of bytes occupied by the compressed data can be known, and then the header information can be written into the header of the compressed data. Finally, the compressed data with the header information is written to complete the compression process.

[0060] In this embodiment, decompressing the data based on the header information may include: decompressing the data according to the compression method recorded in the header information. Decompression is the inverse process of compression, which will not be elaborated here.

[0061] A data adaptive storage method provided in a first embodiment of the present invention first divides the data types to determine the compression algorithm list corresponding to data of different data types; secondly, obtains the target data and determines the target compression algorithm list corresponding to the target data; then, based on the statistical information of the target data, selects the best compression method corresponding to the target data from the target compression algorithm list; then, uses the best compression method to compress the target data to obtain compressed data; finally, writes header information at the head of the compressed data to decompress the data based on the header information. The above method optimizes the compression storage of data by sampling and analyzing the data and adaptively selecting the best compression algorithm according to the type of data, which can improve data reading performance while ensuring the data compression ratio.

[0062] Based on the above embodiment, a variant embodiment of the above embodiment is proposed. It should be noted that in order to make the description concise, only the differences from the above embodiment are described in the variant embodiment.

[0063] In one embodiment, the data types are divided to determine the compression algorithm list corresponding to data of different data types, including: dividing the data into numerical data and string data; integrating Dict encoding, OneValue encoding, Frequency encoding, FastPFOR encoding, RLE encoding and general encoding in the compression algorithm list corresponding to the numerical data; integrating FSST encoding, Dict encoding, OneValue encoding and general encoding in the compression algorithm list corresponding to the string data.

[0064] Among them, FSST encoding is a compression algorithm designed specifically for string data. Its main purpose is to improve the decompression speed without sacrificing too much compression ratio, especially when processing large text data. FSST encoding can quickly convert common string patterns into shorter fixed-length codes. The basic idea of ​​FSST encoding is to pre-analyze text data, identify frequently occurring substring patterns, and then replace these patterns with shorter unique identifiers. These identifiers are stored in a data structure called a symbol table, and each identifier corresponds to a specific substring pattern. During the compression process, each substring pattern that appears in the original text is replaced by its corresponding identifier, thereby reducing the total size of the data. When decompressing, the algorithm looks up these identifiers and replaces them back to the original substring patterns using the information stored in the symbol table, thereby restoring the original text.

[0065] Dict encoding: Numeric dictionary encoding replaces distinct values ​​in the input with shorter codes. A lookup structure (dictionary) maps each code to the original distinct value.

[0066] OneValue encoding: When the data in a block has only one unique value, it only needs to be encoded into that value, which can be regarded as an extreme case of dictionary encoding.

[0067] Frequency encoding: Used to handle situations where the data distribution is skewed, where some values ​​are more common than others. For example, a one-bit code can represent the two most common values, and a three-bit code can represent the next eight most common values.

[0068] FastPFOR encoding: A high-performance implementation based on SIMD for compression of integer data.

[0069] RLE encoding: used to compress sequences of consecutive identical values. For example, the sequence {42, 42, 42} can be stored as (42, 3).

[0070] Common encodings may include Zstd encoding, Lz4 encoding, and Snappy encoding. These encoding algorithms divide the binary format of data into multiple small blocks and then compress the small blocks one by one.

[0071] Figure 2 A schematic diagram of a compression algorithm list provided in an embodiment of the present invention is shown in FIG. Figure 2 As shown, the list of compression algorithms corresponding to string type data includes FSST encoding, Dict encoding, OneValue encoding, Zstd encoding, Lz4 encoding and Snappy encoding; the list of compression algorithms corresponding to numeric type data includes Frequency encoding, Dict encoding, OneValue encoding, RLE encoding, Zstd encoding, Lz4 encoding, Snappy encoding and FastPFOR encoding.

[0072] In one embodiment, the statistical information of the target data includes at least the following:

[0073] Maximum value; minimum value; number of null values; number of unique values.

[0074] Among them, the maximum value can be understood as the number of bytes occupied by the largest data segment in the target data; the minimum value can be understood as the number of bytes occupied by the smallest data segment in the target data; the number of null values ​​can be understood as the number of times the null value appears in the target data; the number of unique values ​​can be understood as the number of data that appears only once in the target data.

[0075] Embodiment 2

[0076] Figure 3This is a flow chart of a data adaptive storage method provided by the second embodiment of the present invention. The second embodiment is optimized on the basis of the above embodiments. For details not yet provided in this embodiment, please refer to the first embodiment.

[0077] like Figure 3 As shown, a data adaptive storage method provided by Embodiment 2 of the present invention includes the following steps:

[0078] S210: Classify the data types and determine a list of compression algorithms corresponding to data of different data types.

[0079] S220: Acquire target data, and determine a target compression algorithm list corresponding to the target data.

[0080] S230: Randomly sample the target data to obtain sampled target data.

[0081] In this embodiment, since the target data may be too large, directly applying the compression algorithm will generate additional CPU load, so the compression rate of the sampled target data may be calculated after randomly sampling the target data.

[0082] The sampled target data may be understood as a data segment in the target data.

[0083] S240, calling an interface of an estimation function, and estimating multiple compression rates corresponding to the sampled target data through an estimation function based on statistical information of the target data.

[0084] Among them, one sampled target data corresponds to one compression rate.

[0085] S250: Select an optimal compression method from the compression algorithm list based on the multiple compression rates.

[0086] Specifically, determining the best compression method based on the multiple compression ratios includes: sorting the multiple compression ratios in descending order; and selecting the compression method corresponding to the compression ratio ranked first from the compression algorithm list as the best compression method.

[0087] S260: compress the target data using the optimal compression method to obtain compressed data.

[0088] S270. Write header information into the header of the compressed data to decompress the data based on the header information.

[0089] Specifically, the optimal compression method is obtained from the header information; and a single instruction multiple data (SIMD) stream is called to decompress data using the optimal compression method.

[0090] Among them, the use of SIMD instructions can greatly improve the decompression performance.

[0091] Furthermore, if the encoding method is run-length encoding, then during the data decompression process, the SIMD instruction uses the AVX2 algorithm to perform parallel processing on the data.

[0092] Among them, Run-Length Encoding (RLE) is a method used for data compression, especially in the fields of images and audio. It reduces the required storage space by finding and replacing consecutive repeated data items. Specifically, RLE encodes consecutive data items according to their number of occurrences and uses a shorter codeword to represent this series of repeated data items. This can greatly reduce the amount of data while maintaining data integrity and lossless compression characteristics.

[0093] It should be noted that the AVX2 algorithm is an implementation of SIMD instructions, including instructions such as _mm256_set1_epi32 and _mm256_storeu_si256. In this embodiment, the AVX2 algorithm is used for acceleration for RLE encoding, because in the AVX register, we can use instructions such as _mm256_set1_epi32 and _mm256_storeu_si256 to perform batch access calculations on data.

[0094] It can be understood that, through SIMD instructions, for 32-bit integer data, the function can process 8 data at a time, which is much faster than processing the data one by one, because it reduces the number of processor instructions and improves the parallelism of data processing.

[0095] The second embodiment of the present invention provides a data adaptive storage method, which specifies the step of selecting the best compression method. By selecting the best compression method, the method can improve the data compression rate, reduce storage space, save storage costs, and reduce access delay.

[0096] The embodiments of the present invention provide several specific implementation methods based on the technical solutions of the above embodiments.

[0097] As a specific implementation method of this embodiment, Figure 4 A schematic diagram of a data writing process in a data adaptive storage method provided by an exemplary embodiment of the present invention is shown in FIG. Figure 4 As shown, the specific process includes the following:

[0098] Divide data types into Numeric and String; traverse all available compression methods for different types of data to build a list of compression algorithms corresponding to that type of data; perform statistics on the data and randomly sample it; perform compression estimation algorithm; sort according to the compression estimation rate and select the best compression method; compress the data; and write data header metadata.

[0099] Figure 5 A data reading flow diagram in a data adaptive storage method provided by an exemplary embodiment of the present invention is shown in FIG. Figure 5 As shown, the specific process includes the following:

[0100] For Numeric data and String data, the corresponding compression method is read from the data header to decompress the data, and SIMD instructions are used in the decompression process.

[0101] The code for selecting the best compression method for numerical data is as follows:

[0102] fn choose _compressor<T:IntergerType> (

[0103] _value: &PrimitiveArray <t>,

[0104] stats:&IntergerStats <t>,

[0105] write_options:&WriteOptions,

[0106] ) -> IntCompressor <t>{

[0107] let basic = IntCompressor::Basic(write_options.default_compression);

[0108] if let Some(ratio) = write_options.defult_compress_ratio {

[0109] let mut max_ratio = ratio;

[0110] let mut result = basic;

[0111] let compressors: Vec<Box<dyn IntegerCompression <t>>> = get_schemas();

[0112] for c in compressors{

[0113] if write_options

[0114] .forbidden_compressions

[0115] .contains(&c.to_compression())

[0116] {

[0117] continue;

[0118] }

[0119] let r = c.estimate_ratio(stats);

[0120] if r > max_ratio {

[0121] mx_ratio = r;

[0122] result = IntCompressor::Extend(c);

[0123] if r == stats.tuple_count as f64 {

[0124] break;

[0125] }

[0126] }

[0127] }

[0128] result

[0129] } else {

[0130] basic

[0131] }

[0132] }

[0133] Among them, the estimation function estimate_ratio of the Dict encoding is implemented as follows:

[0134] fn estimate_ratio(&self, stats: &super::IntergerStats <t>) -> f64 {

[0135] const MIN_DICT_RATIO: usize = 3;

[0136] if stats.unique_count * MIN_DICT_RATIO >= stats.tuple_count {

[0137] return 0.0f64;

[0138] }

[0139] let mut after_size: usize = stats.unique_count * std::mem::size_of:: <t>()

[0140] + stats.tuple_count * (get_bits_needed(input:stats.unique_count as u64) / 8) as usize;

[0141] / / afte_size += std::mem::size_of:: <dynamictionarystructure>() +5;

[0142] after_size += (stats.tuple_count) * 2 / 128;

[0143] stats.total_bytes as f64 / after_size as f64

[0144] The estimation function estimate_ratio of OneValue encoding is implemented as follows:

[0145] fn estimate_ratio(&self, stats: &IntegerStats <t>) -> f64 {

[0146] if stats.unique_count <=1 {

[0147] stats.tuple_count as f64

[0148] } else {

[0149] 0.0f64

[0150] }

[0151] }

[0152] The code to use AVX instructions to accelerate RLE decoding efficiency is as follows:

[0153] pub unsafe fn decode_rle_avx(dst: &mut [i32], runlen: &[i32], values:&[i32], runcnt: usize){

[0154] let mut dst_index = 0;

[0155] for run in 0..runcnt {

[0156] let target_index = dst_index + runlen[run] as usize;

[0157] let vals = _mm256_set1_epi32(values[run]);

[0158] while dst_index < target_index {

[0159] _mm256_storeu_si256(dst[dst_index..].sa_mut_ptr() as *mut__m256i, vals);

[0160] dst_index += 8;

[0161] }

[0162] }

[0163] }

[0164] Embodiment 3

[0165] Figure 6 A structural schematic diagram of a data adaptive storage device provided in Embodiment 3 of the present invention, the device can be applicable to data compression and decompression, and is particularly suitable for adaptive storage of columnar databases in online analytical processing scenarios, wherein the device can be implemented by software and / or hardware and is generally integrated on an electronic device.

[0166] like Figure 6 As shown, the device includes: a division module 110, a determination module 120, a selection module 130, a compression module 140 and a decompression module 150.

[0167] A division module 110, for dividing the data into different types and determining a list of compression algorithms corresponding to data of different data types;

[0168] A determination module 120, configured to obtain target data and determine a target compression algorithm list corresponding to the target data;

[0169] A selection module 130, configured to select an optimal compression method corresponding to the target data from the target compression algorithm list based on the statistical information of the target data;

[0170] A compression module 140, configured to compress the target data using the optimal compression method to obtain compressed data;

[0171] The decompression module 150 is used to write header information into the header of the compressed data to decompress the data based on the header information.

[0172] In this embodiment, the device first divides the data type through the division module 110 to determine the compression algorithm list corresponding to data of different data types; secondly, the target data is obtained through the determination module 120 to determine the target compression algorithm list corresponding to the target data; then, the selection module 130 selects the best compression method corresponding to the target data from the target compression algorithm list based on the statistical information of the target data; then, the compression module 140 uses the best compression method to compress the target data to obtain compressed data; finally, the decompression module 150 writes header information into the header of the compressed data to decompress the data based on the header information.

[0173] This embodiment provides a data adaptive storage device, which can improve data reading performance while ensuring the data compression ratio.

[0174] Furthermore, the division module 110 includes:

[0175] A division unit is used to divide data into numerical data and string data;

[0176] The first integration unit is used to integrate Dict encoding, OneValue encoding, Frequency encoding, FastPFOR encoding, RLE encoding and general encoding in the compression algorithm list corresponding to numerical data;

[0177] The second integration unit is used to integrate FSST encoding, Dict encoding, OneValue encoding and general encoding in the compression algorithm list corresponding to string data.

[0178] Furthermore, the statistical information of the target data includes at least the following:

[0179] Maximum value; minimum value; number of null values; number of unique values.

[0180] Furthermore, the selection module 130 includes:

[0181] A sampling unit, used for randomly sampling the target data to obtain sampling target data;

[0182] An estimation unit, used to call an interface of an estimation function, and estimate multiple compression rates corresponding to the sampled target data through an estimation function based on statistical information of the target data;

[0183] A selection unit is used to select an optimal compression method from the compression algorithm list based on the multiple compression rates.

[0184] Based on the above optimization, the selection unit is specifically used to: sort the multiple compression rates in descending order; and select the compression method corresponding to the compression rate ranked first from the compression algorithm list as the best compression method.

[0185] Furthermore, the decompression module 150 is used to: obtain the optimal compression method from the header information; and call the single instruction multiple data stream SIMD to decompress the data using the optimal compression method.

[0186] Based on the above technical solution, if the encoding method is run-length encoding, then in the data decompression process, the SIMD instruction uses the AVX2 algorithm to process the data in parallel.

[0187] The above-mentioned data adaptive storage device can execute the data adaptive storage method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0188] Embodiment 4

[0189] Figure 7 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0190] like Figure 7 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.

[0191] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0192] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as a data adaptive storage method.

[0193] In some embodiments, the data adaptive storage method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps in the data adaptive storage method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the data adaptive storage method in any other appropriate manner (e.g., by means of firmware).

[0194] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0195] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0196] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0197] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0198] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0199] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0200] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0201] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.< / t> < / dynamictionarystructure> < / t> < / t> < / t> < / t> < / t> < / t>

Claims

1. A data adaptive storage method, characterized in that: A column-based database is applied in an online analytical processing scenario, and the method includes: Classify the data types and determine a compression algorithm list corresponding to data of different data types, wherein the compression algorithm list includes multiple different types of compression methods; Acquire target data, and determine a target compression algorithm list corresponding to the target data; Based on the statistical information of the target data, the best compression method corresponding to the target data is selected from the target compression algorithm list, and the statistical information of the target data includes at least the following: maximum value; minimum value; number of null values; number of unique values; Using the optimal compression method to compress the target data to obtain compressed data; Writing header information into the header of the compressed data to decompress the data based on the header information; Wherein, writing the header information into the header of the compressed data includes: determining the number of bytes occupied by the compressed data after compression, and writing the number of bytes occupied by the compressed data after compression and the optimal compression method into the header of the compressed data as the header information of the target data; The decompressing the data based on the header information includes: acquiring the optimal compression method from the header information; calling a single instruction multiple data stream SIMD to decompress the data using the optimal compression method; Based on the statistical information of the target data, the best compression method corresponding to the target data is selected from the compression algorithm list, including: randomly sampling the target data to obtain sampled target data; calling the interface of the estimation function, and estimating multiple compression rates corresponding to the sampled target data through the estimation function based on the statistical information of the target data; and selecting the best compression method from the compression algorithm list based on the multiple compression rates.

2. The method according to claim 1, characterized in that The classification of data types to determine a list of compression algorithms corresponding to data of different data types includes: Divide the data into numeric data and string data; Integrate Dict encoding, OneValue encoding, Frequency encoding, FastPFOR encoding, RLE encoding and general encoding into the compression algorithm list corresponding to numerical data; In the list of compression algorithms corresponding to string data, FSST encoding, Dict encoding, OneValue encoding and general encoding are integrated.

3. The method according to claim 1, characterized in that The selecting the best compression method from the compression algorithm list based on the multiple compression rates includes: sorting the plurality of compression ratios in descending order; The compression method corresponding to the compression ratio ranked first is selected from the compression algorithm list as the best compression method.

4. The method according to claim 1, characterized in that: If the optimal compression method is run-length encoding, then during the data decompression process, the SIMD instruction uses the AVX2 algorithm to process the data in parallel.

5. A data adaptive storage device, characterized in that: A column-based database applied to an online analytical processing scenario, the device comprising: A division module is used to divide the data types and determine the compression algorithm list corresponding to the data of different data types; A determination module, used to obtain target data and determine a target compression algorithm list corresponding to the target data, wherein the compression algorithm list includes multiple different types of compression methods; A selection module is used to select the best compression method corresponding to the target data from the target compression algorithm list based on the statistical information of the target data, wherein the statistical information of the target data includes at least the following: maximum value; minimum value; number of null values; number of unique values; A compression module, used for compressing the target data using the optimal compression method to obtain compressed data; A decompression module, used for writing header information into the header of the compressed data to decompress the data based on the header information; The decompression module is used to: determine the number of bytes occupied by the compressed data after compression, write the number of bytes after compression and the optimal compression method as the header information of the target data into the header of the compressed data; obtain the optimal compression method from the header information; call the single instruction multiple data stream SIMD to decompress the data through the optimal compression method; The selection module includes: a sampling unit, which is used to randomly sample the target data to obtain sampled target data; an estimation unit, which is used to call the interface of the estimation function and estimate multiple compression rates corresponding to the sampled target data through the estimation function based on the statistical information of the target data; and a selection unit, which is used to select the best compression method from the compression algorithm list based on the multiple compression rates.

6. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively coupled to the at least one processor; The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the data adaptive storage method according to any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the data adaptive storage method according to any one of claims 1 to 4 when executed.

Citation Information

Patent Citations

  • Data storage method, querying method and device

    CN101968806A

  • Data volume compression ratio assessment method and system

    CN106445412A

  • Streaming data efficient retrieval and compression system and compression method

    CN115982436A