hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From x..@apache.org
Subject [01/50] [abbrv] hive git commit: HIVE-11366: Avoid right leaning tree hashCode depth in ExprNodeDescEqualityWrapper hashmaps (Gopal V, reviewed by Ashutosh Chauhan)
Date Wed, 09 Sep 2015 07:08:31 GMT
Repository: hive
Updated Branches:
  refs/heads/beeline-cli b90a2ae5d -> fc53e5d7e


HIVE-11366: Avoid right leaning tree hashCode depth in ExprNodeDescEqualityWrapper hashmaps
(Gopal V, reviewed by Ashutosh Chauhan)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/3e63fc42
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/3e63fc42
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/3e63fc42

Branch: refs/heads/beeline-cli
Commit: 3e63fc42054e64455d90ca74cb6ebe30ea0d40ae
Parents: 284859c
Author: Gopal V <gopalv@apache.org>
Authored: Tue Aug 25 14:14:08 2015 -0700
Committer: Gopal V <gopalv@apache.org>
Committed: Tue Aug 25 14:14:08 2015 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hive/ql/plan/ExprNodeDesc.java | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/3e63fc42/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeDesc.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeDesc.java b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeDesc.java
index 0fe9eda..15267b9 100755
--- a/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeDesc.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/plan/ExprNodeDesc.java
@@ -98,21 +98,22 @@ public abstract class ExprNodeDesc implements Serializable, Node {
 
   // This wraps an instance of an ExprNodeDesc, and makes equals work like isSame, see comment
on
   // isSame
-  public static class ExprNodeDescEqualityWrapper {
-    private ExprNodeDesc exprNodeDesc;
+  public final static class ExprNodeDescEqualityWrapper {
+    private final ExprNodeDesc exprNodeDesc;
+    // beware of any implementation whose hashcode is mutable by reference
+    // inserting into a Map and then changing the hashcode can make it 
+    // disappear out of the Map during lookups
+    private final int hashcode;
 
     public ExprNodeDescEqualityWrapper(ExprNodeDesc exprNodeDesc) {
       this.exprNodeDesc = exprNodeDesc;
+      this.hashcode = exprNodeDesc == null ? 0 : exprNodeDesc.hashCode();
     }
 
     public ExprNodeDesc getExprNodeDesc() {
       return exprNodeDesc;
     }
 
-    public void setExprNodeDesc(ExprNodeDesc exprNodeDesc) {
-      this.exprNodeDesc = exprNodeDesc;
-    }
-
     @Override
     public boolean equals(Object other) {
 
@@ -125,7 +126,7 @@ public abstract class ExprNodeDesc implements Serializable, Node {
 
     @Override
     public int hashCode() {
-      return exprNodeDesc == null ? 0 : exprNodeDesc.hashCode();
+      return hashcode;
     }
 
     /* helper function to allow Set()/Collection() operations with ExprNodeDesc */


Mime
View raw message