Search in sources :

Example 6 with TaskSource

use of com.facebook.presto.TaskSource in project presto by prestodb.

the class SqlTaskExecution method schedulePartitionedSource.

private synchronized void schedulePartitionedSource(TaskSource source) {
    // when the source is scheduled
    if (!isSchedulingSource(source.getPlanNodeId())) {
        pendingSplits.merge(source.getPlanNodeId(), source, TaskSource::update);
        return;
    }
    DriverSplitRunnerFactory partitionedDriverFactory = partitionedDriverFactories.get(source.getPlanNodeId());
    ImmutableList.Builder<DriverSplitRunner> runners = ImmutableList.builder();
    for (ScheduledSplit scheduledSplit : source.getSplits()) {
        // create a new driver for the split
        runners.add(partitionedDriverFactory.createDriverRunner(scheduledSplit, true));
    }
    enqueueDrivers(false, runners.build());
    if (source.isNoMoreSplits()) {
        partitionedDriverFactory.setNoMoreSplits();
        sourceStartOrder.remove(source.getPlanNodeId());
        // schedule next source
        if (!sourceStartOrder.isEmpty()) {
            TaskSource nextSource = pendingSplits.get(sourceStartOrder.peek());
            if (nextSource != null) {
                schedulePartitionedSource(nextSource);
            }
        }
    }
}
Also used : ScheduledSplit(com.facebook.presto.ScheduledSplit) ImmutableList(com.google.common.collect.ImmutableList) TaskSource(com.facebook.presto.TaskSource)

Example 7 with TaskSource

use of com.facebook.presto.TaskSource in project presto by prestodb.

the class SqlTaskExecution method scheduleUnpartitionedSource.

private synchronized void scheduleUnpartitionedSource(TaskSource source, Map<PlanNodeId, TaskSource> updatedUnpartitionedSources) {
    // create new source
    TaskSource newSource;
    TaskSource currentSource = unpartitionedSources.get(source.getPlanNodeId());
    if (currentSource == null) {
        newSource = source;
    } else {
        newSource = currentSource.update(source);
    }
    // only record new source if something changed
    if (newSource != currentSource) {
        unpartitionedSources.put(source.getPlanNodeId(), newSource);
        updatedUnpartitionedSources.put(source.getPlanNodeId(), newSource);
    }
}
Also used : TaskSource(com.facebook.presto.TaskSource)

Aggregations

TaskSource (com.facebook.presto.TaskSource)7 ScheduledSplit (com.facebook.presto.ScheduledSplit)5 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)4 Split (com.facebook.presto.metadata.Split)3 Duration (io.airlift.units.Duration)3 Test (org.testng.annotations.Test)3 Session (com.facebook.presto.Session)2 Driver (com.facebook.presto.operator.Driver)2 DriverContext (com.facebook.presto.operator.DriverContext)2 DriverFactory (com.facebook.presto.operator.DriverFactory)2 ColumnHandle (com.facebook.presto.spi.ColumnHandle)2 ConnectorPageSource (com.facebook.presto.spi.ConnectorPageSource)2 ConnectorSplit (com.facebook.presto.spi.ConnectorSplit)2 FixedPageSource (com.facebook.presto.spi.FixedPageSource)2 Type (com.facebook.presto.spi.type.Type)2 PageSourceProvider (com.facebook.presto.split.PageSourceProvider)2 LocalExecutionPlanner (com.facebook.presto.sql.planner.LocalExecutionPlanner)2 LocalExecutionPlan (com.facebook.presto.sql.planner.LocalExecutionPlanner.LocalExecutionPlan)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 ArrayList (java.util.ArrayList)2