2018-10-11 02:57:48 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <IO/WriteBuffer.h>
|
|
|
|
#include <Compression/ICompressionCodec.h>
|
|
|
|
#include <IO/BufferWithOwnMemory.h>
|
|
|
|
#include <Parsers/StringRange.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class CompressionCodecZSTD : public ICompressionCodec
|
|
|
|
{
|
|
|
|
public:
|
2018-12-21 12:17:30 +00:00
|
|
|
static constexpr auto ZSTD_DEFAULT_LEVEL = 1;
|
|
|
|
|
2018-12-19 17:20:18 +00:00
|
|
|
CompressionCodecZSTD(int level_);
|
2018-10-11 02:57:48 +00:00
|
|
|
|
2020-01-03 14:39:24 +00:00
|
|
|
uint8_t getMethodByte() const override;
|
2018-10-11 02:57:48 +00:00
|
|
|
|
2018-12-19 17:20:18 +00:00
|
|
|
String getCodecDesc() const override;
|
2018-10-11 02:57:48 +00:00
|
|
|
|
2019-01-15 14:20:34 +00:00
|
|
|
UInt32 getMaxCompressedDataSize(UInt32 uncompressed_size) const override;
|
2018-10-11 02:57:48 +00:00
|
|
|
|
2018-12-19 17:20:18 +00:00
|
|
|
protected:
|
|
|
|
UInt32 doCompressData(const char * source, UInt32 source_size, char * dest) const override;
|
2018-10-11 02:57:48 +00:00
|
|
|
|
2018-12-19 17:20:18 +00:00
|
|
|
void doDecompressData(const char * source, UInt32 source_size, char * dest, UInt32 uncompressed_size) const override;
|
2018-10-11 02:57:48 +00:00
|
|
|
|
|
|
|
private:
|
2019-01-14 11:54:40 +00:00
|
|
|
const int level;
|
2018-10-11 02:57:48 +00:00
|
|
|
};
|
|
|
|
|
2019-12-15 06:34:43 +00:00
|
|
|
|
|
|
|
class CompressionCodecFactory;
|
|
|
|
void registerCodecZSTD(CompressionCodecFactory & factory);
|
|
|
|
|
2018-12-19 17:20:18 +00:00
|
|
|
}
|