ClickHouse/src/Compression/CompressionInfo.h
Filatenkov Artur c23fe5baf6
Improve codec for encr 19896 (#27476)
* change syntax of encrypted command

* commit all encrypted changes

* correct encryption

* correct config for test

* add tests and correct code style and typos

* correct test

* fix unbundled build

* add log warning messages

* improve code according to review comments

* correct nonce

* correct errors found by fuzzing

* improve codec AES_128_GCM_SIV. Add AES_256_GCM_SIV. Add sections for last in tests. Improve documentation

* Update CompressionCodecEncrypted.h

* Update 01683_codec_encrypted.sql

* correct compression factory after changes in master

* correct behavior with wrong key in data

* correct fuzzer

* add connection for fuzzer with fix for compression_encrypted

* refactor code

* add load from config with throwing errors on server start

* fix typos and check style

* Update Server.cpp

* correct loading and reading

* refactor code. fix uninitialized value

* refactor code

* move defines from server to cpp file

* correct build

* remove repeated code

* correct namespace

* fix code style
2021-09-13 11:25:36 +03:00

51 lines
1.5 KiB
C++

#pragma once
#include <cstdint>
/** Common defines for compression */
#define DBMS_MAX_COMPRESSED_SIZE 0x40000000ULL /// 1GB
/** one byte for method, 4 bytes for compressed size, 4 bytes for uncompressed size */
#define COMPRESSED_BLOCK_HEADER_SIZE 9
namespace DB
{
/** The compressed block format is as follows:
*
* The first 16 bytes are the checksum from all other bytes of the block. Now only CityHash128 is used.
* In the future, you can provide other checksums, although it will not be possible to make them different in size.
*
* The next byte specifies the compression algorithm. Then everything depends on the algorithm.
*
* 0x82 - LZ4 or LZ4HC (they have the same format).
* Next 4 bytes - the size of the compressed data, taking into account the header; 4 bytes is the size of the uncompressed data.
*
* NOTE: Why is 0x82?
* Originally only QuickLZ was used. Then LZ4 was added.
* The high bit is set to distinguish from QuickLZ, and the second bit is set for compatibility,
* for the functions qlz_size_compressed, qlz_size_decompressed to work.
* Although now such compatibility is no longer relevant.
*
* 0x90 - ZSTD
*
* All sizes are little endian.
*/
enum class CompressionMethodByte : uint8_t
{
NONE = 0x02,
LZ4 = 0x82,
ZSTD = 0x90,
Multiple = 0x91,
Delta = 0x92,
T64 = 0x93,
DoubleDelta = 0x94,
Gorilla = 0x95,
AES_128_GCM_SIV = 0x96,
AES_256_GCM_SIV = 0x97
};
}