Skip to content

Commit

Permalink
Add test for mapWith()
Browse files Browse the repository at this point in the history
  • Loading branch information
tedyu committed May 7, 2015
1 parent 6846e40 commit 0c8d47e
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class ClosureCleanerSuite extends FunSuite {
expectCorrectException { TestUserClosuresActuallyCleaned.testMapPartitions(rdd) }
expectCorrectException { TestUserClosuresActuallyCleaned.testMapPartitionsWithIndex(rdd) }
expectCorrectException { TestUserClosuresActuallyCleaned.testFlatMapWith(rdd) }
expectCorrectException { TestUserClosuresActuallyCleaned.testMapWith(rdd) }
expectCorrectException { TestUserClosuresActuallyCleaned.testZipPartitions2(rdd) }
expectCorrectException { TestUserClosuresActuallyCleaned.testZipPartitions3(rdd) }
expectCorrectException { TestUserClosuresActuallyCleaned.testZipPartitions4(rdd) }
Expand Down Expand Up @@ -269,7 +270,12 @@ private object TestUserClosuresActuallyCleaned {
val random = prng.nextDouble()
Seq(random * t, random * t * 10)}.
count()
rdd.mapPartitionsWithIndex { (_, it) => return; it }.count()
}
def testMapWith(rdd: RDD[Int]): Unit = {
import java.util.Random
val randoms = rdd.mapWith(
(index: Int) => new Random(index + 42))
{(t: Int, prng: Random) => prng.nextDouble * t}.count()
}
def testZipPartitions2(rdd: RDD[Int]): Unit = {
rdd.zipPartitions(rdd) { case (it1, it2) => return; it1 }.count()
Expand Down

0 comments on commit 0c8d47e

Please sign in to comment.