2019-09-26 11:19:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-03-19 12:47:27 +00:00
|
|
|
#include <Dictionaries/IDictionary.h>
|
2021-04-10 23:33:54 +00:00
|
|
|
#include <Interpreters/Context_fwd.h>
|
|
|
|
#include <Interpreters/ExternalLoader.h>
|
|
|
|
#include <Common/quoteString.h>
|
|
|
|
|
|
|
|
#include <memory>
|
2021-03-19 12:47:27 +00:00
|
|
|
|
2019-09-26 11:19:10 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2021-04-10 23:33:54 +00:00
|
|
|
|
2019-12-12 16:41:41 +00:00
|
|
|
class IExternalLoaderConfigRepository;
|
2019-09-26 11:19:10 +00:00
|
|
|
|
|
|
|
/// Manages user-defined dictionaries.
|
2021-06-01 12:20:52 +00:00
|
|
|
class ExternalDictionariesLoader : public ExternalLoader, WithContext
|
2019-09-26 11:19:10 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-03-24 16:31:00 +00:00
|
|
|
using DictPtr = std::shared_ptr<const IDictionary>;
|
2019-09-26 11:19:10 +00:00
|
|
|
|
|
|
|
/// Dictionaries will be loaded immediately and then will be updated in separate thread, each 'reload_period' seconds.
|
2021-06-01 12:20:52 +00:00
|
|
|
explicit ExternalDictionariesLoader(ContextPtr global_context_);
|
2019-09-26 11:19:10 +00:00
|
|
|
|
2021-06-01 12:20:52 +00:00
|
|
|
DictPtr getDictionary(const std::string & dictionary_name, ContextPtr context) const;
|
2021-03-19 12:47:27 +00:00
|
|
|
|
2021-06-01 12:20:52 +00:00
|
|
|
DictPtr tryGetDictionary(const std::string & dictionary_name, ContextPtr context) const;
|
2019-09-26 11:19:10 +00:00
|
|
|
|
2021-06-01 12:20:52 +00:00
|
|
|
void reloadDictionary(const std::string & dictionary_name, ContextPtr context) const;
|
2019-09-26 11:19:10 +00:00
|
|
|
|
2021-06-01 12:20:52 +00:00
|
|
|
DictionaryStructure getDictionaryStructure(const std::string & dictionary_name, ContextPtr context) const;
|
2021-03-18 14:03:22 +00:00
|
|
|
|
2020-04-12 20:50:32 +00:00
|
|
|
static DictionaryStructure getDictionaryStructure(const Poco::Util::AbstractConfiguration & config, const std::string & key_in_config = "dictionary");
|
2021-03-20 15:02:09 +00:00
|
|
|
|
2020-04-12 20:50:32 +00:00
|
|
|
static DictionaryStructure getDictionaryStructure(const ObjectConfig & config);
|
|
|
|
|
2020-02-27 09:34:06 +00:00
|
|
|
static void resetAll();
|
|
|
|
|
2019-09-26 11:19:10 +00:00
|
|
|
protected:
|
|
|
|
LoadablePtr create(const std::string & name, const Poco::Util::AbstractConfiguration & config,
|
2019-12-11 11:09:21 +00:00
|
|
|
const std::string & key_in_config, const std::string & repository_name) const override;
|
2019-09-26 11:19:10 +00:00
|
|
|
|
2021-03-20 15:02:09 +00:00
|
|
|
std::string resolveDictionaryName(const std::string & dictionary_name, const std::string & current_database_name) const;
|
2021-03-19 12:47:27 +00:00
|
|
|
|
|
|
|
/// Try convert qualified dictionary name to persistent UUID
|
2021-09-13 19:11:16 +00:00
|
|
|
std::string resolveDictionaryNameFromDatabaseCatalog(const std::string & name, const std::string & current_database_name) const;
|
2021-03-19 12:47:27 +00:00
|
|
|
|
2019-09-26 11:19:10 +00:00
|
|
|
friend class StorageSystemDictionaries;
|
|
|
|
friend class DatabaseDictionary;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|