| 44 | } |
| 45 | |
| 46 | DictionaryPtr DictionaryFactory::create( |
| 47 | const std::string & name, |
| 48 | const Poco::Util::AbstractConfiguration & config, |
| 49 | const std::string & config_prefix, |
| 50 | ContextPtr global_context, |
| 51 | bool created_from_ddl) const |
| 52 | { |
| 53 | Poco::Util::AbstractConfiguration::Keys keys; |
| 54 | const auto & layout_prefix = config_prefix + ".layout"; |
| 55 | config.keys(layout_prefix, keys); |
| 56 | if (keys.size() != 1) |
| 57 | throw Exception(ErrorCodes::EXCESSIVE_ELEMENT_IN_CONFIG, |
| 58 | "{}: element dictionary.layout should have exactly one child element", |
| 59 | name); |
| 60 | |
| 61 | const DictionaryStructure dict_struct{config, config_prefix}; |
| 62 | |
| 63 | DictionarySourcePtr source_ptr = DictionarySourceFactory::instance().create( |
| 64 | name, config, config_prefix + ".source", dict_struct, global_context, config.getString(config_prefix + ".database", ""), created_from_ddl); |
| 65 | LOG_TRACE(getLogger("DictionaryFactory"), "Created dictionary source '{}' for dictionary '{}'", source_ptr->toString(), name); |
| 66 | |
| 67 | const auto & layout_type = keys.front(); |
| 68 | |
| 69 | { |
| 70 | const auto found = registered_layouts.find(layout_type); |
| 71 | if (found != registered_layouts.end()) |
| 72 | { |
| 73 | const auto & layout_creator = found->second.layout_create_function; |
| 74 | return layout_creator(name, dict_struct, config, config_prefix, std::move(source_ptr), global_context, created_from_ddl); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | throw Exception(ErrorCodes::UNKNOWN_ELEMENT_IN_CONFIG, |
| 79 | "{}: unknown dictionary layout type: {}", |
| 80 | name, |
| 81 | layout_type); |
| 82 | } |
| 83 | |
| 84 | bool DictionaryFactory::isComplex(const std::string & layout_type) const |
| 85 | { |
no test coverage detected