示例#1
0
/// Выводит размеры разжатых и сжатых блоков для сжатого файла.
void stat(DB::ReadBuffer & in, DB::WriteBuffer & out)
{
	while (!in.eof())
	{
		char header[COMPRESSED_BLOCK_HEADER_SIZE];

		in.ignore(16);	/// checksum
		in.readStrict(header, COMPRESSED_BLOCK_HEADER_SIZE);

		size_t size_compressed = 0;
		memcpy(&size_compressed, &header[1], 4);	/// little endian

		if (size_compressed > DBMS_MAX_COMPRESSED_SIZE)
			throw DB::Exception("Too large size_compressed. Most likely corrupted data.", DB::ErrorCodes::TOO_LARGE_SIZE_COMPRESSED);

		size_t size_decompressed = 0;
		memcpy(&size_compressed, &header[5], 4);	/// little endian

		DB::writeText(size_decompressed, out);
		DB::writeChar('\t', out);
		DB::writeText(size_compressed, out);
		DB::writeChar('\n', out);

		in.ignore(size_compressed - COMPRESSED_BLOCK_HEADER_SIZE);
	}
}
示例#2
0
/// Outputs sizes of uncompressed and compressed blocks for compressed file.
void stat(DB::ReadBuffer & in, DB::WriteBuffer & out)
{
    while (!in.eof())
    {
        in.ignore(16);    /// checksum

        char header[COMPRESSED_BLOCK_HEADER_SIZE];
        in.readStrict(header, COMPRESSED_BLOCK_HEADER_SIZE);

        UInt32 size_compressed = unalignedLoad<UInt32>(&header[1]);

        if (size_compressed > DBMS_MAX_COMPRESSED_SIZE)
            throw DB::Exception("Too large size_compressed. Most likely corrupted data.", DB::ErrorCodes::TOO_LARGE_SIZE_COMPRESSED);

        UInt32 size_decompressed = unalignedLoad<UInt32>(&header[5]);

        DB::writeText(size_decompressed, out);
        DB::writeChar('\t', out);
        DB::writeText(size_compressed, out);
        DB::writeChar('\n', out);

        in.ignore(size_compressed - COMPRESSED_BLOCK_HEADER_SIZE);
    }
}
示例#3
0
/// Read and check header of compressed block. Print size of decompressed and compressed data.
std::pair<UInt32, UInt32> stat(DB::ReadBuffer & in, DB::WriteBuffer & out)
{
    if (in.eof())
        return {};

    in.ignore(16);    /// checksum

    char header[COMPRESSED_BLOCK_HEADER_SIZE];
    in.readStrict(header, COMPRESSED_BLOCK_HEADER_SIZE);

    UInt32 size_compressed = unalignedLoad<UInt32>(&header[1]);

    if (size_compressed > DBMS_MAX_COMPRESSED_SIZE)
        throw DB::Exception("Too large size_compressed. Most likely corrupted data.", DB::ErrorCodes::TOO_LARGE_SIZE_COMPRESSED);

    UInt32 size_decompressed = unalignedLoad<UInt32>(&header[5]);

    return {size_compressed, size_decompressed};
}