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-06 10:31:06 +00:00
|
|
|
const ExternalLoaderUpdateSettings & getExternalDictionariesUpdateSettings()
|
2017-04-01 07:20:54 +00:00
|
|
|
{
|
2017-10-06 10:31:06 +00:00
|
|
|
static ExternalLoaderUpdateSettings 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.check_period_sec = 5;
|
|
|
|
settings.backoff_initial_sec = 5;
|
|
|
|
/// 10 minutes
|
|
|
|
settings.backoff_max_sec = 10 * 60;
|
|
|
|
});
|
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
|
|
|
}
|
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(),
|
|
|
|
getExternalDictionariesUpdateSettings(),
|
|
|
|
getExternalDictionariesConfigSettings(),
|
|
|
|
&Logger::get("ExternalDictionaries"),
|
|
|
|
"external dictionary", throw_on_error),
|
|
|
|
context(context)
|
2017-08-24 18:19:06 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-10-06 10:31:06 +00:00
|
|
|
ExternalDictionaries::LoadablePtr ExternalDictionaries::create(
|
|
|
|
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
|
|
|
}
|