ClickHouse/dbms/Compression/CompressionCodecLZ4.h

54 lines
1.3 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:
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
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
};
2019-12-15 06:34:43 +00:00
class CompressionCodecFactory;
void registerCodecLZ4(CompressionCodecFactory & factory);
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
};
2019-12-15 06:34:43 +00:00
class CompressionCodecFactory;
void registerCodecLZ4HC(CompressionCodecFactory & factory);
2018-12-19 17:20:18 +00:00
}