hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1625177 - /hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/optimizer/StatsOptimizer.java
Date Mon, 15 Sep 2014 22:48:22 GMT
Author: sershe
Date: Mon Sep 15 22:48:21 2014
New Revision: 1625177

URL: http://svn.apache.org/r1625177
Log:
HIVE-8085 : stats optimizer should not use Description annotation to figure out function mapping
(because FunctionRegistry doesn't) (Sergey Shelukhin, reviewed by Ashutosh Chauhan)

Modified:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/optimizer/StatsOptimizer.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/optimizer/StatsOptimizer.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/optimizer/StatsOptimizer.java?rev=1625177&r1=1625176&r2=1625177&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/optimizer/StatsOptimizer.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/optimizer/StatsOptimizer.java Mon Sep
15 22:48:21 2014
@@ -37,6 +37,7 @@ import org.apache.hadoop.hive.ql.exec.Co
 import org.apache.hadoop.hive.ql.exec.Description;
 import org.apache.hadoop.hive.ql.exec.FetchTask;
 import org.apache.hadoop.hive.ql.exec.FileSinkOperator;
+import org.apache.hadoop.hive.ql.exec.FunctionRegistry;
 import org.apache.hadoop.hive.ql.exec.GroupByOperator;
 import org.apache.hadoop.hive.ql.exec.ReduceSinkOperator;
 import org.apache.hadoop.hive.ql.exec.SelectOperator;
@@ -65,6 +66,7 @@ import org.apache.hadoop.hive.ql.plan.Fe
 import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFCount;
 import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFMax;
 import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFMin;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFResolver;
 import org.apache.hadoop.hive.ql.udf.generic.GenericUDAFSum;
 import org.apache.hadoop.hive.serde.serdeConstants;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
@@ -230,8 +232,10 @@ public class StatsOptimizer implements T
             // our stats for NDV is approx, not accurate.
             return null;
           }
-          if (aggr.getGenericUDAFName().equals(AnnotationUtils.getAnnotation(GenericUDAFSum.class,
-              Description.class).name())) {
+          // Get the aggregate function matching the name in the query.
+          GenericUDAFResolver udaf =
+              FunctionRegistry.getGenericUDAFResolver(aggr.getGenericUDAFName());
+          if (udaf instanceof GenericUDAFSum) {
             if(!(aggr.getParameters().get(0) instanceof ExprNodeConstantDesc)){
               return null;
             }
@@ -244,8 +248,7 @@ public class StatsOptimizer implements T
             ois.add(PrimitiveObjectInspectorFactory.getPrimitiveJavaObjectInspector(
                 PrimitiveCategory.DECIMAL));
           }
-          else if (aggr.getGenericUDAFName().equals(AnnotationUtils.getAnnotation(GenericUDAFCount.class,
-              Description.class).name())) {
+          else if (udaf instanceof GenericUDAFCount) {
             Long rowCnt = 0L;
             if ((aggr.getParameters().isEmpty() || aggr.getParameters().get(0) instanceof
                 ExprNodeConstantDesc)) {
@@ -326,8 +329,7 @@ public class StatsOptimizer implements T
             oneRow.add(rowCnt);
             ois.add(PrimitiveObjectInspectorFactory.
                 getPrimitiveJavaObjectInspector(PrimitiveCategory.LONG));
-          } else if (aggr.getGenericUDAFName().equals(GenericUDAFMax.class.getAnnotation(
-              Description.class).name())) {
+          } else if (udaf instanceof GenericUDAFMax) {
             ExprNodeColumnDesc colDesc = (ExprNodeColumnDesc)aggr.getParameters().get(0);
             String colName = colDesc.getColumn();
             StatType type = getType(colDesc.getTypeString());
@@ -416,8 +418,7 @@ public class StatsOptimizer implements T
                   return null;
               }
             }
-          }  else if (aggr.getGenericUDAFName().equals(GenericUDAFMin.class.getAnnotation(
-              Description.class).name())) {
+          }  else if (udaf instanceof GenericUDAFMin) {
             ExprNodeColumnDesc colDesc = (ExprNodeColumnDesc)aggr.getParameters().get(0);
             String colName = colDesc.getColumn();
             StatType type = getType(colDesc.getTypeString());



Mime
View raw message