#pragma once #include #include #include #include #include namespace DB { class NamedCollectionsMetadataStorage : private WithContext { public: static std::unique_ptr create(const ContextPtr & context); NamedCollectionsMap getAll() const; MutableNamedCollectionPtr get(const std::string & collection_name) const; MutableNamedCollectionPtr create(const ASTCreateNamedCollectionQuery & query); void remove(const std::string & collection_name); bool removeIfExists(const std::string & collection_name); void update(const ASTAlterNamedCollectionQuery & query); void shutdown(); /// Return true if update was made bool waitUpdate(); bool isReplicated() const; private: class INamedCollectionsStorage; class LocalStorage; class LocalStorageEncrypted; class ZooKeeperStorage; class ZooKeeperStorageEncrypted; std::shared_ptr storage; NamedCollectionsMetadataStorage(std::shared_ptr storage_, ContextPtr context_); std::vector listCollections() const; ASTCreateNamedCollectionQuery readCreateQuery(const std::string & collection_name) const; void writeCreateQuery(const ASTCreateNamedCollectionQuery & query, bool replace = false); }; }