Skip to content

Commit

Permalink
Require positive maxPartitions in CoalescedRDD
Browse files Browse the repository at this point in the history
  • Loading branch information
darabos committed Jul 8, 2015
1 parent 351a36d commit 897c628
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/src/main/scala/org/apache/spark/rdd/CoalescedRDD.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private[spark] case class CoalescedRDDPartition(
* the preferred location of each new partition overlaps with as many preferred locations of its
* parent partitions
* @param prev RDD to be coalesced
* @param maxPartitions number of desired partitions in the coalesced RDD
* @param maxPartitions number of desired partitions in the coalesced RDD (must be positive)
* @param balanceSlack used to trade-off balance and locality. 1.0 is all locality, 0 is all balance
*/
private[spark] class CoalescedRDD[T: ClassTag](
Expand All @@ -78,6 +78,10 @@ private[spark] class CoalescedRDD[T: ClassTag](
balanceSlack: Double = 0.10)
extends RDD[T](prev.context, Nil) { // Nil since we implement getDependencies

if (maxPartitions < 1) {
throw new IllegalArgumentException(s"Number of partitions ($maxPartitions) must be positive.")
}

override def getPartitions: Array[Partition] = {
val pc = new PartitionCoalescer(maxPartitions, prev, balanceSlack)

Expand Down

0 comments on commit 897c628

Please sign in to comment.