1 | #pragma once |
2 | |
3 | #include <cstdint> |
4 | |
5 | /** Common defines for compression */ |
6 | |
7 | #define DBMS_MAX_COMPRESSED_SIZE 0x40000000ULL /// 1GB |
8 | |
9 | /** one byte for method, 4 bytes for compressed size, 4 bytes for uncompressed size */ |
10 | #define 9 |
11 | |
12 | namespace DB |
13 | { |
14 | |
15 | /** The compressed block format is as follows: |
16 | * |
17 | * The first 16 bytes are the checksum from all other bytes of the block. Now only CityHash128 is used. |
18 | * In the future, you can provide other checksums, although it will not be possible to make them different in size. |
19 | * |
20 | * The next byte specifies the compression algorithm. Then everything depends on the algorithm. |
21 | * |
22 | * 0x82 - LZ4 or LZ4HC (they have the same format). |
23 | * Next 4 bytes - the size of the compressed data, taking into account the header; 4 bytes is the size of the uncompressed data. |
24 | * |
25 | * NOTE: Why is 0x82? |
26 | * Originally only QuickLZ was used. Then LZ4 was added. |
27 | * The high bit is set to distinguish from QuickLZ, and the second bit is set for compatibility, |
28 | * for the functions qlz_size_compressed, qlz_size_decompressed to work. |
29 | * Although now such compatibility is no longer relevant. |
30 | * |
31 | * 0x90 - ZSTD |
32 | * |
33 | * All sizes are little endian. |
34 | */ |
35 | |
36 | enum class CompressionMethodByte : uint8_t |
37 | { |
38 | NONE = 0x02, |
39 | LZ4 = 0x82, |
40 | ZSTD = 0x90, |
41 | Multiple = 0x91, |
42 | Delta = 0x92, |
43 | T64 = 0x93, |
44 | DoubleDelta = 0x94, |
45 | Gorilla = 0x95, |
46 | }; |
47 | |
48 | } |
49 | |