2019-09-26 11:19:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Dictionaries/IDictionary.h>
|
2019-09-30 16:12:08 +00:00
|
|
|
#include <Interpreters/IExternalLoaderConfigRepository.h>
|
2019-09-26 11:19:10 +00:00
|
|
|
#include <Interpreters/ExternalLoader.h>
|
|
|
|
#include <common/logger_useful.h>
|
2019-10-18 15:44:32 +00:00
|
|
|
#include <Parsers/ASTCreateQuery.h>
|
2019-09-26 11:19:10 +00:00
|
|
|
#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.
|
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
|
|
|
|
{
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2019-10-17 17:18:54 +00:00
|
|
|
void addConfigRepository(
|
|
|
|
const std::string & repository_name,
|
|
|
|
std::unique_ptr<IExternalLoaderConfigRepository> config_repository);
|
|
|
|
|
2019-10-18 15:44:32 +00:00
|
|
|
/// Starts reloading of a specified object.
|
2019-10-21 13:54:23 +00:00
|
|
|
void addDictionaryWithConfig(
|
|
|
|
const String & dictionary_name,
|
2019-10-18 15:44:32 +00:00
|
|
|
const String & repo_name,
|
|
|
|
const ASTCreateQuery & query,
|
2019-10-21 13:54:23 +00:00
|
|
|
bool load_never_loading = false) const;
|
2019-10-18 15:44:32 +00:00
|
|
|
|
|
|
|
|
2019-09-26 11:19:10 +00:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|