Skip to content

Commit

Permalink
Use require to check for legitimate range
Browse files Browse the repository at this point in the history
  • Loading branch information
tedyu committed Sep 11, 2015
1 parent 04aa45e commit 0e86ae8
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,8 @@ private[spark] class ExternalSorter[K, V, C](
val it = collection.destructiveSortedWritablePartitionedIterator(comparator)
while (it.hasNext) {
val partitionId = it.nextPartition()
if (partitionId < 0) {
throw new IllegalArgumentException("Encountered negative partition Id: " + partitionId)
}
if (partitionId >= numPartitions) {
throw new IllegalArgumentException("Encountered partition Id: " + partitionId +
" which is >= " + numPartitions)
}
require(partitionId >= 0 && partitionId < numPartitions,
s"partition Id: ${partitionId} should be in the range (0, ${numPartitions})")
it.writeNext(writer)
elementsPerPartition(partitionId) += 1
objectsWritten += 1
Expand Down

0 comments on commit 0e86ae8

Please sign in to comment.