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

Function checkAndWriteHeader

programs/compressor/Compressor.cpp:37–60  ·  view source on GitHub ↗

Outputs sizes of uncompressed and compressed blocks for compressed file.

Source from the content-addressed store, hash-verified

35
36/// Outputs sizes of uncompressed and compressed blocks for compressed file.
37void checkAndWriteHeader(DB::ReadBuffer & in, DB::WriteBuffer & out)
38{
39 while (!in.eof())
40 {
41 in.ignore(16); /// checksum
42
43 char header[COMPRESSED_BLOCK_HEADER_SIZE];
44 in.readStrict(header, COMPRESSED_BLOCK_HEADER_SIZE);
45
46 UInt32 size_compressed = unalignedLoad<UInt32>(&header[1]);
47
48 if (size_compressed > DBMS_MAX_COMPRESSED_SIZE)
49 throw DB::Exception("Too large size_compressed. Most likely corrupted data.", DB::ErrorCodes::TOO_LARGE_SIZE_COMPRESSED);
50
51 UInt32 size_decompressed = unalignedLoad<UInt32>(&header[5]);
52
53 DB::writeText(size_decompressed, out);
54 DB::writeChar('\t', out);
55 DB::writeText(size_compressed, out);
56 DB::writeChar('\n', out);
57
58 in.ignore(size_compressed - COMPRESSED_BLOCK_HEADER_SIZE);
59 }
60}
61
62}
63

Callers 1

Calls 6

writeCharFunction · 0.85
readStrictMethod · 0.80
ExceptionClass · 0.50
writeTextFunction · 0.50
eofMethod · 0.45
ignoreMethod · 0.45

Tested by

no test coverage detected