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

Function buildTreeOffset

src/Processors/QueryPlan/QueryPlan.cpp:541–583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539};
540
541static void buildTreeOffset(
542 const std::deque<ExplainPlan::Frame> & frames,
543 const ExplainPlan::Frame & current,
544 IQueryPlanStep::FormatSettings & settings_format,
545 const std::string & parent_tree_prefix = "",
546 bool is_last_child_plan = true)
547{
548 if (frames.empty())
549 throw Exception(ErrorCodes::LOGICAL_ERROR, "Frames stack for building tree offset cannot be empty");
550
551 settings_format.header_prefix = parent_tree_prefix;
552 settings_format.detail_prefix = parent_tree_prefix;
553
554 bool has_children = !current.node->children.empty() || !current.node->step->getChildPlans().empty();
555
556 if (frames.size() == 1)
557 {
558 if (!parent_tree_prefix.empty())
559 {
560 settings_format.header_prefix += is_last_child_plan ? "└──" : "├──";
561 settings_format.detail_prefix += is_last_child_plan ? " " : "│ ";
562 }
563 settings_format.detail_prefix += has_children ? "│ " : " ";
564 return;
565 }
566
567 if (!parent_tree_prefix.empty())
568 {
569 settings_format.header_prefix += is_last_child_plan ? " " : "│ ";
570 settings_format.detail_prefix += is_last_child_plan ? " " : "│ ";
571 }
572
573 for (size_t i = 0; i < frames.size() - 2; ++i)
574 {
575 const auto & segment = frames[i + 1].is_last_child ? " " : "│ ";
576 settings_format.header_prefix += segment;
577 settings_format.detail_prefix += segment;
578 }
579
580 settings_format.header_prefix += current.is_last_child ? "└──" : "├──";
581 settings_format.detail_prefix += current.is_last_child ? " " : "│ ";
582 settings_format.detail_prefix += has_children ? "│ " : " ";
583}
584
585static void buildIndentOffset(const std::deque<ExplainPlan::Frame> & frames, IQueryPlanStep::FormatSettings & settings_format, size_t indent_offset)
586{

Callers 1

explainPlanMethod · 0.85

Calls 4

ExceptionClass · 0.50
emptyMethod · 0.45
getChildPlansMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected