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

Method buildQueryPipeline

src/QueryPlan/QueryPlan.cpp:269–340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267}
268
269QueryPipelinePtr QueryPlan::buildQueryPipeline(
270 const QueryPlanOptimizationSettings & optimization_settings, const BuildQueryPipelineSettings & build_pipeline_settings)
271{
272 checkInitialized();
273
274 if (!optimization_settings.enable_optimizer)
275 {
276 optimize(optimization_settings);
277 }
278
279 struct Frame
280 {
281 Node * node = {};
282 QueryPipelines pipelines = {};
283 };
284
285 QueryPipelinePtr last_pipeline;
286
287 std::stack<Frame> stack;
288 stack.push(Frame{.node = root});
289 Stopwatch watch;
290 while (!stack.empty())
291 {
292 auto & frame = stack.top();
293
294 if (last_pipeline)
295 {
296 frame.pipelines.emplace_back(std::move(last_pipeline));
297 last_pipeline = nullptr; //-V1048
298 }
299
300 size_t next_child = frame.pipelines.size();
301 if (next_child == frame.node->children.size())
302 {
303 bool limit_max_threads = frame.pipelines.empty();
304 try
305 {
306 last_pipeline = frame.node->step->updatePipeline(std::move(frame.pipelines), build_pipeline_settings);
307 updatePipelineStepInfo(last_pipeline, frame.node->step, frame.node->id);
308 }
309 catch (const Exception & e) /// Typical for an incorrect username, password, or address.
310 {
311 LOG_ERROR(log, "Build pipeline error {}", e.what());
312 throw;
313 }
314 // #ifndef NDEBUG
315 // if (optimization_settings.enable_optimizer)
316 // {
317 // const auto & output_header = frame.node->step->getOutputStream().header;
318 // const auto & pipeline_header = last_pipeline->getHeader();
319 // assertBlocksHaveEqualStructure(
320 // output_header,
321 // pipeline_header,
322 // "QueryPlan::buildQueryPipeline for " + frame.node->step->getName() + " (output header, pipeline header)");
323 // }
324 // #endif
325
326 if (limit_max_threads && max_threads)

Callers 12

fillDataMethod · 0.80
initializePipelineMethod · 0.80
executeMethod · 0.80
executeMethod · 0.80
executeMethod · 0.80
explainMethod · 0.80
executeQueryByProxyFunction · 0.80
createForShardMethod · 0.80
executeMethod · 0.80
buildPipelineMethod · 0.80

Calls 10

whatMethod · 0.80
limitMaxThreadsMethod · 0.80
pushMethod · 0.45
emptyMethod · 0.45
emplace_backMethod · 0.45
sizeMethod · 0.45
updatePipelineMethod · 0.45
popMethod · 0.45
addInterpreterContextMethod · 0.45
elapsedMillisecondsMethod · 0.45

Tested by

no test coverage detected