2017-04-01 09:19:00 +00:00
|
|
|
#include <Interpreters/ExternalDictionaries.h>
|
2017-08-24 14:51:13 +00:00
|
|
|
#include <Interpreters/Context.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Dictionaries/DictionaryFactory.h>
|
2015-06-09 16:12:51 +00:00
|
|
|
|
2015-01-21 11:39:48 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2015-02-04 13:06:56 +00:00
|
|
|
namespace
|
|
|
|
{
|
2017-10-26 18:39:55 +00:00
|
|
|
const ExternalLoaderUpdateSettings externalDictionariesUpdateSettings;
|
2017-08-07 13:36:03 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
const ExternalLoaderConfigSettings & getExternalDictionariesConfigSettings()
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
2017-10-06 10:31:06 +00:00
|
|
|
static ExternalLoaderConfigSettings settings;
|
|
|
|
static std::once_flag flag;
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
std::call_once(flag, [] {
|
|
|
|
settings.external_config = "dictionary";
|
|
|
|
settings.external_name = "name";
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
settings.path_setting_name = "dictionaries_config";
|
|
|
|
});
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
return settings;
|
2017-04-01 07:20:54 +00:00
|
|
|
}
|
2015-01-26 15:27:51 +00:00
|
|
|
}
|
2015-01-21 11:39:48 +00:00
|
|
|
|
2017-08-24 18:19:06 +00:00
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
ExternalDictionaries::ExternalDictionaries(Context & context, bool throw_on_error)
|
|
|
|
: ExternalLoader(context.getConfigRef(),
|
2017-10-26 18:39:55 +00:00
|
|
|
externalDictionariesUpdateSettings,
|
2017-10-06 10:31:06 +00:00
|
|
|
getExternalDictionariesConfigSettings(),
|
|
|
|
&Logger::get("ExternalDictionaries"),
|
2017-10-06 11:10:01 +00:00
|
|
|
"external dictionary"),
|
2017-10-06 10:31:06 +00:00
|
|
|
context(context)
|
2017-08-24 18:19:06 +00:00
|
|
|
{
|
2017-10-06 11:10:01 +00:00
|
|
|
init(throw_on_error);
|
2017-08-24 18:19:06 +00:00
|
|
|
}
|
|
|
|
|
2017-10-06 11:10:01 +00:00
|
|
|
std::unique_ptr<IExternalLoadable> ExternalDictionaries::create(
|
2017-10-06 10:31:06 +00:00
|
|
|
const std::string & name, const Configuration & config, const std::string & config_prefix)
|
2015-05-26 11:53:58 +00:00
|
|
|
{
|
2017-10-06 10:31:06 +00:00
|
|
|
return DictionaryFactory::instance().create(name, config, config_prefix, context);
|
2015-05-26 11:53:58 +00:00
|
|
|
}
|
|
|
|
|
2015-01-21 11:39:48 +00:00
|
|
|
}
|