Return-Path: X-Original-To: apmail-hive-commits-archive@www.apache.org Delivered-To: apmail-hive-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2DF6A17542 for ; Thu, 25 Sep 2014 19:38:38 +0000 (UTC) Received: (qmail 39994 invoked by uid 500); 25 Sep 2014 19:38:38 -0000 Delivered-To: apmail-hive-commits-archive@hive.apache.org Received: (qmail 39954 invoked by uid 500); 25 Sep 2014 19:38:38 -0000 Mailing-List: contact commits-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hive.apache.org Delivered-To: mailing list commits@hive.apache.org Received: (qmail 39943 invoked by uid 99); 25 Sep 2014 19:38:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Sep 2014 19:38:37 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Sep 2014 19:38:15 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 7719523888E2; Thu, 25 Sep 2014 19:38:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1627618 - in /hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec: ExprNodeGenericFuncEvaluator.java GroupByOperator.java Date: Thu, 25 Sep 2014 19:38:13 -0000 To: commits@hive.apache.org From: gunther@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140925193813.7719523888E2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gunther Date: Thu Sep 25 19:38:12 2014 New Revision: 1627618 URL: http://svn.apache.org/r1627618 Log: HIVE-8188: ExprNodeGenericFuncEvaluator::_evaluate() loads class annotations in a tight loop (Gopal V via Gunther Hagleitner) Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeGenericFuncEvaluator.java hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeGenericFuncEvaluator.java URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeGenericFuncEvaluator.java?rev=1627618&r1=1627617&r2=1627618&view=diff ============================================================================== --- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeGenericFuncEvaluator.java (original) +++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/ExprNodeGenericFuncEvaluator.java Thu Sep 25 19:38:12 2014 @@ -45,6 +45,7 @@ public class ExprNodeGenericFuncEvaluato transient ExprNodeEvaluator[] children; transient GenericUDF.DeferredObject[] deferredChildren; transient boolean isEager; + transient boolean isConstant = false; /** * Class to allow deferred evaluation for GenericUDF. @@ -124,7 +125,10 @@ public class ExprNodeGenericFuncEvaluato if (context != null) { context.setup(genericUDF); } - return outputOI = genericUDF.initializeAndFoldConstants(childrenOIs); + outputOI = genericUDF.initializeAndFoldConstants(childrenOIs); + isConstant = ObjectInspectorUtils.isConstantObjectInspector(outputOI) + && isDeterministic(); + return outputOI; } @Override @@ -154,12 +158,11 @@ public class ExprNodeGenericFuncEvaluato @Override protected Object _evaluate(Object row, int version) throws HiveException { - rowObject = row; - if (ObjectInspectorUtils.isConstantObjectInspector(outputOI) && - isDeterministic()) { + if (isConstant) { // The output of this UDF is constant, so don't even bother evaluating. - return ((ConstantObjectInspector)outputOI).getWritableConstantValue(); + return ((ConstantObjectInspector) outputOI).getWritableConstantValue(); } + rowObject = row; for (int i = 0; i < deferredChildren.length; i++) { deferredChildren[i].prepare(version); } Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java?rev=1627618&r1=1627617&r2=1627618&view=diff ============================================================================== --- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java (original) +++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/GroupByOperator.java Thu Sep 25 19:38:12 2014 @@ -77,6 +77,7 @@ public class GroupByOperator extends Ope private static final Log LOG = LogFactory.getLog(GroupByOperator.class .getName()); + private static final boolean isTraceEnabled = LOG.isTraceEnabled(); private static final long serialVersionUID = 1L; private static final int NUMROWSESTIMATESIZE = 1000; @@ -101,6 +102,7 @@ public class GroupByOperator extends Ope transient ExprNodeEvaluator unionExprEval = null; transient GenericUDAFEvaluator[] aggregationEvaluators; + transient boolean[] estimableAggregationEvaluators; protected transient ArrayList objectInspectors; transient ArrayList fieldNames; @@ -557,11 +559,13 @@ public class GroupByOperator extends Ope // Go over all the aggregation classes and and get the size of the fields of // fixed length. Keep track of the variable length // fields in these aggregation classes. + estimableAggregationEvaluators = new boolean[aggregationEvaluators.length]; for (int i = 0; i < aggregationEvaluators.length; i++) { fixedRowSize += javaObjectOverHead; AggregationBuffer agg = aggregationEvaluators[i].getNewAggregationBuffer(); if (GenericUDAFEvaluator.isEstimable(agg)) { + estimableAggregationEvaluators[i] = true; continue; } Field[] fArr = ObjectInspectorUtils.getDeclaredNonStaticFields(agg.getClass()); @@ -765,10 +769,12 @@ public class GroupByOperator extends Ope flushHashTable(true); hashAggr = false; } else { - LOG.trace("Hash Aggr Enabled: #hash table = " + numRowsHashTbl - + " #total = " + numRowsInput + " reduction = " + 1.0 - * (numRowsHashTbl / numRowsInput) + " minReduction = " - + minReductionHashAggr); + if (isTraceEnabled) { + LOG.trace("Hash Aggr Enabled: #hash table = " + numRowsHashTbl + + " #total = " + numRowsInput + " reduction = " + 1.0 + * (numRowsHashTbl / numRowsInput) + " minReduction = " + + minReductionHashAggr); + } } } } @@ -952,7 +958,7 @@ public class GroupByOperator extends Ope AggregationBuffer[] aggs = hashAggregations.get(newKeys); for (int i = 0; i < aggs.length; i++) { AggregationBuffer agg = aggs[i]; - if (GenericUDAFEvaluator.isEstimable(agg)) { + if (estimableAggregationEvaluators[i]) { totalVariableSize += ((GenericUDAFEvaluator.AbstractAggregationBuffer)agg).estimate(); continue; } @@ -966,8 +972,10 @@ public class GroupByOperator extends Ope // Update the number of entries that can fit in the hash table numEntriesHashTable = (int) (maxHashTblMemory / (fixedRowSize + (totalVariableSize / numEntriesVarSize))); - LOG.trace("Hash Aggr: #hash table = " + numEntries - + " #max in hash table = " + numEntriesHashTable); + if (isTraceEnabled) { + LOG.trace("Hash Aggr: #hash table = " + numEntries + + " #max in hash table = " + numEntriesHashTable); + } } // flush if necessary