diff options
author | Reynold Xin <rxin@apache.org> | 2014-07-25 01:10:05 -0700 |
---|---|---|
committer | Reynold Xin <rxin@apache.org> | 2014-07-25 01:10:05 -0700 |
commit | eb82abd8e3d25c912fa75201cf4f429aab8d73c7 (patch) | |
tree | 2571f03b5a22d72deea51e54f247dcf41a256952 /core/src/main | |
parent | 8529ced35c6b77a384d10a26b654a8073d57e03d (diff) | |
download | spark-eb82abd8e3d25c912fa75201cf4f429aab8d73c7.tar.gz spark-eb82abd8e3d25c912fa75201cf4f429aab8d73c7.tar.bz2 spark-eb82abd8e3d25c912fa75201cf4f429aab8d73c7.zip |
[SPARK-2529] Clean closures in foreach and foreachPartition.
Author: Reynold Xin <rxin@apache.org>
Closes #1583 from rxin/closureClean and squashes the following commits:
8982fe6 [Reynold Xin] [SPARK-2529] Clean closures in foreach and foreachPartition.
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/scala/org/apache/spark/rdd/RDD.scala | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/core/src/main/scala/org/apache/spark/rdd/RDD.scala b/core/src/main/scala/org/apache/spark/rdd/RDD.scala index edbf7eace9..b1c965a790 100644 --- a/core/src/main/scala/org/apache/spark/rdd/RDD.scala +++ b/core/src/main/scala/org/apache/spark/rdd/RDD.scala @@ -754,14 +754,16 @@ abstract class RDD[T: ClassTag]( * Applies a function f to all elements of this RDD. */ def foreach(f: T => Unit) { - sc.runJob(this, (iter: Iterator[T]) => iter.foreach(f)) + val cleanF = sc.clean(f) + sc.runJob(this, (iter: Iterator[T]) => iter.foreach(cleanF)) } /** * Applies a function f to each partition of this RDD. */ def foreachPartition(f: Iterator[T] => Unit) { - sc.runJob(this, (iter: Iterator[T]) => f(iter)) + val cleanF = sc.clean(f) + sc.runJob(this, (iter: Iterator[T]) => cleanF(iter)) } /** |