You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by rx...@apache.org on 2013/10/25 02:08:52 UTC
[4/6] git commit: Always use a shuffle
Always use a shuffle
Project: http://git-wip-us.apache.org/repos/asf/incubator-spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spark/commit/2fda84fe
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spark/tree/2fda84fe
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spark/diff/2fda84fe
Branch: refs/heads/master
Commit: 2fda84fe3ffa4d887e58b4d1717765a42a30b0f9
Parents: 08c1a42
Author: Patrick Wendell <pw...@gmail.com>
Authored: Thu Oct 24 10:52:25 2013 -0700
Committer: Patrick Wendell <pw...@gmail.com>
Committed: Thu Oct 24 14:31:34 2013 -0700
----------------------------------------------------------------------
.../main/scala/org/apache/spark/rdd/RDD.scala | 22 +++++++-------------
1 file changed, 7 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-spark/blob/2fda84fe/core/src/main/scala/org/apache/spark/rdd/RDD.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/org/apache/spark/rdd/RDD.scala b/core/src/main/scala/org/apache/spark/rdd/RDD.scala
index e2652f1..17bc251 100644
--- a/core/src/main/scala/org/apache/spark/rdd/RDD.scala
+++ b/core/src/main/scala/org/apache/spark/rdd/RDD.scala
@@ -268,22 +268,14 @@ abstract class RDD[T: ClassManifest](
/**
* Return a new RDD that has exactly numPartitions partitions.
*
- * Used to increase or decrease the level of parallelism in this RDD. By default, this will use
- * a shuffle to redistribute data. If you are shrinking the RDD into fewer partitions, you can
- * set skipShuffle = false to avoid a shuffle. Skipping shuffles is not supported when
- * increasing the number of partitions.
+ * Used to increase or decrease the level of parallelism in this RDD. This will use
+ * a shuffle to redistribute data.
*
- * Similar to `coalesce`, but shuffles by default, allowing you to call this safely even
- * if you don't know the number of partitions.
- */
- def repartition(numPartitions: Int, skipShuffle: Boolean = false): RDD[T] = {
- if (skipShuffle && numPartitions > this.partitions.size) {
- val msg = "repartition must grow %s from %s to %s partitions, cannot skip shuffle.".format(
- this.name, this.partitions.size, numPartitions
- )
- throw new IllegalArgumentException(msg)
- }
- coalesce(numPartitions, !skipShuffle)
+ * If you are decreasing the number of partitions in this RDD, consider using `coalesce`,
+ * which can avoid performing a shuffle.
+ */
+ def repartition(numPartitions: Int): RDD[T] = {
+ coalesce(numPartitions, true)
}
/**