Skip to content

Commit 8ec8f24

Browse files
committed
Make to local iterator shorter
1 parent 34aa300 commit 8ec8f24

File tree

1 file changed

+1
-7
lines changed
  • core/src/main/scala/org/apache/spark/rdd

1 file changed

+1
-7
lines changed

core/src/main/scala/org/apache/spark/rdd/RDD.scala

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -672,13 +672,7 @@ abstract class RDD[T: ClassTag](
672672
def collectPartition(p: Int): Array[T] = {
673673
sc.runJob(this, (iter: Iterator[T]) => iter.toArray, Seq(p), allowLocal = false).head
674674
}
675-
var buffer = Stream.empty[T]
676-
for (p <- 0 until this.partitions.length) {
677-
buffer = buffer append {
678-
collectPartition(p).toStream
679-
}
680-
}
681-
buffer.iterator
675+
(0 until partitions.length).iterator.flatMap(i => collectPartition(i))
682676
}
683677

684678
/**

0 commit comments

Comments
 (0)