2019-02-13 20:31:54 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <IO/WriteBuffer.h>
|
|
|
|
#include <IO/BufferWithOwnMemory.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2019-03-26 21:32:29 +00:00
|
|
|
|
2019-02-13 20:31:54 +00:00
|
|
|
class BrotliWriteBuffer : public BufferWithOwnMemory<WriteBuffer>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BrotliWriteBuffer(
|
2020-01-04 07:31:00 +00:00
|
|
|
std::unique_ptr<WriteBuffer> out_,
|
|
|
|
int compression_level,
|
|
|
|
size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE,
|
|
|
|
char * existing_memory = nullptr,
|
|
|
|
size_t alignment = 0);
|
2019-02-13 20:31:54 +00:00
|
|
|
|
|
|
|
~BrotliWriteBuffer() override;
|
|
|
|
|
2019-03-19 20:18:41 +00:00
|
|
|
void finish();
|
|
|
|
|
2019-02-13 20:31:54 +00:00
|
|
|
private:
|
|
|
|
void nextImpl() override;
|
|
|
|
|
2019-02-13 22:42:38 +00:00
|
|
|
class BrotliStateWrapper;
|
|
|
|
std::unique_ptr<BrotliStateWrapper> brotli;
|
|
|
|
|
|
|
|
size_t in_available;
|
|
|
|
const uint8_t * in_data;
|
|
|
|
|
|
|
|
size_t out_capacity;
|
2020-01-04 07:31:00 +00:00
|
|
|
uint8_t * out_data;
|
2019-02-13 22:42:38 +00:00
|
|
|
|
2020-01-04 07:31:00 +00:00
|
|
|
std::unique_ptr<WriteBuffer> out;
|
2019-03-19 20:18:41 +00:00
|
|
|
|
2019-02-13 20:31:54 +00:00
|
|
|
bool finished = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|