Source:
<code>private SqlQueryScheduler( QueryStateMachine queryStateMachine, LocationFactory locationFactory, SubPlan plan, NodePartitioningManager nodePartitioningManager, NodeScheduler nodeScheduler, RemoteTaskFactory remoteTaskFactory, SplitSourceFactory splitSourceFactory, Session session, boolean summarizeTaskInfo, int splitBatchSize, ExecutorService queryExecutor, ScheduledExecutorService schedulerExecutor, FailureDetector failureDetector, OutputBuffers rootOutputBuffers, NodeTaskMap nodeTaskMap, ExecutionPolicy executionPolicy, SplitSchedulerStats schedulerStats, Metadata metadata) { this.queryStateMachine = requireNonNull(queryStateMachine, "queryStateMachine is null"); this.locationFactory = requireNonNull(locationFactory, "locationFactory is null"); this.plan = requireNonNull(plan, "plan is null"); this.executionPolicy = requireNonNull(executionPolicy, "schedulerPolicyFactory is null"); this.schedulerStats = requireNonNull(schedulerStats, "schedulerStats is null"); this.summarizeTaskInfo = summarizeTaskInfo; OutputBufferId rootBufferId = getOnlyElement(rootOutputBuffers.getBuffers().keySet()); sectionedPlan = extractStreamingSections(plan); List<SqlStageExecutionInfo> stageExecutions = createStageExecutions( (fragmentId, tasks, noMoreExchangeLocations) -> updateQueryOutputLocations(queryStateMachine, rootBufferId, tasks, noMoreExchangeLocations), sectionedPlan, Optional.of(new int[1]), metadata, rootOutputBuffers, nodeScheduler, remoteTaskFactory, splitSourceFactory, session, splitBatchSize, nodePartitioningManager, queryExecutor, schedulerExecutor, failureDetector, nodeTaskMap); <START> this.rootStageId = stageExecutions.get(stageExecutions.size() - 1).getStageExecution().getStageExecutionId().getStageId(); <END> this.stageExecutions = stageExecutions.stream() .collect(toImmutableMap(execution -> execution.getStageExecution().getStageExecutionId().getStageId(), identity())); this.executor = queryExecutor; this.maxConcurrentMaterializations = getMaxConcurrentMaterializations(session); }</code><technical_language>nit: Iterables.getLast(stageExecutions) slightly better? . ditto for other x.get(x.size() - 1)</technical_language>

Target:
private SqlQueryScheduler( QueryStateMachine queryStateMachine, LocationFactory locationFactory, SubPlan plan, NodePartitioningManager nodePartitioningManager, NodeScheduler nodeScheduler, RemoteTaskFactory remoteTaskFactory, SplitSourceFactory splitSourceFactory, Session session, boolean summarizeTaskInfo, int splitBatchSize, ExecutorService queryExecutor, ScheduledExecutorService schedulerExecutor, FailureDetector failureDetector, OutputBuffers rootOutputBuffers, NodeTaskMap nodeTaskMap, ExecutionPolicy executionPolicy, SplitSchedulerStats schedulerStats, Metadata metadata) { this.queryStateMachine = requireNonNull(queryStateMachine, "queryStateMachine is null"); this.locationFactory = requireNonNull(locationFactory, "locationFactory is null"); this.plan = requireNonNull(plan, "plan is null"); this.executionPolicy = requireNonNull(executionPolicy, "schedulerPolicyFactory is null"); this.schedulerStats = requireNonNull(schedulerStats, "schedulerStats is null"); this.summarizeTaskInfo = summarizeTaskInfo; OutputBufferId rootBufferId = getOnlyElement(rootOutputBuffers.getBuffers().keySet()); sectionedPlan = extractStreamingSections(plan); List<StageExecutionAndScheduler> stageExecutions = createStageExecutions( (fragmentId, tasks, noMoreExchangeLocations) -> updateQueryOutputLocations(queryStateMachine, rootBufferId, tasks, noMoreExchangeLocations), sectionedPlan, Optional.of(new int[1]), metadata, rootOutputBuffers, nodeScheduler, remoteTaskFactory, splitSourceFactory, session, splitBatchSize, nodePartitioningManager, queryExecutor, schedulerExecutor, failureDetector, nodeTaskMap); this.rootStageId = Iterables.getLast(stageExecutions).getStageExecution().getStageExecutionId().getStageId(); this.stageExecutions = stageExecutions.stream() .collect(toImmutableMap(execution -> execution.getStageExecution().getStageExecutionId().getStageId(), identity())); this.executor = queryExecutor; this.maxConcurrentMaterializations = getMaxConcurrentMaterializations(session); }