diff --git ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java index 9d1a81c..238214e 100644 --- ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java +++ ql/src/java/org/apache/hadoop/hive/ql/optimizer/ConstantPropagateProcFactory.java @@ -164,7 +164,9 @@ private static ExprNodeConstantDesc typeCast(ExprNodeDesc desc, TypeInfo ti) { // ExprNodeConstantDesc return null; } - LOG.debug("Casting " + desc + " to type " + ti); + if (LOG.isDebugEnabled()) { + LOG.debug("Casting " + desc + " to type " + ti); + } ExprNodeConstantDesc c = (ExprNodeConstantDesc) desc; if (null != c.getFoldedFromVal() && priti.getTypeName().equals(serdeConstants.STRING_TYPE_NAME)) { // avoid double casting to preserve original string representation of constant. @@ -224,7 +226,9 @@ private static ExprNodeDesc foldExpr(ExprNodeDesc desc, Map " + constant); + if (LOG.isDebugEnabled()) { + LOG.debug("Folding expression:" + desc + " -> " + constant); + } return constant; } else { // Check if the function can be short cut. ExprNodeDesc shortcut = shortcutFunction(udf, newExprs); if (shortcut != null) { - LOG.debug("Folding expression:" + desc + " -> " + shortcut); + if (LOG.isDebugEnabled()) { + LOG.debug("Folding expression:" + desc + " -> " + shortcut); + } return shortcut; } ((ExprNodeGenericFuncDesc) desc).setChildren(newExprs); @@ -265,7 +273,9 @@ private static ExprNodeDesc foldExpr(ExprNodeDesc desc, Map parent = op.getParentOperators().get(tag); ExprNodeDesc col = evaluateColumn((ExprNodeColumnDesc) desc, cppCtx, parent); if (col != null) { - LOG.debug("Folding expression:" + desc + " -> " + col); + if (LOG.isDebugEnabled()) { + LOG.debug("Folding expression:" + desc + " -> " + col); + } return col; } } @@ -343,7 +353,9 @@ private static void propagate(GenericUDF udf, List newExprs, RowRe } ColumnInfo ci = resolveColumn(rr, c); if (ci != null) { - LOG.debug("Filter " + udf + " is identified as a value assignment, propagate it."); + if (LOG.isDebugEnabled()) { + LOG.debug("Filter " + udf + " is identified as a value assignment, propagate it."); + } if (!v.getTypeInfo().equals(ci.getType())) { v = typeCast(v, ci.getType()); } @@ -354,7 +366,9 @@ private static void propagate(GenericUDF udf, List newExprs, RowRe } else if (udf instanceof GenericUDFOPNull) { ExprNodeDesc operand = newExprs.get(0); if (operand instanceof ExprNodeColumnDesc) { - LOG.debug("Filter " + udf + " is identified as a value assignment, propagate it."); + if (LOG.isDebugEnabled()) { + LOG.debug("Filter " + udf + " is identified as a value assignment, propagate it."); + } ExprNodeColumnDesc c = (ExprNodeColumnDesc) operand; ColumnInfo ci = resolveColumn(rr, c); if (ci != null) { @@ -530,7 +544,9 @@ private static ExprNodeDesc evaluateFunction(GenericUDF udf, List try { ObjectInspector oi = udf.initialize(argois); Object o = udf.evaluate(arguments); - LOG.debug(udf.getClass().getName() + "(" + exprs + ")=" + o); + if (LOG.isDebugEnabled()) { + LOG.debug(udf.getClass().getName() + "(" + exprs + ")=" + o); + } if (o == null) { return new ExprNodeNullDesc(); } @@ -551,7 +567,9 @@ private static ExprNodeDesc evaluateFunction(GenericUDF udf, List } else if (PrimitiveObjectInspectorUtils.isPrimitiveJavaClass(clz)) { } else { - LOG.error("Unable to evaluate " + udf + ". Return value unrecoginizable."); + if (LOG.isErrorEnabled()) { + LOG.error("Unable to evaluate " + udf + ". Return value unrecoginizable."); + } return null; } String constStr = null; @@ -582,7 +600,9 @@ private static void foldOperator(Operator op, for (ColumnInfo col : schema.getSignature()) { ExprNodeDesc constant = constants.get(col); if (constant != null) { - LOG.debug("Replacing column " + col + " with constant " + constant + " in " + op); + if (LOG.isDebugEnabled()) { + LOG.debug("Replacing column " + col + " with constant " + constant + " in " + op); + } if (!col.getType().equals(constant.getTypeInfo())) { constant = typeCast(constant, col.getType()); } @@ -618,18 +638,26 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx ctx, Object.. cppCtx.getOpToConstantExprs().put(op, constants); ExprNodeDesc condn = op.getConf().getPredicate(); - LOG.debug("Old filter FIL[" + op.getIdentifier() + "] conditions:" + condn.getExprString()); + if (LOG.isDebugEnabled()) { + LOG.debug("Old filter FIL[" + op.getIdentifier() + "] conditions:" + condn.getExprString()); + } ExprNodeDesc newCondn = foldExpr(condn, constants, cppCtx, op, 0, true); if (newCondn instanceof ExprNodeConstantDesc) { ExprNodeConstantDesc c = (ExprNodeConstantDesc) newCondn; if (Boolean.TRUE.equals(c.getValue())) { cppCtx.addOpToDelete(op); - LOG.debug("Filter expression " + condn + " holds true. Will delete it."); + if (LOG.isDebugEnabled()) { + LOG.debug("Filter expression " + condn + " holds true. Will delete it."); + } } else if (Boolean.FALSE.equals(c.getValue())) { - LOG.warn("Filter expression " + condn + " holds false!"); + if (LOG.isWarnEnabled()) { + LOG.warn("Filter expression " + condn + " holds false!"); + } } } - LOG.debug("New filter FIL[" + op.getIdentifier() + "] conditions:" + newCondn.getExprString()); + if (LOG.isDebugEnabled()) { + LOG.debug("New filter FIL[" + op.getIdentifier() + "] conditions:" + newCondn.getExprString()); + } // merge it with the downstream col list op.getConf().setPredicate(newCondn); @@ -752,7 +780,9 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx ctx, Object.. columnExprMap.put(columnNames.get(i), newCol); } } - LOG.debug("New column list:(" + StringUtils.join(colList, " ") + ")"); + if (LOG.isDebugEnabled()) { + LOG.debug("New column list:(" + StringUtils.join(colList, " ") + ")"); + } } return null; } @@ -831,7 +861,9 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx ctx, Object.. Operator op = (Operator) nd; ConstantPropagateProcCtx cppCtx = (ConstantPropagateProcCtx) ctx; cppCtx.getOpToConstantExprs().put(op, new HashMap()); - LOG.debug("Stop propagate constants on op " + op.getOperatorId()); + if (LOG.isDebugEnabled()) { + LOG.debug("Stop propagate constants on op " + op.getOperatorId()); + } return null; } } @@ -863,7 +895,9 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx ctx, Object.. && op.getChildOperators().get(0) instanceof JoinOperator) { JoinOperator joinOp = (JoinOperator) op.getChildOperators().get(0); if (skipFolding(joinOp.getConf())) { - LOG.debug("Skip folding in outer join " + op); + if (LOG.isDebugEnabled()) { + LOG.debug("Skip folding in outer join " + op); + } cppCtx.getOpToConstantExprs().put(op, new HashMap()); return null; } @@ -871,7 +905,9 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx ctx, Object.. if (rsDesc.getDistinctColumnIndices() != null && !rsDesc.getDistinctColumnIndices().isEmpty()) { - LOG.debug("Skip folding in distinct subqueries " + op); + if (LOG.isDebugEnabled()) { + LOG.debug("Skip folding in distinct subqueries " + op); + } cppCtx.getOpToConstantExprs().put(op, new HashMap()); return null; } @@ -955,7 +991,9 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx ctx, Object.. LOG.debug("Skip JOIN-RS structure."); return null; } - LOG.info("Old exprs " + conf.getExprs()); + if (LOG.isInfoEnabled()) { + LOG.info("Old exprs " + conf.getExprs()); + } Iterator>> itr = conf.getExprs().entrySet().iterator(); while (itr.hasNext()) { Entry> e = itr.next(); @@ -968,14 +1006,18 @@ public Object process(Node nd, Stack stack, NodeProcessorCtx ctx, Object.. for (ExprNodeDesc expr : exprs) { ExprNodeDesc newExpr = foldExpr(expr, constants, cppCtx, op, tag, false); if (newExpr instanceof ExprNodeConstantDesc || newExpr instanceof ExprNodeNullDesc) { - LOG.info("expr " + newExpr + " fold from " + expr + " is removed."); + if (LOG.isInfoEnabled()) { + LOG.info("expr " + newExpr + " fold from " + expr + " is removed."); + } continue; } newExprs.add(newExpr); } e.setValue(newExprs); } - LOG.info("New exprs " + conf.getExprs()); + if (LOG.isInfoEnabled()) { + LOG.info("New exprs " + conf.getExprs()); + } for (List v : conf.getFilters().values()) { for (int i = 0; i < v.size(); i++) {