#pragma once #include #include #include #include #include #include #include #include namespace DB { class ICompressionCodec; using CompressionCodecPtr = std::shared_ptr; class IAST; using ASTPtr = std::shared_ptr; /** Creates a codec object by name of compression algorithm family and parameters. */ class CompressionCodecFactory final : public ext::singleton { protected: using Creator = std::function; using SimpleCreator = std::function; using CompressionCodecsDictionary = std::unordered_map; using CompressionCodecsCodeDictionary = std::unordered_map; public: CompressionCodecPtr getDefaultCodec() const; CompressionCodecPtr get(const ASTPtr & ast) const; CompressionCodecPtr get(const UInt8 byte_code) const; /// For backward compatibility with config settings CompressionCodecPtr get(const String & family_name, std::optional level) const; void registerCompressionCodec(const String & family_name, std::optional byte_code, Creator creator); void registerSimpleCompressionCodec(const String & family_name, std::optional byte_code, SimpleCreator creator); protected: CompressionCodecPtr getImpl(const String & family_name, const ASTPtr & arguments) const; private: CompressionCodecsDictionary family_name_with_codec; CompressionCodecsCodeDictionary family_code_with_codec; CompressionCodecPtr default_codec; CompressionCodecFactory(); friend class ext::singleton; }; }