Skip to content

Commit

Permalink
Check partitionId's range in ExternalSorter#spill()
Browse files Browse the repository at this point in the history
  • Loading branch information
tedyu committed Sep 10, 2015
1 parent 49da38e commit 70eb93e
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ 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)
}
it.writeNext(writer)
elementsPerPartition(partitionId) += 1
objectsWritten += 1
Expand Down

0 comments on commit 70eb93e

Please sign in to comment.