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 | |
9 | namespace DB |
10 | { |
11 | |
12 | class CompressionCodecLZ4 : public ICompressionCodec |
13 | { |
14 | public: |
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 | |
21 | protected: |
22 | UInt32 doCompressData(const char * source, UInt32 source_size, char * dest) const override; |
23 | |
24 | private: |
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 | |
32 | class CompressionCodecFactory; |
33 | void registerCodecLZ4(CompressionCodecFactory & factory); |
34 | |
35 | class CompressionCodecLZ4HC : public CompressionCodecLZ4 |
36 | { |
37 | public: |
38 | |
39 | CompressionCodecLZ4HC(int level_); |
40 | |
41 | String getCodecDesc() const override; |
42 | |
43 | protected: |
44 | UInt32 doCompressData(const char * source, UInt32 source_size, char * dest) const override; |
45 | |
46 | private: |
47 | const int level; |
48 | }; |
49 | |
50 | class CompressionCodecFactory; |
51 | void registerCodecLZ4HC(CompressionCodecFactory & factory); |
52 | |
53 | } |
54 |