2015-02-10 17:40:40 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Dictionaries/IDictionary.h>
|
2017-10-06 10:31:06 +00:00
|
|
|
#include <Interpreters/ExternalLoader.h>
|
2015-09-29 19:19:54 +00:00
|
|
|
#include <common/logger_useful.h>
|
2017-10-06 10:31:06 +00:00
|
|
|
#include <memory>
|
2017-09-09 23:17:38 +00:00
|
|
|
|
2015-02-10 17:40:40 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class Context;
|
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
/// Manages user-defined dictionaries.
|
|
|
|
class ExternalDictionaries : public ExternalLoader
|
2015-02-10 17:40:40 +00:00
|
|
|
{
|
2017-10-06 10:31:06 +00:00
|
|
|
public:
|
|
|
|
using DictPtr = std::shared_ptr<IDictionaryBase>;
|
2015-03-24 09:46:07 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
/// Dictionaries will be loaded immediately and then will be updated in separate thread, each 'reload_period' seconds.
|
2017-11-28 11:00:07 +00:00
|
|
|
ExternalDictionaries(
|
|
|
|
std::unique_ptr<IExternalLoaderConfigRepository> config_repository,
|
|
|
|
Context & context,
|
|
|
|
bool throw_on_error);
|
2015-03-18 16:07:15 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
/// Forcibly reloads specified dictionary.
|
|
|
|
void reloadDictionary(const std::string & name) { reload(name); }
|
2017-08-24 18:19:06 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
DictPtr getDictionary(const std::string & name) const
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
2017-10-06 10:31:06 +00:00
|
|
|
return std::static_pointer_cast<IDictionaryBase>(getLoadable(name));
|
|
|
|
}
|
2015-05-26 11:53:58 +00:00
|
|
|
|
2018-03-23 19:56:24 +00:00
|
|
|
DictPtr tryGetDictionary(const std::string & name) const
|
|
|
|
{
|
|
|
|
return std::static_pointer_cast<IDictionaryBase>(tryGetLoadable(name));
|
|
|
|
}
|
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
protected:
|
2015-06-09 16:12:51 +00:00
|
|
|
|
2017-10-06 11:10:01 +00:00
|
|
|
std::unique_ptr<IExternalLoadable> create(const std::string & name, const Configuration & config,
|
|
|
|
const std::string & config_prefix) override;
|
2015-08-12 03:57:32 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
using ExternalLoader::getObjectsMap;
|
2015-08-12 03:57:32 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
friend class StorageSystemDictionaries;
|
|
|
|
friend class DatabaseDictionary;
|
2015-08-12 03:57:32 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
private:
|
2015-02-10 17:40:40 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
Context & context;
|
2015-02-10 17:40:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|