You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by pw...@apache.org on 2014/04/26 02:55:11 UTC

git commit: SPARK-1632. Remove unnecessary boxing in compares in ExternalAppendOnlyM...

Repository: spark
Updated Branches:
  refs/heads/master 027f1b85f -> 87cf35c2d


SPARK-1632. Remove unnecessary boxing in compares in ExternalAppendOnlyM...

...ap

Author: Sandy Ryza <sa...@cloudera.com>

Closes #559 from sryza/sandy-spark-1632 and squashes the following commits:

a6cd352 [Sandy Ryza] Only compute hashes once
04e3884 [Sandy Ryza] SPARK-1632. Remove unnecessary boxing in compares in ExternalAppendOnlyMap


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/87cf35c2
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/87cf35c2
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/87cf35c2

Branch: refs/heads/master
Commit: 87cf35c2d6acc9649b3fb05648b79b9862b3959b
Parents: 027f1b8
Author: Sandy Ryza <sa...@cloudera.com>
Authored: Fri Apr 25 17:55:04 2014 -0700
Committer: Patrick Wendell <pw...@gmail.com>
Committed: Fri Apr 25 17:55:04 2014 -0700

----------------------------------------------------------------------
 .../apache/spark/util/collection/ExternalAppendOnlyMap.scala | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/87cf35c2/core/src/main/scala/org/apache/spark/util/collection/ExternalAppendOnlyMap.scala
----------------------------------------------------------------------
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 d615767..170f09b 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
     }
   }
 }