Skip to content

Commit 0c8d47e

Browse files
committed
Add test for mapWith()
1 parent 6846e40 commit 0c8d47e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class ClosureCleanerSuite extends FunSuite {
9393
expectCorrectException { TestUserClosuresActuallyCleaned.testMapPartitions(rdd) }
9494
expectCorrectException { TestUserClosuresActuallyCleaned.testMapPartitionsWithIndex(rdd) }
9595
expectCorrectException { TestUserClosuresActuallyCleaned.testFlatMapWith(rdd) }
96+
expectCorrectException { TestUserClosuresActuallyCleaned.testMapWith(rdd) }
9697
expectCorrectException { TestUserClosuresActuallyCleaned.testZipPartitions2(rdd) }
9798
expectCorrectException { TestUserClosuresActuallyCleaned.testZipPartitions3(rdd) }
9899
expectCorrectException { TestUserClosuresActuallyCleaned.testZipPartitions4(rdd) }
@@ -269,7 +270,12 @@ private object TestUserClosuresActuallyCleaned {
269270
val random = prng.nextDouble()
270271
Seq(random * t, random * t * 10)}.
271272
count()
272-
rdd.mapPartitionsWithIndex { (_, it) => return; it }.count()
273+
}
274+
def testMapWith(rdd: RDD[Int]): Unit = {
275+
import java.util.Random
276+
val randoms = rdd.mapWith(
277+
(index: Int) => new Random(index + 42))
278+
{(t: Int, prng: Random) => prng.nextDouble * t}.count()
273279
}
274280
def testZipPartitions2(rdd: RDD[Int]): Unit = {
275281
rdd.zipPartitions(rdd) { case (it1, it2) => return; it1 }.count()

0 commit comments

Comments
 (0)