2021-11-05 11:55:30 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-09-28 08:45:15 +00:00
|
|
|
#include "config.h"
|
2021-11-05 11:55:30 +00:00
|
|
|
|
|
|
|
#if USE_SNAPPY
|
|
|
|
#include <IO/BufferWithOwnMemory.h>
|
|
|
|
#include <IO/WriteBuffer.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
/// Performs compression using snappy library and write compressed data to the underlying buffer.
|
|
|
|
class SnappyWriteBuffer : public BufferWithOwnMemory<WriteBuffer>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit SnappyWriteBuffer(
|
|
|
|
std::unique_ptr<WriteBuffer> out_,
|
|
|
|
size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE,
|
|
|
|
char * existing_memory = nullptr,
|
|
|
|
size_t alignment = 0);
|
|
|
|
|
|
|
|
~SnappyWriteBuffer() override;
|
|
|
|
|
2021-11-24 09:52:02 +00:00
|
|
|
void finalizeImpl() override { finish(); }
|
2021-11-05 11:55:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void nextImpl() override;
|
|
|
|
|
|
|
|
void finishImpl();
|
|
|
|
void finish();
|
|
|
|
|
|
|
|
std::unique_ptr<WriteBuffer> out;
|
|
|
|
bool finished = false;
|
|
|
|
|
|
|
|
String uncompress_buffer;
|
|
|
|
String compress_buffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|