Source:
<code>private JavaPairRDD<Integer, PrestoSparkRow> createIntermediateRdd( JavaSparkContext sparkContext, Session session, PlanFragment fragment, PrestoSparkTaskExecutorFactoryProvider executorFactoryProvider, CollectionAccumulator<SerializedTaskStats> taskStatsCollector, TableWriteInfo tableWriteInfo, Map<PlanFragmentId, JavaPairRDD<Integer, PrestoSparkRow>> rddInputs, Map<PlanFragmentId, Broadcast<List<PrestoSparkSerializedPage>>> broadcastInputs) { checkInputs(fragment.getRemoteSourceNodes(), rddInputs, broadcastInputs); List<TableScanNode> tableScans = findTableScanNodes(fragment.getRoot()); verify(tableScans.isEmpty(), "no table scans is expected"); PrestoSparkTaskDescriptor taskDescriptor = createIntermediateTaskDescriptor(session, tableWriteInfo, fragment); SerializedPrestoSparkTaskDescriptor serializedTaskDescriptor = new SerializedPrestoSparkTaskDescriptor(taskDescriptorJsonCodec.toJsonBytes(taskDescriptor)); if (rddInputs.size() == 0) { checkArgument(fragment.getPartitioning().equals(SINGLE_DISTRIBUTION), "SINGLE_DISTRIBUTION partitioning is expected: %s", fragment.getPartitioning()); return sparkContext.parallelize(ImmutableList.of(serializedTaskDescriptor), 1) .mapPartitionsToPair(createTaskProcessor( executorFactoryProvider, taskStatsCollector, toTaskProcessorBroadcastInputs(broadcastInputs))); } ImmutableList.Builder<String> fragmentIds = ImmutableList.builder(); ImmutableList.Builder<RDD<Tuple2<Integer, PrestoSparkRow>>> rdds = ImmutableList.builder(); <START> for (Entry<PlanFragmentId, JavaPairRDD<Integer, PrestoSparkRow>> input : rddInputs.entrySet()) { <END> fragmentIds.add(input.getKey().toString()); rdds.add(input.getValue().rdd()); } Function<List<Iterator<Tuple2<Integer, PrestoSparkRow>>>, Iterator<Tuple2<Integer, PrestoSparkRow>>> taskProcessor = createTaskProcessor( executorFactoryProvider, serializedTaskDescriptor, fragmentIds.build(), taskStatsCollector, toTaskProcessorBroadcastInputs(broadcastInputs)); return JavaPairRDD.fromRDD( new PrestoSparkZipRdd(sparkContext.sc(), rdds.build(), taskProcessor), classTag(Integer.class), classTag(PrestoSparkRow.class)); }</code><technical_language>nit: I Map.Entry<...></technical_language>

Target:
private JavaPairRDD<Integer, PrestoSparkRow> createIntermediateRdd( JavaSparkContext sparkContext, Session session, PlanFragment fragment, PrestoSparkTaskExecutorFactoryProvider executorFactoryProvider, CollectionAccumulator<SerializedTaskStats> taskStatsCollector, TableWriteInfo tableWriteInfo, Map<PlanFragmentId, JavaPairRDD<Integer, PrestoSparkRow>> rddInputs, Map<PlanFragmentId, Broadcast<List<PrestoSparkSerializedPage>>> broadcastInputs) { checkInputs(fragment.getRemoteSourceNodes(), rddInputs, broadcastInputs); List<TableScanNode> tableScans = findTableScanNodes(fragment.getRoot()); verify(tableScans.isEmpty(), "no table scans is expected"); PrestoSparkTaskDescriptor taskDescriptor = createIntermediateTaskDescriptor(session, tableWriteInfo, fragment); SerializedPrestoSparkTaskDescriptor serializedTaskDescriptor = new SerializedPrestoSparkTaskDescriptor(taskDescriptorJsonCodec.toJsonBytes(taskDescriptor)); if (rddInputs.size() == 0) { checkArgument(fragment.getPartitioning().equals(SINGLE_DISTRIBUTION), "SINGLE_DISTRIBUTION partitioning is expected: %s", fragment.getPartitioning()); return sparkContext.parallelize(ImmutableList.of(serializedTaskDescriptor), 1) .mapPartitionsToPair(createTaskProcessor( executorFactoryProvider, taskStatsCollector, toTaskProcessorBroadcastInputs(broadcastInputs))); } ImmutableList.Builder<String> fragmentIds = ImmutableList.builder(); ImmutableList.Builder<RDD<Tuple2<Integer, PrestoSparkRow>>> rdds = ImmutableList.builder(); for (Map.Entry<PlanFragmentId, JavaPairRDD<Integer, PrestoSparkRow>> input : rddInputs.entrySet()) { fragmentIds.add(input.getKey().toString()); rdds.add(input.getValue().rdd()); } Function<List<Iterator<Tuple2<Integer, PrestoSparkRow>>>, Iterator<Tuple2<Integer, PrestoSparkRow>>> taskProcessor = createTaskProcessor( executorFactoryProvider, serializedTaskDescriptor, fragmentIds.build(), taskStatsCollector, toTaskProcessorBroadcastInputs(broadcastInputs)); return JavaPairRDD.fromRDD( new PrestoSparkZipRdd(sparkContext.sc(), rdds.build(), taskProcessor), classTag(Integer.class), classTag(PrestoSparkRow.class)); }