Search in sources :

Example 1 with DistributedExecutionPlanner

use of com.facebook.presto.sql.planner.DistributedExecutionPlanner in project presto by prestodb.

the class SqlQueryExecution method planDistribution.

private void planDistribution(PlanRoot plan) {
    // time distribution planning
    long distributedPlanningStart = System.nanoTime();
    // plan the execution on the active nodes
    DistributedExecutionPlanner distributedPlanner = new DistributedExecutionPlanner(splitManager);
    StageExecutionPlan outputStageExecutionPlan = distributedPlanner.plan(plan.getRoot(), stateMachine.getSession());
    stateMachine.recordDistributedPlanningTime(distributedPlanningStart);
    // ensure split sources are closed
    stateMachine.addStateChangeListener(state -> {
        if (state.isDone()) {
            closeSplitSources(outputStageExecutionPlan);
        }
    });
    // if query was canceled, skip creating scheduler
    if (stateMachine.isDone()) {
        return;
    }
    // record field names
    stateMachine.setOutputFieldNames(outputStageExecutionPlan.getFieldNames());
    PartitioningHandle partitioningHandle = plan.getRoot().getFragment().getPartitioningScheme().getPartitioning().getHandle();
    OutputBuffers rootOutputBuffers = createInitialEmptyOutputBuffers(partitioningHandle).withBuffer(OUTPUT_BUFFER_ID, BROADCAST_PARTITION_ID).withNoMoreBufferIds();
    // build the stage execution objects (this doesn't schedule execution)
    SqlQueryScheduler scheduler = new SqlQueryScheduler(stateMachine, locationFactory, outputStageExecutionPlan, nodePartitioningManager, nodeScheduler, remoteTaskFactory, stateMachine.getSession(), plan.isSummarizeTaskInfos(), scheduleSplitBatchSize, queryExecutor, rootOutputBuffers, nodeTaskMap, executionPolicy, schedulerStats);
    queryScheduler.set(scheduler);
    // directly since the callback may have already fired
    if (stateMachine.isDone()) {
        scheduler.abort();
        queryScheduler.set(null);
    }
}
Also used : OutputBuffers(com.facebook.presto.OutputBuffers) OutputBuffers.createInitialEmptyOutputBuffers(com.facebook.presto.OutputBuffers.createInitialEmptyOutputBuffers) StageExecutionPlan(com.facebook.presto.sql.planner.StageExecutionPlan) SqlQueryScheduler(com.facebook.presto.execution.scheduler.SqlQueryScheduler) PartitioningHandle(com.facebook.presto.sql.planner.PartitioningHandle) DistributedExecutionPlanner(com.facebook.presto.sql.planner.DistributedExecutionPlanner)

Aggregations

OutputBuffers (com.facebook.presto.OutputBuffers)1 OutputBuffers.createInitialEmptyOutputBuffers (com.facebook.presto.OutputBuffers.createInitialEmptyOutputBuffers)1 SqlQueryScheduler (com.facebook.presto.execution.scheduler.SqlQueryScheduler)1 DistributedExecutionPlanner (com.facebook.presto.sql.planner.DistributedExecutionPlanner)1 PartitioningHandle (com.facebook.presto.sql.planner.PartitioningHandle)1 StageExecutionPlan (com.facebook.presto.sql.planner.StageExecutionPlan)1