| 292 | } |
| 293 | |
| 294 | void CompressedReadBufferBase::decompress(BufferBase::Buffer & to, size_t size_decompressed, size_t size_compressed_without_checksum) |
| 295 | { |
| 296 | readHeaderAndGetCodec(compressed_buffer, size_decompressed, codec, allow_different_codecs, external_data); |
| 297 | |
| 298 | if (codec->isNone()) |
| 299 | { |
| 300 | /// Shortcut for NONE codec to avoid extra memcpy. |
| 301 | /// We doing it by changing the buffer `to` to point to existing uncompressed data. |
| 302 | |
| 303 | UInt8 header_size = ICompressionCodec::getHeaderSize(); |
| 304 | if (size_compressed_without_checksum < header_size) |
| 305 | throw Exception(external_data ? ErrorCodes::CANNOT_DECOMPRESS : ErrorCodes::CORRUPTED_DATA, |
| 306 | "Can't decompress data: the compressed data size ({}, this should include header size) is less than the header size ({})", |
| 307 | size_compressed_without_checksum, static_cast<size_t>(header_size)); |
| 308 | |
| 309 | to = BufferBase::Buffer(compressed_buffer + header_size, compressed_buffer + size_compressed_without_checksum); |
| 310 | } |
| 311 | else |
| 312 | codec->decompress(compressed_buffer, static_cast<UInt32>(size_compressed_without_checksum), to.begin()); |
| 313 | } |
| 314 | |
| 315 | void CompressedReadBufferBase::addDiagnostics(Exception & e) const |
| 316 | { |
no test coverage detected