Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
address review comments
  • Loading branch information
kiszk committed Jun 21, 2018
commit 02bbeb1be87c76ff20909cd1f9dd3889ca4a7f40
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,7 @@ private[spark] class ExternalSorter[K, V, C](
type Iter = BufferedIterator[Product2[K, C]]
val heap = new mutable.PriorityQueue[Iter]()(new Ordering[Iter] {
// Use the reverse of comparator.compare because PriorityQueue dequeues the max
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we keep this comment? we still use reverse order here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe: Use the reverse order because PriorityQueue dequeues the max.

// avoid false positive of RV_NEGATING_RESULT_OF_COMPARETO by SpotBugs
override def compare(x: Iter, y: Iter): Int = -1 * comparator.compare(x.head._1, y.head._1)
override def compare(x: Iter, y: Iter): Int = comparator.compare(y.head._1, x.head._1)
})
heap.enqueue(bufferedIters: _*) // Will contain only the iterators with hasNext = true
new Iterator[Product2[K, C]] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,7 @@ trait ArraySortLike extends ExpectsInputTypes {
} else if (o2 == null) {
nullOrder
} else {
// avoid false positive of RV_NEGATING_RESULT_OF_COMPARETO by SpotBugs
-1 * ordering.compare(o1, o2)
ordering.compare(o2, o1)
}
}
}
Expand Down