MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / doIncludesRecursive

Method doIncludesRecursive

src/Common/Config/ConfigProcessor.cpp:424–640  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

422}
423
424void ConfigProcessor::doIncludesRecursive(
425 XMLDocumentPtr config,
426 XMLDocumentPtr include_from,
427 const Substitutions & substitutions,
428 bool throw_on_bad_incl,
429 Poco::XML::DOMParser & dom_parser,
430 const LoggerPtr & log,
431 Node * node,
432 zkutil::ZooKeeperNodeCache * zk_node_cache,
433 const Coordination::EventPtr & zk_changed_event,
434 std::unordered_set<std::string> * contributing_zk_paths)
435{
436 if (node->nodeType() == Node::TEXT_NODE)
437 {
438 for (const auto & substitution : substitutions)
439 {
440 std::string value = node->nodeValue();
441
442 bool replace_occurred = false;
443 size_t pos = 0;
444 while ((pos = value.find(substitution.first)) != std::string::npos)
445 {
446 value.replace(pos, substitution.first.length(), substitution.second);
447 replace_occurred = true;
448 }
449
450 if (replace_occurred)
451 node->setNodeValue(value);
452 }
453 }
454
455 if (node->nodeType() != Node::ELEMENT_NODE)
456 return;
457
458 std::map<std::string, const Node *> attr_nodes;
459 NamedNodeMapPtr attributes = node->attributes();
460 size_t substs_count = 0;
461 for (const auto & attr_name : SUBSTITUTION_ATTRS)
462 {
463 const auto * subst = attributes->getNamedItem(attr_name);
464 attr_nodes[attr_name] = subst;
465 substs_count += static_cast<size_t>(subst != nullptr);
466 }
467
468 if (substs_count > 1) /// only one substitution is allowed
469 throw Poco::Exception("More than one substitution attribute is set for element <" + node->nodeName() + ">");
470
471 if (node->nodeName() == "include")
472 {
473 if (node->hasChildNodes())
474 throw Poco::Exception("<include> element must have no children");
475 if (substs_count == 0)
476 throw Poco::Exception("No substitution attributes set for element <include>, must have exactly one");
477 }
478
479 /// Replace the original contents, not add to it.
480 bool replace = attributes->getNamedItem("replace");
481 /// Merge with the original contents

Callers

nothing calls this directly

Calls 15

nodeNameMethod · 0.80
childNodesMethod · 0.80
importNodeMethod · 0.80
setAttributeNodeMethod · 0.80
getRootNodeFunction · 0.70
ExceptionClass · 0.50
get_nodeFunction · 0.50
nodeTypeMethod · 0.45
findMethod · 0.45
replaceMethod · 0.45
lengthMethod · 0.45
setNodeValueMethod · 0.45

Tested by

no test coverage detected