LocalExecutionPlan localExecutionPlan = planner.plan(session, fragment.getRoot(), fragment.getSymbols(), new TaskOutputFactory(sharedBuffer));
List<DriverFactory> driverFactories = localExecutionPlan.getDriverFactories();
// index driver factories
DriverFactory partitionedDriverFactory = null;
List<Driver> unpartitionedDrivers = new ArrayList<>();
for (DriverFactory driverFactory : driverFactories) {
if (driverFactory.getSourceIds().contains(fragment.getPartitionedSource())) {
partitionedDriverFactory = driverFactory;
}
else {
PipelineContext pipelineContext = taskContext.addPipelineContext(driverFactory.isInputDriver(), driverFactory.isOutputDriver());
Driver driver = driverFactory.createDriver(pipelineContext.addDriverContext());
unpartitionedDrivers.add(driver);
}
}
this.unpartitionedDrivers = ImmutableList.copyOf(unpartitionedDrivers);
if (fragment.getDistribution() == PlanDistribution.SOURCE) {
checkArgument(partitionedDriverFactory != null, "Fragment is partitioned, but no partitioned driver found");
this.partitionedSourceId = fragment.getPartitionedSource();
this.partitionedDriverFactory = partitionedDriverFactory;
this.partitionedPipelineContext = taskContext.addPipelineContext(partitionedDriverFactory.isInputDriver(), partitionedDriverFactory.isOutputDriver());
}
else {
this.partitionedSourceId = null;
this.partitionedDriverFactory = null;
this.partitionedPipelineContext = null;