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

Method decompress

src/Compression/CompressedReadBufferBase.cpp:294–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294void 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
315void CompressedReadBufferBase::addDiagnostics(Exception & e) const
316{

Callers 1

decompressToMethod · 0.45

Calls 5

readHeaderAndGetCodecFunction · 0.85
ExceptionClass · 0.70
BufferClass · 0.50
isNoneMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected