Skip to content

Commit f83d445

Browse files
committed
Move cleaning outside of mapPartitionsWithIndex
1 parent 56d7c92 commit f83d445

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,11 +789,11 @@ abstract class RDD[T: ClassTag](
789789
*/
790790
@deprecated("use mapPartitionsWithIndex and filter", "1.0.0")
791791
def filterWith[A](constructA: Int => A)(p: (T, A) => Boolean): RDD[T] = withScope {
792+
val cleanP = sc.clean(p)
793+
val cleanA = sc.clean(constructA)
792794
mapPartitionsWithIndex((index, iter) => {
793-
/* val cleanP = sc.clean(p)
794-
val cleanA = sc.clean(constructA) */
795-
val a = constructA(index)
796-
iter.filter(t => p(t, a))
795+
val a = cleanA(index)
796+
iter.filter(t => cleanP(t, a))
797797
}, preservesPartitioning = true)
798798
}
799799

core/src/test/scala/org/apache/spark/util/ClosureCleanerSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class ClosureCleanerSuite extends FunSuite {
9595
expectCorrectException { TestUserClosuresActuallyCleaned.testMapPartitionsWithIndex(rdd) }
9696
expectCorrectException { TestUserClosuresActuallyCleaned.testMapPartitionsWithContext(rdd) }
9797
expectCorrectException { TestUserClosuresActuallyCleaned.testFlatMapWith(rdd) }
98-
// expectCorrectException { TestUserClosuresActuallyCleaned.testFilterWith(rdd) }
98+
expectCorrectException { TestUserClosuresActuallyCleaned.testFilterWith(rdd) }
9999
expectCorrectException { TestUserClosuresActuallyCleaned.testForEachWith(rdd) }
100100
expectCorrectException { TestUserClosuresActuallyCleaned.testMapWith(rdd) }
101101
expectCorrectException { TestUserClosuresActuallyCleaned.testZipPartitions2(rdd) }

0 commit comments

Comments
 (0)