| 71 | } |
| 72 | |
| 73 | CompressionMethod 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 | |
| 107 | std::unique_ptr<ReadBuffer> wrapReadBufferWithCompressionMethod( |
no test coverage detected