2020-10-31 23:56:41 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-11-01 18:40:05 +00:00
|
|
|
#include <IO/BufferWithOwnMemory.h>
|
2020-11-02 20:04:49 +00:00
|
|
|
#include <IO/WriteBuffer.h>
|
2020-10-31 23:56:41 +00:00
|
|
|
|
|
|
|
#include <lzma.h>
|
2020-11-09 22:52:22 +00:00
|
|
|
#include <fast-lzma2.h>
|
2020-10-31 23:56:41 +00:00
|
|
|
|
2020-11-02 20:04:49 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2020-11-01 18:40:05 +00:00
|
|
|
/// Performs compression using lzma library and writes compressed data to out_ WriteBuffer.
|
2020-11-09 22:52:22 +00:00
|
|
|
class LZMADeflatingWriteBuffer : public BufferWithOwnMemory<WriteBuffer>
|
2020-11-02 20:04:49 +00:00
|
|
|
{
|
2020-11-01 18:40:05 +00:00
|
|
|
public:
|
2020-11-09 22:52:22 +00:00
|
|
|
LZMADeflatingWriteBuffer(
|
2020-11-02 20:04:49 +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);
|
2020-11-01 18:40:05 +00:00
|
|
|
|
|
|
|
void finish();
|
|
|
|
|
2020-11-09 22:52:22 +00:00
|
|
|
~LZMADeflatingWriteBuffer() override;
|
2020-11-01 18:40:05 +00:00
|
|
|
|
|
|
|
private:
|
2020-11-02 20:04:49 +00:00
|
|
|
void nextImpl() override;
|
2020-11-01 18:40:05 +00:00
|
|
|
|
2020-11-02 20:04:49 +00:00
|
|
|
std::unique_ptr<WriteBuffer> out;
|
2020-11-09 22:52:22 +00:00
|
|
|
FL2_CStream * lstr;
|
2020-11-02 20:04:49 +00:00
|
|
|
bool finished = false;
|
2020-11-01 18:40:05 +00:00
|
|
|
};
|
2020-11-03 23:47:39 +00:00
|
|
|
}
|