#pragma once #include #include #include #include #include #include #include #include #include #include #include namespace DB { class ICompressionCodec; using CompressionCodecPtr = std::shared_ptr; using Codecs = std::vector; /** * */ class ICompressionCodec : private boost::noncopyable { public: virtual ~ICompressionCodec() = default; virtual UInt8 getMethodByte() const = 0; virtual String getCodecDesc() const = 0; virtual UInt32 compress(char * source, UInt32 source_size, char * dest) const; virtual UInt32 decompress(char * source, UInt32 source_size, char * dest) const; virtual UInt32 getCompressedReserveSize(UInt32 uncompressed_size) const { return getHeaderSize() + getCompressedDataSize(uncompressed_size); } virtual UInt32 getAdditionalSizeAtTheEndOfBuffer() const { return 0; } static UInt8 getHeaderSize() { return COMPRESSED_BLOCK_HEADER_SIZE; } static UInt32 readCompressedBlockSize(const char * source); static UInt32 readDecompressedBlockSize(const char * source); static UInt8 readMethod(const char * source); protected: virtual UInt32 getCompressedDataSize(UInt32 uncompressed_size) const { return uncompressed_size; } virtual UInt32 doCompressData(const char * source, UInt32 source_size, char * dest) const = 0; virtual void doDecompressData(const char * source, UInt32 source_size, char * dest, UInt32 uncompressed_size) const = 0; }; }