| 1558 | } |
| 1559 | |
| 1560 | std::shared_ptr<BenchmarkContext::Node> BenchmarkContext::parseNode(const std::string & key, const Poco::Util::AbstractConfiguration & config) |
| 1561 | { |
| 1562 | auto node = std::make_shared<BenchmarkContext::Node>(); |
| 1563 | node->name = StringGetter::fromConfig(key + ".name", config); |
| 1564 | |
| 1565 | if (config.has(key + ".data")) |
| 1566 | node->data = StringGetter::fromConfig(key + ".data", config); |
| 1567 | |
| 1568 | if (config.has(key + ".tag")) |
| 1569 | node->tag = config.getString(key + ".tag"); |
| 1570 | |
| 1571 | Poco::Util::AbstractConfiguration::Keys node_keys; |
| 1572 | config.keys(key, node_keys); |
| 1573 | |
| 1574 | for (const auto & node_key : node_keys) |
| 1575 | { |
| 1576 | if (!node_key.starts_with("node")) |
| 1577 | continue; |
| 1578 | |
| 1579 | const auto node_key_string = key + "." + node_key; |
| 1580 | auto child_node = parseNode(node_key_string, config); |
| 1581 | node->children.push_back(child_node); |
| 1582 | |
| 1583 | if (config.has(node_key_string + ".repeat")) |
| 1584 | { |
| 1585 | if (!child_node->name.isRandom()) |
| 1586 | throw DB::Exception(DB::ErrorCodes::BAD_ARGUMENTS, "Repeating node creation for key {}, but name is not randomly generated", node_key_string); |
| 1587 | |
| 1588 | auto repeat_count = config.getUInt64(node_key_string + ".repeat"); |
| 1589 | child_node->repeat_count = repeat_count; |
| 1590 | for (size_t i = 1; i < repeat_count; ++i) |
| 1591 | node->children.push_back(child_node); |
| 1592 | } |
| 1593 | } |
| 1594 | |
| 1595 | return node; |
| 1596 | } |
| 1597 | |
| 1598 | void BenchmarkContext::Node::dumpTree(int level) const |
| 1599 | { |