MCPcopy Create free account
hub / github.com/ByConity/ByConity / getSubPlan

Method getSubPlan

src/QueryPlan/QueryPlan.cpp:240–267  ·  view source on GitHub ↗

* Be careful, after we create a sub_plan, some nodes in the original plan have been deleted and deconstructed. * More precisely, nodes that moved to sub_plan are deleted. */

Source from the content-addressed store, hash-verified

238 * More precisely, nodes that moved to sub_plan are deleted.
239 */
240QueryPlan QueryPlan::getSubPlan(QueryPlan::Node * node_)
241{
242 QueryPlan sub_plan;
243
244 std::stack<QueryPlan::Node *> plan_nodes;
245 sub_plan.addRoot(Node{.step = node_->step, .children = node_->children, .id = node_->id});
246 plan_nodes.push(sub_plan.getRoot());
247 sub_plan.setResetStepId(reset_step_id);
248
249 while (!plan_nodes.empty())
250 {
251 auto current = plan_nodes.top();
252 plan_nodes.pop();
253
254 std::vector<Node *> result_children;
255 for (auto & child : current->children)
256 {
257 sub_plan.addNode(Node{.step = child->step, .children = child->children, .id = child->id});
258 result_children.push_back(sub_plan.getLastNode());
259 plan_nodes.push(sub_plan.getLastNode());
260 }
261 current->children.swap(result_children);
262 }
263
264 freshPlan();
265
266 return sub_plan;
267}
268
269QueryPipelinePtr QueryPlan::buildQueryPipeline(
270 const QueryPlanOptimizationSettings & optimization_settings, const BuildQueryPipelineSettings & build_pipeline_settings)

Callers 1

createPlanSegmentMethod · 0.80

Calls 10

addRootMethod · 0.80
setResetStepIdMethod · 0.80
pushMethod · 0.45
getRootMethod · 0.45
emptyMethod · 0.45
popMethod · 0.45
addNodeMethod · 0.45
push_backMethod · 0.45
getLastNodeMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected