ClickHouse/dbms/src/Compression/CompressionCodecLZ4.h

48 lines
1.1 KiB
C++
Raw Normal View History

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>
2018-12-28 18:15:26 +00:00
#include <Compression/LZ4_decompress_faster.h>
2018-10-11 02:57:48 +00:00
namespace DB
{
class CompressionCodecLZ4 : public ICompressionCodec
{
public:
2018-12-19 17:20:18 +00:00
UInt8 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
2018-12-20 10:27:38 +00:00
UInt32 getAdditionalSizeAtTheEndOfBuffer() const override { return LZ4::ADDITIONAL_BYTES_AT_END_OF_BUFFER; }
2018-10-11 02:57:48 +00:00
2018-12-21 14:03:53 +00:00
protected:
2018-12-19 17:20:18 +00:00
UInt32 doCompressData(const char * source, UInt32 source_size, char * dest) const override;
2018-10-11 02:57:48 +00:00
2018-12-21 14:03:53 +00:00
private:
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
UInt32 getMaxCompressedDataSize(UInt32 uncompressed_size) const override;
2018-12-19 17:20:18 +00:00
mutable LZ4::PerformanceStatistics lz4_stat;
2018-10-11 02:57:48 +00:00
};
2018-12-21 14:03:53 +00:00
class CompressionCodecLZ4HC : public CompressionCodecLZ4
{
public:
CompressionCodecLZ4HC(int level_);
String getCodecDesc() const override;
protected:
UInt32 doCompressData(const char * source, UInt32 source_size, char * dest) const override;
private:
const int level;
2018-12-21 14:03:53 +00:00
};
2018-12-19 17:20:18 +00:00
}