ClickHouse/src/Interpreters/ExternalDictionariesLoader.cpp

41 lines
1.2 KiB
C++
Raw Normal View History

2019-09-26 11:19:10 +00:00
#include <Interpreters/ExternalDictionariesLoader.h>
#include <Dictionaries/DictionaryFactory.h>
2020-03-03 08:32:58 +00:00
#include "config_core.h"
2019-09-26 11:19:10 +00:00
#if USE_MYSQL
# include <mysqlxx/PoolFactory.h>
#endif
2019-09-26 11:19:10 +00:00
namespace DB
{
/// Must not acquire Context lock in constructor to avoid possibility of deadlocks.
ExternalDictionariesLoader::ExternalDictionariesLoader(Context & context_)
: ExternalLoader("external dictionary", &Logger::get("ExternalDictionariesLoader"))
, context(context_)
2019-09-26 11:19:10 +00:00
{
setConfigSettings({"dictionary", "name", "database"});
2019-09-26 11:19:10 +00:00
enableAsyncLoading(true);
enablePeriodicUpdates(true);
}
ExternalLoader::LoadablePtr ExternalDictionariesLoader::create(
2019-12-11 11:09:21 +00:00
const std::string & name, const Poco::Util::AbstractConfiguration & config,
const std::string & key_in_config, const std::string & repository_name) const
2019-09-26 11:19:10 +00:00
{
2020-01-11 09:50:41 +00:00
/// For dictionaries from databases (created with DDL queries) we have to perform
/// additional checks, so we identify them here.
2019-12-11 11:09:21 +00:00
bool dictionary_from_database = !repository_name.empty();
return DictionaryFactory::instance().create(name, config, key_in_config, context, dictionary_from_database);
2019-09-26 11:19:10 +00:00
}
void ExternalDictionariesLoader::resetAll()
{
#if USE_MYSQL
mysqlxx::PoolFactory::instance().reset();
#endif
}
2019-09-26 11:19:10 +00:00
}