| 24 | #endif |
| 25 | |
| 26 | std::unique_ptr<main::QueryResult> QueryProcessor::execute(PhysicalPlan* physicalPlan, |
| 27 | ExecutionContext* context) { |
| 28 | context->clientContext->registerQueryStart(); |
| 29 | struct Guard { |
| 30 | main::ClientContext* ctx; |
| 31 | ~Guard() { ctx->registerQueryEnd(); } |
| 32 | } guard{context->clientContext}; |
| 33 | auto lastOperator = physicalPlan->lastOperator.get(); |
| 34 | // The root pipeline(task) consists of operators and its prevOperator only, because we |
| 35 | // expect to have linear plans. For binary operators, e.g., HashJoin, we keep probe and its |
| 36 | // prevOperator in the same pipeline, and decompose build and its prevOperator into another |
| 37 | // one. |
| 38 | auto sink = lastOperator->ptrCast<Sink>(); |
| 39 | auto task = std::make_shared<ProcessorTask>(sink, context); |
| 40 | for (auto i = (int64_t)sink->getNumChildren() - 1; i >= 0; --i) { |
| 41 | decomposePlanIntoTask(sink->getChild(i), task.get(), context); |
| 42 | } |
| 43 | initTask(task.get()); |
| 44 | auto progressBar = ProgressBar::Get(*context->clientContext); |
| 45 | progressBar->startProgress(context->queryID); |
| 46 | taskScheduler->scheduleTaskAndWaitOrError(task, context); |
| 47 | progressBar->endProgress(context->queryID); |
| 48 | return sink->getQueryResult(); |
| 49 | } |
| 50 | |
| 51 | void QueryProcessor::decomposePlanIntoTask(PhysicalOperator* op, Task* task, |
| 52 | ExecutionContext* context) { |
no test coverage detected