drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject [1/3] drill git commit: DRILL-4382: Remove dependency on drill-logical from vector package
Date Tue, 16 Feb 2016 21:10:32 GMT
Repository: drill
Updated Branches:
  refs/heads/master 0a2518d7c -> 9a3a5c4ff


http://git-wip-us.apache.org/repos/asf/drill/blob/9a3a5c4f/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/FieldIdUtil.java
----------------------------------------------------------------------
diff --git a/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/FieldIdUtil.java
b/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/FieldIdUtil.java
deleted file mode 100644
index 935e93c..0000000
--- a/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/FieldIdUtil.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.drill.exec.vector.complex;
-
-import org.apache.drill.common.expression.PathSegment;
-import org.apache.drill.common.expression.SchemaPath;
-import org.apache.drill.common.types.TypeProtos.DataMode;
-import org.apache.drill.common.types.TypeProtos.MajorType;
-import org.apache.drill.common.types.TypeProtos.MinorType;
-import org.apache.drill.exec.record.TypedFieldId;
-import org.apache.drill.exec.vector.ValueVector;
-
-import java.util.List;
-
-public class FieldIdUtil {
-  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(FieldIdUtil.class);
-  public static TypedFieldId getFieldIdIfMatches(ValueVector vector, TypedFieldId.Builder
builder, boolean addToBreadCrumb, PathSegment seg) {
-    if (seg == null) {
-      if (addToBreadCrumb) {
-        builder.intermediateType(vector.getField().getType());
-      }
-      return builder.finalType(vector.getField().getType()).build();
-    }
-
-    if (seg.isArray()) {
-      if (seg.isLastPath()) {
-        MajorType type;
-        if (vector instanceof AbstractContainerVector) {
-          type = ((AbstractContainerVector) vector).getLastPathType();
-        } else if (vector instanceof ListVector) {
-          type = ((ListVector) vector).getDataVector().getField().getType();
-          builder.listVector();
-        } else {
-          throw new UnsupportedOperationException("FieldIdUtil does not support vector of
type " + vector.getField().getType());
-        }
-        builder //
-                .withIndex() //
-                .finalType(type);
-
-        // remainder starts with the 1st array segment in SchemaPath.
-        // only set remainder when it's the only array segment.
-        if (addToBreadCrumb) {
-          addToBreadCrumb = false;
-          builder.remainder(seg);
-        }
-        return builder.build();
-      } else {
-        if (addToBreadCrumb) {
-          addToBreadCrumb = false;
-          builder.remainder(seg);
-        }
-      }
-    } else {
-      if (vector instanceof ListVector) {
-        return null;
-      }
-    }
-
-    ValueVector v;
-    if (vector instanceof AbstractContainerVector) {
-      VectorWithOrdinal vord = ((AbstractContainerVector) vector).getChildVectorWithOrdinal(seg.isArray()
? null : seg.getNameSegment().getPath());
-      if (vord == null) {
-        return null;
-      }
-      v = vord.vector;
-      if (addToBreadCrumb) {
-        builder.intermediateType(v.getField().getType());
-        builder.addId(vord.ordinal);
-      }
-    } else if (vector instanceof ListVector) {
-      v = ((ListVector) vector).getDataVector();
-    } else {
-      throw new UnsupportedOperationException("FieldIdUtil does not support vector of type
" + vector.getField().getType());
-    }
-
-    if (v instanceof AbstractContainerVector) {
-      // we're looking for a multi path.
-      AbstractContainerVector c = (AbstractContainerVector) v;
-      return c.getFieldIdIfMatches(builder, addToBreadCrumb, seg.getChild());
-    } else if(v instanceof ListVector) {
-      ListVector list = (ListVector) v;
-      return list.getFieldIdIfMatches(builder, addToBreadCrumb, seg.getChild());
-    } else if (v instanceof  UnionVector) {
-      return ((UnionVector) v).getFieldIdIfMatches(builder, addToBreadCrumb, seg.getChild());
-    } else {
-      if (seg.isNamed()) {
-        if(addToBreadCrumb) {
-          builder.intermediateType(v.getField().getType());
-        }
-        builder.finalType(v.getField().getType());
-      } else {
-        builder.finalType(v.getField().getType().toBuilder().setMode(DataMode.OPTIONAL).build());
-      }
-
-      if (seg.isLastPath()) {
-        return builder.build();
-      } else {
-        PathSegment child = seg.getChild();
-        if (child.isLastPath() && child.isArray()) {
-          if (addToBreadCrumb) {
-            builder.remainder(child);
-          }
-          builder.withIndex();
-          builder.finalType(v.getField().getType().toBuilder().setMode(DataMode.OPTIONAL).build());
-          return builder.build();
-        } else {
-          logger.warn("You tried to request a complex type inside a scalar object or path
or type is wrong.");
-          return null;
-        }
-      }
-    }
-  }
-
-  public static TypedFieldId getFieldId(ValueVector vector, int id, SchemaPath expectedPath,
boolean hyper) {
-    if (!expectedPath.getRootSegment().segmentEquals(vector.getField().getPath().getRootSegment()))
{
-      return null;
-    }
-    PathSegment seg = expectedPath.getRootSegment();
-
-    TypedFieldId.Builder builder = TypedFieldId.newBuilder();
-    if (hyper) {
-      builder.hyper();
-    }
-    if (vector instanceof UnionVector) {
-      builder.addId(id).remainder(expectedPath.getRootSegment().getChild());
-      List<MinorType> minorTypes = ((UnionVector) vector).getSubTypes();
-      MajorType.Builder majorTypeBuilder = MajorType.newBuilder().setMinorType(MinorType.UNION);
-      for (MinorType type : minorTypes) {
-        majorTypeBuilder.addSubType(type);
-      }
-      MajorType majorType = majorTypeBuilder.build();
-      builder.intermediateType(majorType);
-      if (seg.isLastPath()) {
-        builder.finalType(majorType);
-        return builder.build();
-      } else {
-        return ((UnionVector) vector).getFieldIdIfMatches(builder, false, seg.getChild());
-      }
-    } else if (vector instanceof ListVector) {
-      ListVector list = (ListVector) vector;
-      builder.intermediateType(vector.getField().getType());
-      builder.addId(id);
-      return list.getFieldIdIfMatches(builder, true, expectedPath.getRootSegment().getChild());
-    } else
-    if (vector instanceof AbstractContainerVector) {
-      // we're looking for a multi path.
-      AbstractContainerVector c = (AbstractContainerVector) vector;
-      builder.intermediateType(vector.getField().getType());
-      builder.addId(id);
-      return c.getFieldIdIfMatches(builder, true, expectedPath.getRootSegment().getChild());
-
-    } else {
-      builder.intermediateType(vector.getField().getType());
-      builder.addId(id);
-      builder.finalType(vector.getField().getType());
-      if (seg.isLastPath()) {
-        return builder.build();
-      } else {
-        PathSegment child = seg.getChild();
-        if (child.isArray() && child.isLastPath()) {
-          builder.remainder(child);
-          builder.withIndex();
-          builder.finalType(vector.getField().getType().toBuilder().setMode(DataMode.OPTIONAL).build());
-          return builder.build();
-        } else {
-          return null;
-        }
-
-      }
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/9a3a5c4f/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/ListVector.java
----------------------------------------------------------------------
diff --git a/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/ListVector.java
b/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/ListVector.java
index 10975f5..ba30241 100644
--- a/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/ListVector.java
+++ b/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/ListVector.java
@@ -20,9 +20,6 @@ package org.apache.drill.exec.vector.complex;
 
 import com.google.common.collect.ObjectArrays;
 import io.netty.buffer.DrillBuf;
-import org.apache.drill.common.expression.FieldReference;
-import org.apache.drill.common.expression.PathSegment;
-import org.apache.drill.common.types.TypeProtos.DataMode;
 import org.apache.drill.common.types.TypeProtos.MinorType;
 import org.apache.drill.common.types.Types;
 import org.apache.drill.exec.memory.BufferAllocator;
@@ -30,7 +27,6 @@ import org.apache.drill.exec.exception.OutOfMemoryException;
 import org.apache.drill.exec.proto.UserBitShared;
 import org.apache.drill.exec.record.MaterializedField;
 import org.apache.drill.exec.record.TransferPair;
-import org.apache.drill.exec.record.TypedFieldId;
 import org.apache.drill.exec.util.CallBack;
 import org.apache.drill.exec.util.JsonStringArrayList;
 import org.apache.drill.exec.vector.AddOrGetResult;
@@ -103,7 +99,7 @@ public class ListVector extends BaseRepeatedValueVector {
   }
 
   @Override
-  public TransferPair getTransferPair(FieldReference ref, BufferAllocator allocator) {
+  public TransferPair getTransferPair(String ref, BufferAllocator allocator) {
     return new TransferImpl(field.withPath(ref), allocator);
   }
 
@@ -263,10 +259,6 @@ public class ListVector extends BaseRepeatedValueVector {
     return vector;
   }
 
-  public TypedFieldId getFieldIdIfMatches(TypedFieldId.Builder builder, boolean addToBreadCrumb,
PathSegment seg) {
-    return FieldIdUtil.getFieldIdIfMatches(this, builder, addToBreadCrumb, seg);
-  }
-
   private int lastSet;
 
   public class Accessor extends BaseRepeatedAccessor {

http://git-wip-us.apache.org/repos/asf/drill/blob/9a3a5c4f/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/MapVector.java
----------------------------------------------------------------------
diff --git a/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/MapVector.java
b/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/MapVector.java
index 6784ed4..976b183 100644
--- a/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/MapVector.java
+++ b/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/MapVector.java
@@ -26,8 +26,6 @@ import java.util.Map;
 
 import javax.annotation.Nullable;
 
-import org.apache.drill.common.expression.FieldReference;
-import org.apache.drill.common.expression.SchemaPath;
 import org.apache.drill.common.types.TypeProtos.MajorType;
 import org.apache.drill.common.types.TypeProtos.MinorType;
 import org.apache.drill.common.types.Types;
@@ -60,7 +58,7 @@ public class MapVector extends AbstractMapVector {
   private int valueCount;
 
   public MapVector(String path, BufferAllocator allocator, CallBack callBack){
-    this(MaterializedField.create(SchemaPath.getSimplePath(path), TYPE), allocator, callBack);
+    this(MaterializedField.create(path, TYPE), allocator, callBack);
   }
 
   public MapVector(MaterializedField field, BufferAllocator allocator, CallBack callBack){
@@ -153,7 +151,7 @@ public class MapVector extends AbstractMapVector {
   }
 
   @Override
-  public TransferPair getTransferPair(FieldReference ref, BufferAllocator allocator) {
+  public TransferPair getTransferPair(String ref, BufferAllocator allocator) {
     return new MapTransferPair(this, ref, allocator);
   }
 
@@ -162,7 +160,7 @@ public class MapVector extends AbstractMapVector {
     private final MapVector from;
     private final MapVector to;
 
-    public MapTransferPair(MapVector from, SchemaPath path, BufferAllocator allocator) {
+    public MapTransferPair(MapVector from, String path, BufferAllocator allocator) {
       this(from, new MapVector(MaterializedField.create(path, TYPE), allocator, from.callBack),
false);
     }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/9a3a5c4f/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/RepeatedListVector.java
----------------------------------------------------------------------
diff --git a/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/RepeatedListVector.java
b/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/RepeatedListVector.java
index 4706999..50f357f 100644
--- a/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/RepeatedListVector.java
+++ b/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/RepeatedListVector.java
@@ -24,8 +24,6 @@ import io.netty.buffer.DrillBuf;
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.drill.common.expression.FieldReference;
-import org.apache.drill.common.expression.SchemaPath;
 import org.apache.drill.common.types.TypeProtos.MajorType;
 import org.apache.drill.common.types.TypeProtos.MinorType;
 import org.apache.drill.common.types.Types;
@@ -64,7 +62,7 @@ public class RepeatedListVector extends AbstractContainerVector
 
       @Override
       public Object getObject(int index) {
-        final List<Object> list = new JsonStringArrayList();
+        final List<Object> list = new JsonStringArrayList<>();
         final int start = offsets.getAccessor().get(index);
         final int until = offsets.getAccessor().get(index+1);
         for (int i = start; i < until; i++) {
@@ -172,7 +170,7 @@ public class RepeatedListVector extends AbstractContainerVector
       }
     }
 
-    public DelegateRepeatedVector(SchemaPath path, BufferAllocator allocator) {
+    public DelegateRepeatedVector(String path, BufferAllocator allocator) {
       this(MaterializedField.create(path, TYPE), allocator);
     }
 
@@ -189,7 +187,7 @@ public class RepeatedListVector extends AbstractContainerVector
     }
 
     @Override
-    public TransferPair getTransferPair(FieldReference ref, BufferAllocator allocator) {
+    public TransferPair getTransferPair(String ref, BufferAllocator allocator) {
       return makeTransferPair(new DelegateRepeatedVector(ref, allocator));
     }
 
@@ -250,7 +248,7 @@ public class RepeatedListVector extends AbstractContainerVector
     }
   }
 
-  public RepeatedListVector(SchemaPath path, BufferAllocator allocator, CallBack callBack)
{
+  public RepeatedListVector(String path, BufferAllocator allocator, CallBack callBack) {
     this(MaterializedField.create(path, TYPE), allocator, callBack);
   }
 
@@ -315,6 +313,7 @@ public class RepeatedListVector extends AbstractContainerVector
     if (result.isCreated() && callBack != null) {
       callBack.doWork();
     }
+    this.field = delegate.getField();
     return result;
   }
 
@@ -349,7 +348,7 @@ public class RepeatedListVector extends AbstractContainerVector
   }
 
   @Override
-  public TransferPair getTransferPair(FieldReference ref, BufferAllocator allocator) {
+  public TransferPair getTransferPair(String ref, BufferAllocator allocator) {
     return new RepeatedListTransferPair(delegate.getTransferPair(ref, allocator));
   }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/9a3a5c4f/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/RepeatedMapVector.java
----------------------------------------------------------------------
diff --git a/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/RepeatedMapVector.java
b/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/RepeatedMapVector.java
index b13de9d..cc3eedc 100644
--- a/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/RepeatedMapVector.java
+++ b/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/RepeatedMapVector.java
@@ -24,9 +24,6 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.lang3.ArrayUtils;
-import org.apache.drill.common.expression.FieldReference;
-import org.apache.drill.common.expression.PathSegment;
-import org.apache.drill.common.expression.SchemaPath;
 import org.apache.drill.common.types.TypeProtos.DataMode;
 import org.apache.drill.common.types.TypeProtos.MajorType;
 import org.apache.drill.common.types.TypeProtos.MinorType;
@@ -39,7 +36,6 @@ import org.apache.drill.exec.memory.BufferAllocator;
 import org.apache.drill.exec.proto.UserBitShared.SerializedField;
 import org.apache.drill.exec.record.MaterializedField;
 import org.apache.drill.exec.record.TransferPair;
-import org.apache.drill.exec.record.TypedFieldId;
 import org.apache.drill.exec.util.CallBack;
 import org.apache.drill.exec.util.JsonStringArrayList;
 import org.apache.drill.exec.vector.AddOrGetResult;
@@ -204,32 +200,12 @@ public class RepeatedMapVector extends AbstractMapVector
     }
   }
 
-  @Override
-  public TypedFieldId getFieldIdIfMatches(TypedFieldId.Builder builder, boolean addToBreadCrumb,
PathSegment seg) {
-    if (seg != null && seg.isArray() && !seg.isLastPath()) {
-      if (addToBreadCrumb) {
-        addToBreadCrumb = false;
-        builder.remainder(seg);
-      }
-      // skip the first array segment as there is no corresponding child vector.
-      seg = seg.getChild();
-
-      // multi-level numbered access to a repeated map is not possible so return if the next
part is also an array
-      // segment.
-      if (seg.isArray()) {
-        return null;
-      }
-    }
-
-    return super.getFieldIdIfMatches(builder, addToBreadCrumb, seg);
-  }
-
-  public TransferPair getTransferPairToSingleMap(FieldReference reference, BufferAllocator
allocator) {
+  public TransferPair getTransferPairToSingleMap(String reference, BufferAllocator allocator)
{
     return new SingleMapTransferPair(this, reference, allocator);
   }
 
   @Override
-  public TransferPair getTransferPair(FieldReference ref, BufferAllocator allocator) {
+  public TransferPair getTransferPair(String ref, BufferAllocator allocator) {
     return new RepeatedMapTransferPair(this, ref, allocator);
   }
 
@@ -261,7 +237,7 @@ public class RepeatedMapVector extends AbstractMapVector
     private final MapVector to;
     private static final MajorType MAP_TYPE = Types.required(MinorType.MAP);
 
-    public SingleMapTransferPair(RepeatedMapVector from, SchemaPath path, BufferAllocator
allocator) {
+    public SingleMapTransferPair(RepeatedMapVector from, String path, BufferAllocator allocator)
{
       this(from, new MapVector(MaterializedField.create(path, MAP_TYPE), allocator, from.callBack),
false);
     }
 
@@ -326,7 +302,7 @@ public class RepeatedMapVector extends AbstractMapVector
     private final RepeatedMapVector to;
     private final RepeatedMapVector from;
 
-    public RepeatedMapTransferPair(RepeatedMapVector from, SchemaPath path, BufferAllocator
allocator) {
+    public RepeatedMapTransferPair(RepeatedMapVector from, String path, BufferAllocator allocator)
{
       this(from, new RepeatedMapVector(MaterializedField.create(path, TYPE), allocator, from.callBack),
false);
     }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/9a3a5c4f/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/impl/PromotableWriter.java
----------------------------------------------------------------------
diff --git a/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/impl/PromotableWriter.java
b/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/impl/PromotableWriter.java
index ee16e97..13e9a9e 100644
--- a/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/impl/PromotableWriter.java
+++ b/exec/vector/src/main/java/org/apache/drill/exec/vector/complex/impl/PromotableWriter.java
@@ -19,7 +19,6 @@ package org.apache.drill.exec.vector.complex.impl;
 
 import java.lang.reflect.Constructor;
 
-import org.apache.drill.common.expression.FieldReference;
 import org.apache.drill.common.types.TypeProtos.MinorType;
 import org.apache.drill.common.types.Types;
 import org.apache.drill.exec.expr.BasicTypeHelper;
@@ -151,7 +150,7 @@ public class PromotableWriter extends AbstractPromotableFieldWriter {
 
   private FieldWriter promoteToUnion() {
     String name = vector.getField().getLastName();
-    TransferPair tp = vector.getTransferPair(new FieldReference(vector.getField().getType().getMinorType().name().toLowerCase()),
vector.getAllocator());
+    TransferPair tp = vector.getTransferPair(vector.getField().getType().getMinorType().name().toLowerCase(),
vector.getAllocator());
     tp.transfer();
     if (parentContainer != null) {
       unionVector = parentContainer.addOrGet(name, Types.optional(MinorType.UNION), UnionVector.class);


Mime
View raw message