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

Function readHeaderAndGetCodec

src/Compression/CompressedReadBufferBase.cpp:258–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256}
257
258static void readHeaderAndGetCodec(const char * compressed_buffer, size_t size_decompressed, CompressionCodecPtr & codec,
259 bool allow_different_codecs, bool external_data)
260{
261 ProfileEvents::increment(ProfileEvents::CompressedReadBufferBlocks);
262 ProfileEvents::increment(ProfileEvents::CompressedReadBufferBytes, size_decompressed);
263
264 uint8_t method = ICompressionCodec::readMethod(compressed_buffer);
265
266 if (!codec)
267 {
268 codec = CompressionCodecFactory::instance().get(method);
269 }
270 else if (codec->getMethodByte() != method)
271 {
272 if (allow_different_codecs)
273 {
274 codec = CompressionCodecFactory::instance().get(method);
275 }
276 else
277 {
278 throw Exception(ErrorCodes::CANNOT_DECOMPRESS, "Data compressed with different methods, given method "
279 "byte 0x{}, previous method byte 0x{}",
280 getHexUIntLowercase(method), getHexUIntLowercase(codec->getMethodByte()));
281 }
282 }
283
284 if (external_data)
285 codec->setExternalDataFlag();
286}
287
288void CompressedReadBufferBase::decompressTo(char * to, size_t size_decompressed, size_t size_compressed_without_checksum)
289{

Callers 2

decompressToMethod · 0.85
decompressMethod · 0.85

Calls 6

getHexUIntLowercaseFunction · 0.85
setExternalDataFlagMethod · 0.80
ExceptionClass · 0.70
incrementFunction · 0.50
getMethod · 0.45
getMethodByteMethod · 0.45

Tested by

no test coverage detected