You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2015/08/25 23:28:52 UTC

[22/50] [abbrv] hive git commit: HIVE-11490 : Lazily call ASTNode::toStringTree() after tree modification (Hari Subramaniyan, reviewed by Ashutosh Chauhan)

HIVE-11490 : Lazily call ASTNode::toStringTree() after tree modification (Hari Subramaniyan, 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/9d8515df
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/9d8515df
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/9d8515df

Branch: refs/heads/llap
Commit: 9d8515df6ff722cd81b9b42a582c422adeac8849
Parents: 97a6cd3
Author: Hari Subramaniyan <ha...@apache.org>
Authored: Mon Aug 17 11:32:06 2015 -0700
Committer: Hari Subramaniyan <ha...@apache.org>
Committed: Mon Aug 17 11:32:06 2015 -0700

----------------------------------------------------------------------
 .../hadoop/hive/ql/lib/DefaultGraphWalker.java    |  2 +-
 .../org/apache/hadoop/hive/ql/parse/ASTNode.java  | 18 +++++++++---------
 2 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/9d8515df/ql/src/java/org/apache/hadoop/hive/ql/lib/DefaultGraphWalker.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/lib/DefaultGraphWalker.java b/ql/src/java/org/apache/hadoop/hive/ql/lib/DefaultGraphWalker.java
index cf9131d..583c113 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/lib/DefaultGraphWalker.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/lib/DefaultGraphWalker.java
@@ -108,7 +108,7 @@ public class DefaultGraphWalker implements GraphWalker {
     while (toWalk.size() > 0) {
       Node nd = toWalk.remove(0);
       walk(nd);
-      if (nodeOutput != null) {
+      if (nodeOutput != null && getDispatchedList().contains(nd)) {
         nodeOutput.put(nd, retMap.get(nd));
       }
     }

http://git-wip-us.apache.org/repos/asf/hive/blob/9d8515df/ql/src/java/org/apache/hadoop/hive/ql/parse/ASTNode.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/ASTNode.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/ASTNode.java
index 136d481..b96e2eb 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/ASTNode.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/ASTNode.java
@@ -143,9 +143,11 @@ public class ASTNode extends CommonTree implements Node,Serializable {
       retNode = (ASTNode) retNode.parent;
     }
     rootNode=retNode;
-    rootNode.astStr = new StringBuffer();
-    rootNode.toStringTree(rootNode);
-    rootNode.isValidASTStr = true;
+    if (!rootNode.isValidASTStr) {
+      rootNode.astStr = new StringBuffer();
+      rootNode.toStringTree(rootNode);
+      rootNode.isValidASTStr = true;
+    }
     return retNode;
   }
 
@@ -159,9 +161,6 @@ public class ASTNode extends CommonTree implements Node,Serializable {
       rootNode.astStr = null;
       rootNode.isValidASTStr = false;
     }
-    // The root might have changed because of tree modifications.
-    // Compute the new root for this tree and set the astStr.
-    getRootNodeWithValidASTStr(false);
   }
 
   private int getMemoizedStringLen() {
@@ -225,9 +224,10 @@ public class ASTNode extends CommonTree implements Node,Serializable {
 
   @Override
   public String toStringTree() {
-    // The tree modifier functions invalidate the old astStr, rootNode, etc.
-    // Hence, we can use the memoized root node and string values here.
-    ASTNode rootNode = (ASTNode)this.getRootNodeWithValidASTStr(true);
+
+    // The root might have changed because of tree modifications.
+    // Compute the new root for this tree and set the astStr.
+    getRootNodeWithValidASTStr(true);
 
     // If rootNotModified is false, then startIndx and endIndx will be stale.
     if (startIndx >= 0 && endIndx <= rootNode.getMemoizedStringLen()) {