spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mengxr <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-2568] RangePartitioner should run only ...
Date Sun, 27 Jul 2014 14:32:13 GMT
Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/1562#discussion_r15439509
  
    --- Diff: core/src/test/scala/org/apache/spark/PartitioningSuite.scala ---
    @@ -102,6 +100,34 @@ class PartitioningSuite extends FunSuite with SharedSparkContext
with PrivateMet
         partitioner.getPartition(Row(100))
       }
     
    +  test("RangePartitioner should run only one job if data is roughly balanced") {
    +    val rdd = sc.makeRDD(0 until 20, 20).flatMap { i =>
    +      val random = new java.util.Random(i)
    +      Iterator.fill(5000 * i)((random.nextDouble() + i, i))
    +    }.cache()
    +    for (numPartitions <- Seq(10, 20, 40)) {
    +      val partitioner = new RangePartitioner(numPartitions, rdd)
    +      assert(partitioner.numPartitions === numPartitions)
    +      assert(partitioner.singlePass === true)
    +      val counts = rdd.keys.map(key => partitioner.getPartition(key)).countByValue().values
    +      assert(counts.max < 2.0 * counts.min)
    +    }
    +  }
    +
    +  test("RangePartitioner should work well on unbalanced data") {
    +    val rdd = sc.makeRDD(0 until 20, 20).flatMap { i =>
    +      val random = new java.util.Random(i)
    +      Iterator.fill(20 * i * i * i)((random.nextDouble() + i, i))
    +    }.cache()
    +    for (numPartitions <- Seq(2, 4, 8)) {
    +      val partitioner = new RangePartitioner(numPartitions, rdd)
    +      assert(partitioner.numPartitions === numPartitions)
    +      assert(partitioner.singlePass === false)
    +      val counts = rdd.keys.map(key => partitioner.getPartition(key)).countByValue().values
    +      assert(counts.max < 2.0 * counts.min)
    +    }
    +  }
    +
    --- End diff --
    
    The first partition in this test contains 0 elements. I will add a test where the whole
RDD has 0 elements.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message