Skip to content

Commit f9da752

Browse files
committed
Response to Matei's feedback
1 parent acfa46a commit f9da752

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

core/src/main/scala/org/apache/spark/rdd/RDD.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

core/src/test/scala/org/apache/spark/rdd/RDDSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)