Skip to content

Commit f6ba5fb

Browse files
committed
Use require() for simpler syntax.
1 parent d5e3df8 commit f6ba5fb

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

core/src/main/scala/org/apache/spark/Partitioner.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ object Partitioner {
7676
* produce an unexpected or incorrect result.
7777
*/
7878
class HashPartitioner(partitions: Int) extends Partitioner {
79-
if (partitions < 1) {
80-
throw new IllegalArgumentException(s"Number of partitions ($partitions) must be positive.")
81-
}
79+
require(partitions > 0, s"Number of partitions ($partitions) must be positive.")
8280

8381
def numPartitions: Int = partitions
8482

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ private[spark] class CoalescedRDD[T: ClassTag](
7878
balanceSlack: Double = 0.10)
7979
extends RDD[T](prev.context, Nil) { // Nil since we implement getDependencies
8080

81-
if (maxPartitions < 1) {
82-
throw new IllegalArgumentException(s"Number of partitions ($maxPartitions) must be positive.")
83-
}
81+
require(maxPartitions > 0, s"Number of partitions ($maxPartitions) must be positive.")
8482

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

0 commit comments

Comments
 (0)