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

Method buildQueryPipeline

src/Processors/QueryPlan/QueryPlan.cpp:218–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218QueryPipelineBuilderPtr QueryPlan::buildQueryPipeline(
219 const QueryPlanOptimizationSettings & optimization_settings,
220 const BuildQueryPipelineSettings & build_pipeline_settings,
221 bool do_optimize)
222{
223 checkInitialized();
224 if (do_optimize)
225 optimize(optimization_settings);
226
227 if (optimization_settings.make_distributed_plan)
228 convertToDistributed(optimization_settings);
229
230 struct Frame
231 {
232 Node * node = {};
233 QueryPipelineBuilders pipelines = {};
234 };
235
236 QueryPipelineBuilderPtr last_pipeline;
237
238 std::stack<Frame> stack;
239 stack.push(Frame{.node = root});
240
241 while (!stack.empty())
242 {
243 auto & frame = stack.top();
244
245 if (last_pipeline)
246 {
247 frame.pipelines.emplace_back(std::move(last_pipeline));
248 last_pipeline = nullptr;
249 }
250
251 size_t next_child = frame.pipelines.size();
252 if (next_child == frame.node->children.size())
253 {
254 bool limit_max_threads = frame.pipelines.empty();
255 last_pipeline = frame.node->step->updatePipeline(std::move(frame.pipelines), build_pipeline_settings);
256
257 if (limit_max_threads && max_threads)
258 last_pipeline->limitMaxThreads(max_threads);
259
260 stack.pop();
261 }
262 else
263 stack.push(Frame{.node = frame.node->children[next_child]});
264 }
265
266 last_pipeline->setProgressCallback(build_pipeline_settings.progress_callback);
267 last_pipeline->setProcessListElement(build_pipeline_settings.process_list_element);
268 last_pipeline->addResources(resources);
269 last_pipeline->setConcurrencyControl(getConcurrencyControl());
270
271 return last_pipeline;
272}
273
274static void explainStep(const IQueryPlanStep & step, JSONBuilder::JSONMap & map, const ExplainPlanOptions & options)
275{

Callers 15

readImplMethod · 0.45
calculateByQueryMethod · 0.45
buildPipelineMethod · 0.45
executeSubqueryNodeFunction · 0.45
createMergedStreamMethod · 0.45
getNewBlocksMethod · 0.45
writeIntoWindowViewMethod · 0.45
readDataFunction · 0.45
buildStepExecutorMethod · 0.45
workMethod · 0.45

Calls 13

checkInitializedFunction · 0.85
limitMaxThreadsMethod · 0.80
optimizeFunction · 0.50
pushMethod · 0.45
emptyMethod · 0.45
emplace_backMethod · 0.45
sizeMethod · 0.45
updatePipelineMethod · 0.45
popMethod · 0.45
setProgressCallbackMethod · 0.45
setProcessListElementMethod · 0.45
addResourcesMethod · 0.45

Tested by 1

readDataFunction · 0.36