hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1669674 - /hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/stats/HiveRelMdSize.java
Date Fri, 27 Mar 2015 20:26:59 GMT
Author: hashutosh
Date: Fri Mar 27 20:26:59 2015
New Revision: 1669674

URL: http://svn.apache.org/r1669674
Log:
HIVE-10116 : CBO (Calcite Return Path): RelMdSize throws an Exception when Join is actually
a Semijoin [CBO branch] (Jesus Camacho Rodriguez via Ashutosh Chauhan)

Modified:
    hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/stats/HiveRelMdSize.java

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/stats/HiveRelMdSize.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/stats/HiveRelMdSize.java?rev=1669674&r1=1669673&r2=1669674&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/stats/HiveRelMdSize.java
(original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/stats/HiveRelMdSize.java
Fri Mar 27 20:26:59 2015
@@ -19,14 +19,18 @@ package org.apache.hadoop.hive.ql.optimi
 
 import java.util.List;
 
+import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.metadata.ReflectiveRelMetadataProvider;
 import org.apache.calcite.rel.metadata.RelMdSize;
 import org.apache.calcite.rel.metadata.RelMetadataProvider;
+import org.apache.calcite.rel.metadata.RelMetadataQuery;
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeField;
 import org.apache.calcite.util.BuiltInMethod;
 import org.apache.calcite.util.ImmutableIntList;
+import org.apache.calcite.util.ImmutableNullableList;
 import org.apache.hadoop.hive.ql.optimizer.calcite.RelOptHiveTable;
+import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveJoin;
 import org.apache.hadoop.hive.ql.optimizer.calcite.reloperators.HiveTableScan;
 import org.apache.hadoop.hive.ql.plan.ColStatistics;
 
@@ -68,6 +72,32 @@ public class HiveRelMdSize extends RelMd
     return list.build();
   }
 
+  public List<Double> averageColumnSizes(HiveJoin rel) {
+    final RelNode left = rel.getLeft();
+    final RelNode right = rel.getRight();
+    final List<Double> lefts =
+        RelMetadataQuery.getAverageColumnSizes(left);
+    List<Double> rights = null;
+    if (!rel.isLeftSemiJoin()) {
+        rights = RelMetadataQuery.getAverageColumnSizes(right);
+    }
+    if (lefts == null && rights == null) {
+      return null;
+    }
+    final int fieldCount = rel.getRowType().getFieldCount();
+    Double[] sizes = new Double[fieldCount];
+    if (lefts != null) {
+      lefts.toArray(sizes);
+    }
+    if (rights != null) {
+      final int leftCount = left.getRowType().getFieldCount();
+      for (int i = 0; i < rights.size(); i++) {
+        sizes[leftCount + i] = rights.get(i);
+      }
+    }
+    return ImmutableNullableList.copyOf(sizes);
+  }
+
   public Double averageTypeValueSize(RelDataType type) {
     switch (type.getSqlTypeName()) {
     case BOOLEAN:



Mime
View raw message