File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
main/scala/org/apache/spark/rdd
test/scala/org/apache/spark/rdd Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -331,8 +331,10 @@ abstract class RDD[T: ClassTag](
331331 /** Distributes elements evenly across output partitions, starting from a random partition. */
332332 def distributePartition (index : Int , items : Iterator [T ]): Iterator [(Int , T )] = {
333333 var position = (new Random (index)).nextInt(numPartitions)
334- items.map{ t =>
335- position = position + 1 % numPartitions
334+ items.map { t =>
335+ // Note that the hash code of the key will just be the key itself. The HashPartitioner
336+ // will mod it with the number of total partitions.
337+ position = position + 1
336338 (position, t)
337339 }
338340 }
Original file line number Diff line number Diff line change @@ -219,7 +219,7 @@ class RDDSuite extends FunSuite with SharedSparkContext {
219219 def testSplitPartitions (input : Seq [Int ], initialPartitions : Int , finalPartitions : Int ) {
220220 val data = sc.parallelize(input, initialPartitions)
221221 val repartitioned = data.repartition(finalPartitions)
222- assert(repartitioned.partitions.size == finalPartitions)
222+ assert(repartitioned.partitions.size === finalPartitions)
223223 val partitions = repartitioned.glom().collect()
224224 // assert all elements are present
225225 assert(repartitioned.collect().sortWith(_ > _).toSeq === input.toSeq.sortWith(_ > _).toSeq)
You can’t perform that action at this time.
0 commit comments