| 1 | #include <Interpreters/ExternalDictionariesLoader.h> |
| 2 | #include <Dictionaries/DictionaryFactory.h> |
| 3 | |
| 4 | namespace DB |
| 5 | { |
| 6 | |
| 7 | /// Must not acquire Context lock in constructor to avoid possibility of deadlocks. |
| 8 | ExternalDictionariesLoader::ExternalDictionariesLoader(Context & context_) |
| 9 | : ExternalLoader("external dictionary" , &Logger::get("ExternalDictionariesLoader" )) |
| 10 | , context(context_) |
| 11 | { |
| 12 | setConfigSettings({"dictionary" , "name" , "database" }); |
| 13 | enableAsyncLoading(true); |
| 14 | enablePeriodicUpdates(true); |
| 15 | } |
| 16 | |
| 17 | |
| 18 | ExternalLoader::LoadablePtr ExternalDictionariesLoader::create( |
| 19 | const std::string & name, const Poco::Util::AbstractConfiguration & config, |
| 20 | const std::string & key_in_config, const std::string & repository_name) const |
| 21 | { |
| 22 | /// For dictionaries from databases (created with DDL qureies) we have to perform |
| 23 | /// additional checks, so we identify them here. |
| 24 | bool dictionary_from_database = !repository_name.empty(); |
| 25 | return DictionaryFactory::instance().create(name, config, key_in_config, context, dictionary_from_database); |
| 26 | } |
| 27 | } |
| 28 | |