mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-20 05:05:38 +00:00
40 lines
899 B
C++
40 lines
899 B
C++
#pragma once
|
|
|
|
#include <IO/BufferWithOwnMemory.h>
|
|
#include <IO/CompressionMethod.h>
|
|
#include <IO/WriteBuffer.h>
|
|
#include <IO/WriteBufferDecorator.h>
|
|
|
|
#include <lz4.h>
|
|
#include <lz4frame.h>
|
|
|
|
namespace DB
|
|
{
|
|
/// Performs compression using lz4 library and writes compressed data to out_ WriteBuffer.
|
|
class Lz4DeflatingWriteBuffer : public WriteBufferWithOwnMemoryDecorator
|
|
{
|
|
public:
|
|
Lz4DeflatingWriteBuffer(
|
|
std::unique_ptr<WriteBuffer> out_,
|
|
int compression_level,
|
|
size_t buf_size = DBMS_DEFAULT_BUFFER_SIZE,
|
|
char * existing_memory = nullptr,
|
|
size_t alignment = 0);
|
|
|
|
~Lz4DeflatingWriteBuffer() override;
|
|
|
|
private:
|
|
void nextImpl() override;
|
|
|
|
void finalizeBefore() override;
|
|
void finalizeAfter() override;
|
|
|
|
LZ4F_preferences_t kPrefs; /// NOLINT
|
|
LZ4F_compressionContext_t ctx;
|
|
|
|
Memory<> tmp_memory;
|
|
|
|
bool first_time = true;
|
|
};
|
|
}
|