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

Function checkAndWriteHeader

programs/compressor/Compressor.cpp:52–70  ·  view source on GitHub ↗

Outputs method, sizes of uncompressed and compressed blocks for compressed file.

Source from the content-addressed store, hash-verified

50
51/// Outputs method, sizes of uncompressed and compressed blocks for compressed file.
52void checkAndWriteHeader(DB::ReadBuffer & in, DB::WriteBuffer & out)
53{
54 while (!in.eof())
55 {
56 UInt32 size_compressed = {};
57 UInt32 size_decompressed = {};
58 auto codec = DB::getCompressionCodecForFile(in, size_compressed, size_decompressed, true /* skip_to_next_block */);
59
60 if (size_compressed > DBMS_MAX_COMPRESSED_SIZE)
61 throw DB::Exception(DB::ErrorCodes::TOO_LARGE_SIZE_COMPRESSED, "Too large size_compressed. Most likely corrupted data.");
62
63 DB::writeText(codec->getFullCodecDesc()->formatWithSecretsOneLine(), out);
64 DB::writeChar('\t', out);
65 DB::writeText(size_decompressed, out);
66 DB::writeChar('\t', out);
67 DB::writeText(size_compressed, out);
68 DB::writeChar('\n', out);
69 }
70}
71
72}
73

Callers 1

Calls 7

writeCharFunction · 0.85
getFullCodecDescMethod · 0.80
ExceptionClass · 0.50
writeTextFunction · 0.50
eofMethod · 0.45

Tested by

no test coverage detected