drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [9/9] drill git commit: DRILL-2321: FlattenRecordBatch should transfer vectors honoring output field reference.
Date Fri, 27 Feb 2015 08:02:03 GMT
DRILL-2321: FlattenRecordBatch should transfer vectors honoring output field reference.


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/74517f5d
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/74517f5d
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/74517f5d

Branch: refs/heads/master
Commit: 74517f5d95300f94bad08004adb4e1a2817bbbe5
Parents: b49e51e
Author: Hanifi Gunes <hgunes@maprtech.com>
Authored: Thu Feb 26 11:23:30 2015 -0800
Committer: Jason Altekruse <altekrusejason@gmail.com>
Committed: Thu Feb 26 22:27:58 2015 -0800

----------------------------------------------------------------------
 .../impl/flatten/FlattenRecordBatch.java        | 34 ++++++++------------
 .../exec/vector/complex/RepeatedMapVector.java  |  8 ++---
 2 files changed, 17 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/74517f5d/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java
index 8a87098..7a5b352 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java
@@ -262,23 +262,19 @@ public class FlattenRecordBatch extends AbstractSingleRecordBatch<FlattenPOP>
{
    * the end of one of the other vectors while we are copying the data of the other vectors
alongside each new flattened
    * value coming out of the repeated field.)
    */
-  private TransferPair getFlattenFieldTransferPair() {
-    ValueVector flattenField = incoming.getValueAccessorById(
-        incoming.getSchema().getColumn(
-            incoming.getValueVectorId(
-                popConfig.getColumn()).getFieldIds()[0]).getValueClass(),
-        incoming.getValueVectorId(popConfig.getColumn()).getFieldIds()).getValueVector();
+  private TransferPair getFlattenFieldTransferPair(FieldReference reference) {
+    final TypedFieldId fieldId = incoming.getValueVectorId(popConfig.getColumn());
+    final Class vectorClass = incoming.getSchema().getColumn(fieldId.getFieldIds()[0]).getValueClass();
+    final ValueVector flattenField = incoming.getValueAccessorById(vectorClass, fieldId.getFieldIds()).getValueVector();
 
     TransferPair tp = null;
-    if (flattenField instanceof MapVector) {
-      return null;
-    } else if (flattenField instanceof RepeatedMapVector) {
-      tp = ((RepeatedMapVector)flattenField).getTransferPairToSingleMap();
+    if (flattenField instanceof RepeatedMapVector) {
+      tp = ((RepeatedMapVector)flattenField).getTransferPairToSingleMap(reference);
     } else {
       ValueVector vvIn = ((RepeatedVector)flattenField).getAccessor().getAllChildValues();
       // vvIn may be null because of fast schema return for repeated list vectors
       if (vvIn != null) {
-        tp = vvIn.getTransferPair();
+        tp = vvIn.getTransferPair(reference);
       }
     }
     return tp;
@@ -293,15 +289,11 @@ public class FlattenRecordBatch extends AbstractSingleRecordBatch<FlattenPOP>
{
     final List<TransferPair> transfers = Lists.newArrayList();
 
     final ClassGenerator<Flattener> cg = CodeGenerator.getRoot(Flattener.TEMPLATE_DEFINITION,
context.getFunctionRegistry());
-    IntOpenHashSet transferFieldIds = new IntOpenHashSet();
+    final IntOpenHashSet transferFieldIds = new IntOpenHashSet();
 
-    NamedExpression namedExpression = new NamedExpression(popConfig.getColumn(), new FieldReference(popConfig.getColumn()));
-    LogicalExpression expr = ExpressionTreeMaterializer.materialize(namedExpression.getExpr(),
incoming, collector, context.getFunctionRegistry(), true);
-    ValueVectorReadExpression vectorRead = (ValueVectorReadExpression) expr;
-    TypedFieldId id = vectorRead.getFieldId();
-    Preconditions.checkNotNull(incoming);
-
-    TransferPair tp = getFlattenFieldTransferPair();
+    final NamedExpression flattenExpr = new NamedExpression(popConfig.getColumn(), new FieldReference(popConfig.getColumn()));
+    final ValueVectorReadExpression vectorRead = (ValueVectorReadExpression)ExpressionTreeMaterializer.materialize(flattenExpr.getExpr(),
incoming, collector, context.getFunctionRegistry(), true);
+    final TransferPair tp = getFlattenFieldTransferPair(flattenExpr.getRef());
 
     if (tp != null) {
       transfers.add(tp);
@@ -314,7 +306,7 @@ public class FlattenRecordBatch extends AbstractSingleRecordBatch<FlattenPOP>
{
     ClassifierResult result = new ClassifierResult();
 
     for (int i = 0; i < exprs.size(); i++) {
-      namedExpression = exprs.get(i);
+      final NamedExpression namedExpression = exprs.get(i);
       result.clear();
 
       String outputName = getRef(namedExpression).getRootSegment().getPath();
@@ -327,7 +319,7 @@ public class FlattenRecordBatch extends AbstractSingleRecordBatch<FlattenPOP>
{
         }
       }
 
-      expr = ExpressionTreeMaterializer.materialize(namedExpression.getExpr(), incoming,
collector, context.getFunctionRegistry(), true);
+      final LogicalExpression expr = ExpressionTreeMaterializer.materialize(namedExpression.getExpr(),
incoming, collector, context.getFunctionRegistry(), true);
       final MaterializedField outputField = MaterializedField.create(outputName, expr.getMajorType());
       if (collector.hasErrors()) {
         throw new SchemaChangeException(String.format("Failure while trying to materialize
incoming schema.  Errors:\n %s.", collector.toErrorString()));

http://git-wip-us.apache.org/repos/asf/drill/blob/74517f5d/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/RepeatedMapVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/RepeatedMapVector.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/RepeatedMapVector.java
index ad8c66f..eb045d0 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/RepeatedMapVector.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/RepeatedMapVector.java
@@ -159,8 +159,8 @@ public class RepeatedMapVector extends AbstractMapVector implements RepeatedFixe
     }
   }
 
-  public TransferPair getTransferPairToSingleMap() {
-    return new SingleMapTransferPair(this, getField());
+  public TransferPair getTransferPairToSingleMap(FieldReference reference) {
+    return new SingleMapTransferPair(this, reference);
   }
 
   @Override
@@ -183,8 +183,8 @@ public class RepeatedMapVector extends AbstractMapVector implements RepeatedFixe
     private final MapVector to;
     private static final MajorType MAP_TYPE = Types.required(MinorType.MAP);
 
-    public SingleMapTransferPair(RepeatedMapVector from, MaterializedField field) {
-      this(from, new MapVector(MaterializedField.create(field.getPath(), MAP_TYPE), from.allocator,
from.callBack), false);
+    public SingleMapTransferPair(RepeatedMapVector from, SchemaPath path) {
+      this(from, new MapVector(MaterializedField.create(path, MAP_TYPE), from.allocator,
from.callBack), false);
     }
 
     public SingleMapTransferPair(RepeatedMapVector from, MapVector to) {


Mime
View raw message