1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#pragma once
#include <memory>
#include <string>
#include <Core/Defines.h>
namespace DB
{
class ReadBuffer;
class WriteBuffer;
/** These are "generally recognizable" compression methods for data import/export.
* Do not mess with more efficient compression methods used by ClickHouse internally
* (they use non-standard framing, indexes, checksums...)
*/
enum class CompressionMethod
{
None,
/// DEFLATE compression with gzip header and CRC32 checksum.
/// This option corresponds to files produced by gzip(1) or HTTP Content-Encoding: gzip.
Gzip,
/// DEFLATE compression with zlib header and Adler32 checksum.
/// This option corresponds to HTTP Content-Encoding: deflate.
Zlib,
/// LZMA2-based content compression
/// This option corresponds to HTTP Content-Encoding: xz
Xz,
/// Zstd compressor
/// This option corresponds to HTTP Content-Encoding: zstd
Zstd,
Brotli,
Lz4,
Bzip2,
Snappy,
};
/// How the compression method is named in HTTP.
std::string toContentEncodingName(CompressionMethod method);
/** Choose compression method from path and hint.
* if hint is "auto" or empty string, then path is analyzed,
* otherwise path parameter is ignored and hint is used as compression method name.
* path is arbitrary string that will be analyzed for file extension (gz, br...) that determines compression.
*/
CompressionMethod chooseCompressionMethod(const std::string & path, const std::string & hint);
/** Choose a compression method from HTTP header list of supported compression methods.
*/
CompressionMethod chooseHTTPCompressionMethod(const std::string & list);
/// Get a range of the valid compression levels for the compression method.
std::pair<uint64_t, uint64_t> getCompressionLevelRange(const CompressionMethod & method);
std::unique_ptr<ReadBuffer> wrapReadBufferWithCompressionMethod(
std::unique_ptr<ReadBuffer> nested,
CompressionMethod method,
int zstd_window_log_max = 0,
size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE,
char * existing_memory = nullptr,
size_t alignment = 0);
std::unique_ptr<WriteBuffer> wrapWriteBufferWithCompressionMethod(
std::unique_ptr<WriteBuffer> nested,
CompressionMethod method,
int level,
size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE,
char * existing_memory = nullptr,
size_t alignment = 0);
}
|