spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pwend...@apache.org
Subject git commit: SPARK-1632. Remove unnecessary boxing in compares in ExternalAppendOnlyM...
Date Sat, 26 Apr 2014 00:55:25 GMT
Repository: spark
Updated Branches:
  refs/heads/branch-1.0 5673c1ea4 -> 94c71e0a2


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

...ap

Author: Sandy Ryza <sandy@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
(cherry picked from commit 87cf35c2d6acc9649b3fb05648b79b9862b3959b)

Signed-off-by: Patrick Wendell <pwendell@gmail.com>


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

Branch: refs/heads/branch-1.0
Commit: 94c71e0a2f00ff315528efbada3ed80953ac5506
Parents: 5673c1e
Author: Sandy Ryza <sandy@cloudera.com>
Authored: Fri Apr 25 17:55:04 2014 -0700
Committer: Patrick Wendell <pwendell@gmail.com>
Committed: Fri Apr 25 17:55:16 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/94c71e0a/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
     }
   }
 }


Mime
View raw message