ClickHouse/dbms/src/Interpreters/ExternalDictionariesLoader.h

49 lines
1.3 KiB
C++
Raw Normal View History

2019-09-26 11:19:10 +00:00
#pragma once
#include <Dictionaries/IDictionary.h>
#include <Interpreters/ExternalLoader.h>
#include <common/logger_useful.h>
#include <memory>
namespace DB
{
class Context;
/// 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.
ExternalDictionariesLoader(
2019-09-26 16:12:15 +00:00
std::unique_ptr<ExternalLoaderConfigRepository> config_repository,
2019-09-26 11:19:10 +00:00
const Poco::Util::AbstractConfiguration & config,
Context & context_);
DictPtr getDictionary(const std::string & name) const
{
return std::static_pointer_cast<const IDictionaryBase>(getLoadable(name));
}
DictPtr tryGetDictionary(const std::string & name) const
{
return std::static_pointer_cast<const IDictionaryBase>(tryGetLoadable(name));
}
protected:
LoadablePtr create(const std::string & name, const Poco::Util::AbstractConfiguration & config,
const std::string & key_in_config) const override;
friend class StorageSystemDictionaries;
friend class DatabaseDictionary;
private:
Context & context;
};
}