1#pragma once
2
3#include <IO/WriteBuffer.h>
4#include <Compression/ICompressionCodec.h>
5#include <IO/BufferWithOwnMemory.h>
6#include <Parsers/StringRange.h>
7#include <Compression/LZ4_decompress_faster.h>
8
9namespace DB
10{
11
12class CompressionCodecLZ4 : public ICompressionCodec
13{
14public:
15 UInt8 getMethodByte() const override;
16
17 String getCodecDesc() const override;
18
19 UInt32 getAdditionalSizeAtTheEndOfBuffer() const override { return LZ4::ADDITIONAL_BYTES_AT_END_OF_BUFFER; }
20
21protected:
22 UInt32 doCompressData(const char * source, UInt32 source_size, char * dest) const override;
23
24private:
25 void doDecompressData(const char * source, UInt32 source_size, char * dest, UInt32 uncompressed_size) const override;
26
27 UInt32 getMaxCompressedDataSize(UInt32 uncompressed_size) const override;
28
29 mutable LZ4::PerformanceStatistics lz4_stat;
30};
31
32class CompressionCodecFactory;
33void registerCodecLZ4(CompressionCodecFactory & factory);
34
35class CompressionCodecLZ4HC : public CompressionCodecLZ4
36{
37public:
38
39 CompressionCodecLZ4HC(int level_);
40
41 String getCodecDesc() const override;
42
43protected:
44 UInt32 doCompressData(const char * source, UInt32 source_size, char * dest) const override;
45
46private:
47 const int level;
48};
49
50class CompressionCodecFactory;
51void registerCodecLZ4HC(CompressionCodecFactory & factory);
52
53}
54