This is an automated email from the ASF dual-hosted git repository.

bslim pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 38e3108  HIVE-22629: Avoid Array resizing/recreation  by using the 
construcor/ref instead of iteration/get_i (Slim Bouguerra reviewed by Vineet 
Garg)
38e3108 is described below

commit 38e310868260b6a20534413de94160d480adc526
Author: Slim Bouguerra <bs...@apache.org>
AuthorDate: Fri Feb 28 09:23:03 2020 -0800

    HIVE-22629: Avoid Array resizing/recreation  by using the construcor/ref 
instead of iteration/get_i (Slim Bouguerra reviewed by Vineet Garg)
---
 parser/src/java/org/apache/hadoop/hive/ql/parse/ASTNode.java     | 8 +-------
 .../java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java   | 5 +++--
 .../org/apache/hadoop/hive/ql/ppd/ExprWalkerProcFactory.java     | 9 ++++-----
 3 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/parser/src/java/org/apache/hadoop/hive/ql/parse/ASTNode.java 
b/parser/src/java/org/apache/hadoop/hive/ql/parse/ASTNode.java
index 746d0dc..2d611fb 100644
--- a/parser/src/java/org/apache/hadoop/hive/ql/parse/ASTNode.java
+++ b/parser/src/java/org/apache/hadoop/hive/ql/parse/ASTNode.java
@@ -78,13 +78,7 @@ public class ASTNode extends CommonTree implements 
Node,Serializable {
     if (super.getChildCount() == 0) {
       return null;
     }
-
-    ArrayList<Node> ret_vec = new ArrayList<Node>();
-    for (int i = 0; i < super.getChildCount(); ++i) {
-      ret_vec.add((Node) super.getChild(i));
-    }
-
-    return ret_vec;
+    return new ArrayList<>((List<? extends Node>) super.getChildren());
   }
 
   /*
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java 
b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
index fed890f..59c41c5 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
@@ -14256,8 +14256,9 @@ public class SemanticAnalyzer extends 
BaseSemanticAnalyzer {
         }
       }
 
-      for (int i = next.getChildren().size() - 1; i >= 0; i--) {
-        stack.push((ASTNode)next.getChildren().get(i));
+      ArrayList childrenList = next.getChildren();
+      for (int i = childrenList.size() - 1; i >= 0; i--) {
+        stack.push((ASTNode)childrenList.get(i));
       }
     }
   }
diff --git 
a/ql/src/java/org/apache/hadoop/hive/ql/ppd/ExprWalkerProcFactory.java 
b/ql/src/java/org/apache/hadoop/hive/ql/ppd/ExprWalkerProcFactory.java
index efcadab..b5fd181 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/ppd/ExprWalkerProcFactory.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/ppd/ExprWalkerProcFactory.java
@@ -383,12 +383,11 @@ public final class ExprWalkerProcFactory {
       // For the children, we populate the NewToOldExprMap to keep track of
       // the original condition before rewriting it for this operator
       assert ctx.getNewToOldExprMap().containsKey(expr);
+      List<ExprNodeDesc> exprChildren = expr.getChildren();
+      List<ExprNodeDesc> newToOldList = 
ctx.getNewToOldExprMap().get(expr).getChildren();
       for (int i = 0; i < expr.getChildren().size(); i++) {
-        ctx.getNewToOldExprMap().put(
-            expr.getChildren().get(i),
-            ctx.getNewToOldExprMap().get(expr).getChildren().get(i));
-        extractFinalCandidates(expr.getChildren().get(i),
-            ctx, conf);
+        ctx.getNewToOldExprMap().put(exprChildren.get(i), newToOldList.get(i));
+        extractFinalCandidates(exprChildren.get(i), ctx, conf);
       }
       return;
     }

Reply via email to