mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-17 21:24:28 +00:00
600bb5f29a
* introduce ZlibDeflatingWriteBuffer and ZlibInflatingReadBuffer * use them instead of Poco streams * seamlessly uncompress multiple concatenated gzip streams
41 lines
815 B
C++
41 lines
815 B
C++
#pragma once
|
|
|
|
#include <DB/IO/ReadBuffer.h>
|
|
#include <DB/IO/BufferWithOwnMemory.h>
|
|
#include <DB/IO/ZlibCompressionMethod.h>
|
|
|
|
#include <zlib.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
namespace ErrorCodes
|
|
{
|
|
extern const int ZLIB_INFLATE_FAILED;
|
|
}
|
|
|
|
/// Reads compressed data from ReadBuffer in_ and performs decompression using zlib library.
|
|
/// This buffer is able to seamlessly decompress multiple concatenated zlib streams.
|
|
class ZlibInflatingReadBuffer : public BufferWithOwnMemory<ReadBuffer>
|
|
{
|
|
public:
|
|
ZlibInflatingReadBuffer(
|
|
ReadBuffer & in_,
|
|
ZlibCompressionMethod compression_method,
|
|
size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE,
|
|
char * existing_memory = nullptr,
|
|
size_t alignment = 0);
|
|
|
|
~ZlibInflatingReadBuffer() override;
|
|
|
|
private:
|
|
bool nextImpl() override;
|
|
|
|
ReadBuffer & in;
|
|
z_stream zstr;
|
|
bool eof;
|
|
};
|
|
|
|
}
|