2017-01-07 16:11:30 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <IO/ReadBuffer.h>
|
|
|
|
#include <IO/BufferWithOwnMemory.h>
|
2019-02-13 20:54:12 +00:00
|
|
|
#include <IO/CompressionMethod.h>
|
2017-01-07 16:11:30 +00:00
|
|
|
|
|
|
|
#include <zlib.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 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:
|
2017-04-01 07:20:54 +00:00
|
|
|
ZlibInflatingReadBuffer(
|
2019-11-19 12:46:07 +00:00
|
|
|
std::unique_ptr<ReadBuffer> in_,
|
2019-02-13 20:54:12 +00:00
|
|
|
CompressionMethod compression_method,
|
2017-04-01 07:20:54 +00:00
|
|
|
size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE,
|
|
|
|
char * existing_memory = nullptr,
|
|
|
|
size_t alignment = 0);
|
2017-01-07 16:11:30 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
~ZlibInflatingReadBuffer() override;
|
2017-01-07 16:11:30 +00:00
|
|
|
|
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
bool nextImpl() override;
|
2017-01-07 16:11:30 +00:00
|
|
|
|
2019-11-19 12:46:07 +00:00
|
|
|
std::unique_ptr<ReadBuffer> in;
|
2017-04-01 07:20:54 +00:00
|
|
|
z_stream zstr;
|
|
|
|
bool eof;
|
2017-01-07 16:11:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|