Github user mateiz commented on a diff in the pull request:
https://github.com/apache/spark/pull/727#discussion_r12511628
--- Diff: core/src/main/scala/org/apache/spark/rdd/RDD.scala ---
@@ -328,11 +328,20 @@ abstract class RDD[T: ClassTag](
def coalesce(numPartitions: Int, shuffle: Boolean = false)(implicit ord:
Ordering[T] = null)
: RDD[T] = {
if (shuffle) {
+ /** Distributes elements evenly across output partitions, starting
from a random partition. */
+ def distributePartition(index: Int, items: Iterator[T]):
Iterator[(Int, T)] = {
+ var position = (new Random(index)).nextInt(numPartitions)
+ items.map{ t =>
+ position = position + 1 % numPartitions
--- End diff --
This is going to mod the 1 with numPartitions and keep increasing
`position`, probably not exactly what we want. In reality passing just
`position` as the key would be fine, because the hashCode for it will be
position as well, and the Partitioner will mod that with `numPartitions`. No
need to mod twice.
---
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.
---