Github user mridulm commented on a diff in the pull request:
https://github.com/apache/spark/pull/15736#discussion_r86173509
--- Diff:
core/src/main/scala/org/apache/spark/util/collection/PartitionedAppendOnlyMap.scala
---
@@ -30,7 +30,21 @@ private[spark] class PartitionedAppendOnlyMap[K, V]
def partitionedDestructiveSortedIterator(keyComparator:
Option[Comparator[K]])
: Iterator[((Int, K), V)] = {
- val comparator =
keyComparator.map(partitionKeyComparator).getOrElse(partitionComparator)
+ val comparator : Comparator[(Int, K)] =
+ if (keyComparator.isEmpty) {
+ partitionComparator
+ } else {
+ new Comparator[(Int, K)] {
+ override def compare(a: (Int, K), b: (Int, K)): Int = {
+ val partitionDiff = a._1 - b._1
+ if (partitionDiff != 0) {
+ partitionDiff
+ } else {
+ keyComparator.get.compare(a._2, b._2)
+ }
--- End diff --
You can dereference the option to avoid get in inner loop
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]