Github user mateiz commented on a diff in the pull request:

    https://github.com/apache/spark/pull/727#discussion_r12511646
  
    --- Diff: core/src/test/scala/org/apache/spark/rdd/RDDSuite.scala ---
    @@ -202,6 +202,39 @@ class RDDSuite extends FunSuite with 
SharedSparkContext {
         assert(repartitioned2.collect().toSet === (1 to 1000).toSet)
       }
     
    +  test("repartitioned RDDs perform load balancing") {
    +    // Coalesce partitions
    +    val input = Array.fill(1000)(1)
    +    val initialPartitions = 10
    +    val data = sc.parallelize(input, initialPartitions)
    +
    +    val repartitioned1 = data.repartition(2)
    +    assert(repartitioned1.partitions.size == 2)
    +    val partitions1 = repartitioned1.glom().collect()
    +    // some noise in balancing is allowed due to randomization
    +    assert(math.abs(partitions1(0).length - 500) < initialPartitions)
    +    assert(math.abs(partitions1(1).length - 500) < initialPartitions)
    +    assert(repartitioned1.collect() === input)
    +
    +    def testSplitPartitions(input: Seq[Int], initialPartitions: Int, 
finalPartitions: Int) {
    +      val data = sc.parallelize(input, initialPartitions)
    +      val repartitioned = data.repartition(finalPartitions)
    +      assert(repartitioned.partitions.size == finalPartitions)
    --- End diff --
    
    Maybe you use `===` here for nicer message


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to