MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / chooseCompressionMethod

Function chooseCompressionMethod

src/IO/CompressionMethod.cpp:80–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80CompressionMethod chooseCompressionMethod(const std::string & path, const std::string & hint)
81{
82 std::string file_extension;
83 if (hint.empty() || hint == "auto")
84 {
85 auto pos = path.find_last_of('.');
86 if (pos != std::string::npos)
87 file_extension = path.substr(pos + 1, std::string::npos);
88 }
89
90 std::string method_str;
91
92 if (file_extension.empty())
93 method_str = hint;
94 else
95 method_str = std::move(file_extension);
96
97 boost::algorithm::to_lower(method_str);
98
99 if (method_str == "gzip" || method_str == "gz")
100 return CompressionMethod::Gzip;
101 if (method_str == "deflate")
102 return CompressionMethod::Zlib;
103 if (method_str == "brotli" || method_str == "br")
104 return CompressionMethod::Brotli;
105 if (method_str == "lzma" || method_str == "xz")
106 return CompressionMethod::Xz;
107 if (method_str == "zstd" || method_str == "zst")
108 return CompressionMethod::Zstd;
109 if (method_str == "lz4")
110 return CompressionMethod::Lz4;
111 if (method_str == "bz2")
112 return CompressionMethod::Bzip2;
113 if (method_str == "snappy")
114 return CompressionMethod::Snappy;
115 if (hint.empty() || hint == "auto" || hint == "none")
116 return CompressionMethod::None;
117
118 throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Unknown compression method '{}'. "
119 "Only 'auto', 'none', 'gzip', 'deflate', 'br', 'xz', 'zstd', 'lz4', 'bz2', 'snappy' are supported as compression methods", hint);
120}
121
122std::pair<uint64_t, uint64_t> getCompressionLevelRange(const CompressionMethod & method)
123{

Callers 15

createReadBufferFunction · 0.85
writeMethod · 0.85
StorageURLClusterMethod · 0.85
IStorageURLBaseMethod · 0.85
generateMethod · 0.85
createReaderMethod · 0.85
nextMethod · 0.85
writeDataFilesFunction · 0.85
createInitialMethod · 0.85

Calls 2

ExceptionClass · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected