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

Function chooseCompressionMethod

src/IO/CompressionMethod.cpp:73–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73CompressionMethod chooseCompressionMethod(const std::string & path, const std::string & hint)
74{
75 std::string file_extension;
76 if (hint.empty() || hint == "auto")
77 {
78 auto pos = path.find_last_of('.');
79 if (pos != std::string::npos)
80 file_extension = path.substr(pos + 1, std::string::npos);
81 }
82
83 std::string method_str = file_extension.empty() ? hint : std::move(file_extension);
84 boost::algorithm::to_lower(method_str);
85
86 if (method_str == "gzip" || method_str == "gz")
87 return CompressionMethod::Gzip;
88 if (method_str == "deflate")
89 return CompressionMethod::Zlib;
90 if (method_str == "brotli" || method_str == "br")
91 return CompressionMethod::Brotli;
92 if (method_str == "lzma" || method_str == "xz")
93 return CompressionMethod::Xz;
94 if (method_str == "zstd" || method_str == "zst")
95 return CompressionMethod::Zstd;
96 if (method_str == "snappy")
97 return CompressionMethod::Snappy;
98 if (hint.empty() || hint == "auto" || hint == "none")
99 return CompressionMethod::None;
100
101 throw Exception(
102 "Unknown compression method " + hint + ". Only 'auto', 'none', 'gzip', 'deflate', 'br', 'xz', 'zstd' are supported as compression methods",
103 ErrorCodes::NOT_IMPLEMENTED);
104}
105
106
107std::unique_ptr<ReadBuffer> wrapReadBufferWithCompressionMethod(

Callers 15

writeMethod · 0.85
generateMethod · 0.85
writeMethod · 0.85
initializeMethod · 0.85
writeMethod · 0.85
nextMethod · 0.85
readMethod · 0.85
writeMethod · 0.85
initializeMethod · 0.85
writeMethod · 0.85
generateMethod · 0.85

Calls 2

ExceptionClass · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected