aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/scala/org/apache/spark/util/collection/ExternalAppendOnlyMap.scala
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/scala/org/apache/spark/util/collection/ExternalAppendOnlyMap.scala')
-rw-r--r--core/src/main/scala/org/apache/spark/util/collection/ExternalAppendOnlyMap.scala8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/src/main/scala/org/apache/spark/util/collection/ExternalAppendOnlyMap.scala b/core/src/main/scala/org/apache/spark/util/collection/ExternalAppendOnlyMap.scala
index d615767284..170f09be21 100644
--- a/core/src/main/scala/org/apache/spark/util/collection/ExternalAppendOnlyMap.scala
+++ b/core/src/main/scala/org/apache/spark/util/collection/ExternalAppendOnlyMap.scala
@@ -337,8 +337,8 @@ class ExternalAppendOnlyMap[K, V, C](
}
override def compareTo(other: StreamBuffer): Int = {
- // minus sign because mutable.PriorityQueue dequeues the max, not the min
- -minKeyHash.compareTo(other.minKeyHash)
+ // descending order because mutable.PriorityQueue dequeues the max, not the min
+ if (other.minKeyHash < minKeyHash) -1 else if (other.minKeyHash == minKeyHash) 0 else 1
}
}
}
@@ -422,7 +422,9 @@ class ExternalAppendOnlyMap[K, V, C](
private[spark] object ExternalAppendOnlyMap {
private class KCComparator[K, C] extends Comparator[(K, C)] {
def compare(kc1: (K, C), kc2: (K, C)): Int = {
- kc1._1.hashCode().compareTo(kc2._1.hashCode())
+ val hash1 = kc1._1.hashCode()
+ val hash2 = kc2._1.hashCode()
+ if (hash1 < hash2) -1 else if (hash1 == hash2) 0 else 1
}
}
}