2019-09-26 11:19:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Dictionaries/IDictionary.h>
|
|
|
|
#include <Interpreters/ExternalLoader.h>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
class Context;
|
2019-12-12 16:41:41 +00:00
|
|
|
class IExternalLoaderConfigRepository;
|
2019-09-26 11:19:10 +00:00
|
|
|
|
|
|
|
/// Manages user-defined dictionaries.
|
|
|
|
class ExternalDictionariesLoader : public ExternalLoader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using DictPtr = std::shared_ptr<const IDictionaryBase>;
|
|
|
|
|
|
|
|
/// Dictionaries will be loaded immediately and then will be updated in separate thread, each 'reload_period' seconds.
|
2019-10-18 15:44:32 +00:00
|
|
|
ExternalDictionariesLoader(Context & context_);
|
2019-09-26 11:19:10 +00:00
|
|
|
|
|
|
|
DictPtr getDictionary(const std::string & name) const
|
|
|
|
{
|
2019-12-12 18:33:43 +00:00
|
|
|
return std::static_pointer_cast<const IDictionaryBase>(load(name));
|
2019-09-26 11:19:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DictPtr tryGetDictionary(const std::string & name) const
|
|
|
|
{
|
2019-12-12 18:33:43 +00:00
|
|
|
return std::static_pointer_cast<const IDictionaryBase>(tryLoad(name));
|
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
|
|
|
|
|
|
|
friend class StorageSystemDictionaries;
|
|
|
|
friend class DatabaseDictionary;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Context & context;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|