drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jacq...@apache.org
Subject [10/45] drill git commit: DRILL-3987: (MOVE) Extract key vector, field reader, complex/field writer classes.
Date Fri, 13 Nov 2015 02:37:40 GMT
http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/BaseValueVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/BaseValueVector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/BaseValueVector.java
deleted file mode 100644
index eb5dbcd..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/BaseValueVector.java
+++ /dev/null
@@ -1,123 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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;
-
-import io.netty.buffer.DrillBuf;
-
-import java.util.Iterator;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Iterators;
-
-import org.apache.drill.common.expression.FieldReference;
-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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class BaseValueVector implements ValueVector {
-  private static final Logger logger = LoggerFactory.getLogger(BaseValueVector.class);
-
-  public static final int MAX_ALLOCATION_SIZE = Integer.MAX_VALUE;
-  public static final int INITIAL_VALUE_ALLOCATION = 4096;
-
-  protected final BufferAllocator allocator;
-  protected final MaterializedField field;
-
-  protected BaseValueVector(MaterializedField field, BufferAllocator allocator) {
-    this.field = Preconditions.checkNotNull(field, "field cannot be null");
-    this.allocator = Preconditions.checkNotNull(allocator, "allocator cannot be null");
-  }
-
-  @Override
-  public String toString() {
-    return super.toString() + "[field = " + field + ", ...]";
-  }
-
-  @Override
-  public void clear() {
-    getMutator().reset();
-  }
-
-  @Override
-  public void close() {
-    clear();
-  }
-
-  @Override
-  public MaterializedField getField() {
-    return field;
-  }
-
-  public MaterializedField getField(FieldReference ref){
-    return getField().withPath(ref);
-  }
-
-  @Override
-  public TransferPair getTransferPair() {
-    return getTransferPair(new FieldReference(getField().getPath()));
-  }
-
-  @Override
-  public SerializedField getMetadata() {
-    return getMetadataBuilder().build();
-  }
-
-  protected SerializedField.Builder getMetadataBuilder() {
-    return getField().getAsBuilder()
-        .setValueCount(getAccessor().getValueCount())
-        .setBufferLength(getBufferSize());
-  }
-
-  public abstract static class BaseAccessor implements ValueVector.Accessor {
-    protected BaseAccessor() { }
-
-    @Override
-    public boolean isNull(int index) {
-      return false;
-    }
-  }
-
-  public abstract static class BaseMutator implements ValueVector.Mutator {
-    protected BaseMutator() { }
-
-    @Override
-    public void generateTestData(int values) {}
-
-    //TODO: consider making mutator stateless(if possible) on another issue.
-    public void reset() {}
-  }
-
-  @Override
-  public Iterator<ValueVector> iterator() {
-    return Iterators.emptyIterator();
-  }
-
-  public static boolean checkBufRefs(final ValueVector vv) {
-    for(final DrillBuf buffer : vv.getBuffers(false)) {
-      if (buffer.refCnt() <= 0) {
-        throw new IllegalStateException("zero refcount");
-      }
-    }
-
-    return true;
-  }
-}
-

http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/BitVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/BitVector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/BitVector.java
deleted file mode 100644
index 67ba5c4..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/BitVector.java
+++ /dev/null
@@ -1,448 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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;
-
-import com.google.common.base.Preconditions;
-import io.netty.buffer.DrillBuf;
-
-import org.apache.drill.common.expression.FieldReference;
-import org.apache.drill.exec.exception.OversizedAllocationException;
-import org.apache.drill.exec.expr.holders.BitHolder;
-import org.apache.drill.exec.expr.holders.NullableBitHolder;
-import org.apache.drill.exec.memory.BufferAllocator;
-import org.apache.drill.exec.memory.OutOfMemoryRuntimeException;
-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.vector.complex.impl.BitReaderImpl;
-import org.apache.drill.exec.vector.complex.reader.FieldReader;
-
-/**
- * Bit implements a vector of bit-width values. Elements in the vector are accessed by position from the logical start
- * of the vector. The width of each element is 1 bit. The equivalent Java primitive is an int containing the value '0'
- * or '1'.
- */
-public final class BitVector extends BaseDataValueVector implements FixedWidthVector {
-  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(BitVector.class);
-
-  private final FieldReader reader = new BitReaderImpl(BitVector.this);
-  private final Accessor accessor = new Accessor();
-  private final Mutator mutator = new Mutator();
-
-  private int valueCount;
-  private int allocationSizeInBytes = INITIAL_VALUE_ALLOCATION;
-  private int allocationMonitor = 0;
-
-  public BitVector(MaterializedField field, BufferAllocator allocator) {
-    super(field, allocator);
-  }
-
-  @Override
-  public FieldReader getReader() {
-    return reader;
-  }
-
-  @Override
-  public int getBufferSize() {
-    return getSizeFromCount(valueCount);
-  }
-
-  @Override
-  public int getBufferSizeFor(final int valueCount) {
-    return getSizeFromCount(valueCount);
-  }
-
-  private int getSizeFromCount(int valueCount) {
-    return (int) Math.ceil(valueCount / 8.0);
-  }
-
-  @Override
-  public int getValueCapacity() {
-    return (int)Math.min((long)Integer.MAX_VALUE, data.capacity() * 8L);
-  }
-
-  private int getByteIndex(int index) {
-    return (int) Math.floor(index / 8.0);
-  }
-
-  @Override
-  public void setInitialCapacity(final int valueCount) {
-    allocationSizeInBytes = getSizeFromCount(valueCount);
-  }
-
-  @Override
-  public void allocateNew() {
-    if (!allocateNewSafe()) {
-      throw new OutOfMemoryRuntimeException();
-    }
-  }
-
-  @Override
-  public boolean allocateNewSafe() {
-    long curAllocationSize = allocationSizeInBytes;
-    if (allocationMonitor > 10) {
-      curAllocationSize = Math.max(8, allocationSizeInBytes / 2);
-      allocationMonitor = 0;
-    } else if (allocationMonitor < -2) {
-      curAllocationSize = allocationSizeInBytes * 2L;
-      allocationMonitor = 0;
-    }
-
-    try {
-      allocateBytes(curAllocationSize);
-    } catch (OutOfMemoryRuntimeException ex) {
-      return false;
-    }
-    return true;
-  }
-
-  @Override
-  public void reset() {
-    valueCount = 0;
-    allocationSizeInBytes = INITIAL_VALUE_ALLOCATION;
-    allocationMonitor = 0;
-    zeroVector();
-    super.reset();
-  }
-
-  /**
-   * Allocate a new memory space for this vector. Must be called prior to using the ValueVector.
-   *
-   * @param valueCount
-   *          The number of values which can be contained within this vector.
-   */
-  @Override
-  public void allocateNew(int valueCount) {
-    final int size = getSizeFromCount(valueCount);
-    allocateBytes(size);
-  }
-
-  private void allocateBytes(final long size) {
-    if (size > MAX_ALLOCATION_SIZE) {
-      throw new OversizedAllocationException("Requested amount of memory is more than max allowed allocation size");
-    }
-
-    final int curSize = (int) size;
-    clear();
-    data = allocator.buffer(curSize);
-    zeroVector();
-    allocationSizeInBytes = curSize;
-  }
-
-  /**
-   * Allocate new buffer with double capacity, and copy data into the new buffer. Replace vector's buffer with new buffer, and release old one
-   */
-  public void reAlloc() {
-    final long newAllocationSize = allocationSizeInBytes * 2L;
-    if (newAllocationSize > MAX_ALLOCATION_SIZE) {
-      throw new OversizedAllocationException("Requested amount of memory is more than max allowed allocation size");
-    }
-
-    final int curSize = (int)newAllocationSize;
-    final DrillBuf newBuf = allocator.buffer(curSize);
-    newBuf.setZero(0, newBuf.capacity());
-    newBuf.setBytes(0, data, 0, data.capacity());
-    data.release();
-    data = newBuf;
-    allocationSizeInBytes = curSize;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void zeroVector() {
-    data.setZero(0, data.capacity());
-  }
-
-  public void copyFrom(int inIndex, int outIndex, BitVector from) {
-    this.mutator.set(outIndex, from.accessor.get(inIndex));
-  }
-
-  public boolean copyFromSafe(int inIndex, int outIndex, BitVector from) {
-    if (outIndex >= this.getValueCapacity()) {
-      decrementAllocationMonitor();
-      return false;
-    }
-    copyFrom(inIndex, outIndex, from);
-    return true;
-  }
-
-  @Override
-  public void load(SerializedField metadata, DrillBuf buffer) {
-    Preconditions.checkArgument(this.field.matches(metadata), "The field %s doesn't match the provided metadata %s.", this.field, metadata);
-    final int valueCount = metadata.getValueCount();
-    final int expectedLength = getSizeFromCount(valueCount);
-    final int actualLength = metadata.getBufferLength();
-    assert expectedLength == actualLength: "expected and actual buffer sizes do not match";
-
-    clear();
-    data = buffer.slice(0, actualLength);
-    data.retain();
-    this.valueCount = valueCount;
-  }
-
-  @Override
-  public Mutator getMutator() {
-    return new Mutator();
-  }
-
-  @Override
-  public Accessor getAccessor() {
-    return new Accessor();
-  }
-
-  @Override
-  public TransferPair getTransferPair() {
-    return new TransferImpl(getField());
-  }
-
-  @Override
-  public TransferPair getTransferPair(FieldReference ref) {
-    return new TransferImpl(getField().withPath(ref));
-  }
-
-  @Override
-  public TransferPair makeTransferPair(ValueVector to) {
-    return new TransferImpl((BitVector) to);
-  }
-
-
-  public void transferTo(BitVector target) {
-    target.clear();
-    if (target.data != null) {
-      target.data.release();
-    }
-    target.data = data;
-    target.data.retain(1);
-    target.valueCount = valueCount;
-    clear();
-  }
-
-  public void splitAndTransferTo(int startIndex, int length, BitVector target) {
-    assert startIndex + length <= valueCount;
-    int firstByte = getByteIndex(startIndex);
-    int byteSize = getSizeFromCount(length);
-    int offset = startIndex % 8;
-    if (offset == 0) {
-      target.clear();
-      // slice
-      if (target.data != null) {
-        target.data.release();
-      }
-      target.data = (DrillBuf) data.slice(firstByte, byteSize);
-      target.data.retain(1);
-    } else {
-      // Copy data
-      // When the first bit starts from the middle of a byte (offset != 0), copy data from src BitVector.
-      // Each byte in the target is composed by a part in i-th byte, another part in (i+1)-th byte.
-      // The last byte copied to target is a bit tricky :
-      //   1) if length requires partly byte (length % 8 !=0), copy the remaining bits only.
-      //   2) otherwise, copy the last byte in the same way as to the prior bytes.
-      target.clear();
-      target.allocateNew(length);
-      // TODO maybe do this one word at a time, rather than byte?
-      for(int i = 0; i < byteSize - 1; i++) {
-        target.data.setByte(i, (((this.data.getByte(firstByte + i) & 0xFF) >>> offset) + (this.data.getByte(firstByte + i + 1) <<  (8 - offset))));
-      }
-      if (length % 8 != 0) {
-        target.data.setByte(byteSize - 1, ((this.data.getByte(firstByte + byteSize - 1) & 0xFF) >>> offset));
-      } else {
-        target.data.setByte(byteSize - 1,
-            (((this.data.getByte(firstByte + byteSize - 1) & 0xFF) >>> offset) + (this.data.getByte(firstByte + byteSize) <<  (8 - offset))));
-      }
-    }
-    target.getMutator().setValueCount(length);
-  }
-
-  private class TransferImpl implements TransferPair {
-    BitVector to;
-
-    public TransferImpl(MaterializedField field) {
-      this.to = new BitVector(field, allocator);
-    }
-
-    public TransferImpl(BitVector to) {
-      this.to = to;
-    }
-
-    @Override
-    public BitVector getTo() {
-      return to;
-    }
-
-    @Override
-    public void transfer() {
-      transferTo(to);
-    }
-
-    @Override
-    public void splitAndTransfer(int startIndex, int length) {
-      splitAndTransferTo(startIndex, length, to);
-    }
-
-    @Override
-    public void copyValueSafe(int fromIndex, int toIndex) {
-      to.copyFromSafe(fromIndex, toIndex, BitVector.this);
-    }
-  }
-
-  private void decrementAllocationMonitor() {
-    if (allocationMonitor > 0) {
-      allocationMonitor = 0;
-    }
-    --allocationMonitor;
-  }
-
-  private void incrementAllocationMonitor() {
-    ++allocationMonitor;
-  }
-
-  public class Accessor extends BaseAccessor {
-
-    /**
-     * Get the byte holding the desired bit, then mask all other bits. Iff the result is 0, the bit was not set.
-     *
-     * @param index
-     *          position of the bit in the vector
-     * @return 1 if set, otherwise 0
-     */
-    public final int get(int index) {
-      int byteIndex = index >> 3;
-      byte b = data.getByte(byteIndex);
-      int bitIndex = index & 7;
-      return Long.bitCount(b &  (1L << bitIndex));
-    }
-
-    @Override
-    public boolean isNull(int index) {
-      return false;
-    }
-
-    @Override
-    public final Boolean getObject(int index) {
-      return new Boolean(get(index) != 0);
-    }
-
-    @Override
-    public final int getValueCount() {
-      return valueCount;
-    }
-
-    public final void get(int index, BitHolder holder) {
-      holder.value = get(index);
-    }
-
-    public final void get(int index, NullableBitHolder holder) {
-      holder.isSet = 1;
-      holder.value = get(index);
-    }
-  }
-
-  /**
-   * MutableBit implements a vector of bit-width values. Elements in the vector are accessed by position from the
-   * logical start of the vector. Values should be pushed onto the vector sequentially, but may be randomly accessed.
-   *
-   * NB: this class is automatically generated from ValueVectorTypes.tdd using FreeMarker.
-   */
-  public class Mutator extends BaseMutator {
-
-    private Mutator() {
-    }
-
-    /**
-     * Set the bit at the given index to the specified value.
-     *
-     * @param index
-     *          position of the bit to set
-     * @param value
-     *          value to set (either 1 or 0)
-     */
-    public final void set(int index, int value) {
-      int byteIndex = index >> 3;
-      int bitIndex = index & 7;
-      byte currentByte = data.getByte(byteIndex);
-      byte bitMask = (byte) (1L << bitIndex);
-      if (value != 0) {
-        currentByte |= bitMask;
-      } else {
-        currentByte -= (bitMask & currentByte);
-      }
-
-      data.setByte(byteIndex, currentByte);
-    }
-
-    public final void set(int index, BitHolder holder) {
-      set(index, holder.value);
-    }
-
-    final void set(int index, NullableBitHolder holder) {
-      set(index, holder.value);
-    }
-
-    public void setSafe(int index, int value) {
-      while(index >= getValueCapacity()) {
-        reAlloc();
-      }
-      set(index, value);
-    }
-
-    public void setSafe(int index, BitHolder holder) {
-      while(index >= getValueCapacity()) {
-        reAlloc();
-      }
-      set(index, holder.value);
-    }
-
-    public void setSafe(int index, NullableBitHolder holder) {
-      while(index >= getValueCapacity()) {
-        reAlloc();
-      }
-      set(index, holder.value);
-    }
-
-    @Override
-    public final void setValueCount(int valueCount) {
-      int currentValueCapacity = getValueCapacity();
-      BitVector.this.valueCount = valueCount;
-      int idx = getSizeFromCount(valueCount);
-      while(valueCount > getValueCapacity()) {
-        reAlloc();
-      }
-      if (valueCount > 0 && currentValueCapacity > valueCount * 2) {
-        incrementAllocationMonitor();
-      } else if (allocationMonitor > 0) {
-        allocationMonitor = 0;
-      }
-      VectorTrimmer.trim(data, idx);
-    }
-
-    @Override
-    public final void generateTestData(int values) {
-      boolean even = true;
-      for(int i = 0; i < values; i++, even = !even) {
-        if (even) {
-          set(i, 1);
-        }
-      }
-      setValueCount(values);
-    }
-
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/FixedWidthVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/FixedWidthVector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/FixedWidthVector.java
deleted file mode 100644
index c2781eb..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/FixedWidthVector.java
+++ /dev/null
@@ -1,35 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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;
-
-
-public interface FixedWidthVector extends ValueVector{
-
-  /**
-   * Allocate a new memory space for this vector.  Must be called prior to using the ValueVector.
-   *
-   * @param valueCount   Number of values in the vector.
-   */
-  void allocateNew(int valueCount);
-
-/**
- * Zero out the underlying buffer backing this vector.
- */
-  void zeroVector();
-
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/NullableVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/NullableVector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/NullableVector.java
deleted file mode 100644
index 8091c4c..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/NullableVector.java
+++ /dev/null
@@ -1,23 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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;
-
-public interface NullableVector extends ValueVector{
-
-  ValueVector getValuesVector();
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/NullableVectorDefinitionSetter.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/NullableVectorDefinitionSetter.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/NullableVectorDefinitionSetter.java
deleted file mode 100644
index c418751..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/NullableVectorDefinitionSetter.java
+++ /dev/null
@@ -1,23 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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;
-
-public interface NullableVectorDefinitionSetter {
-
-  public void setIndexDefined(int index);
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/ObjectVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/ObjectVector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/ObjectVector.java
deleted file mode 100644
index a7a3609..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/ObjectVector.java
+++ /dev/null
@@ -1,222 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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;
-
-import io.netty.buffer.DrillBuf;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.drill.common.expression.FieldReference;
-import org.apache.drill.exec.expr.holders.ObjectHolder;
-import org.apache.drill.exec.memory.BufferAllocator;
-import org.apache.drill.exec.memory.OutOfMemoryRuntimeException;
-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.vector.complex.reader.FieldReader;
-
-public class ObjectVector extends BaseValueVector {
-  private final Accessor accessor = new Accessor();
-  private final Mutator mutator = new Mutator();
-  private int maxCount = 0;
-  private int count = 0;
-  private int allocationSize = 4096;
-
-  private List<Object[]> objectArrayList = new ArrayList<>();
-
-  public ObjectVector(MaterializedField field, BufferAllocator allocator) {
-    super(field, allocator);
-  }
-
-  public void addNewArray() {
-    objectArrayList.add(new Object[allocationSize]);
-    maxCount += allocationSize;
-  }
-
-  @Override
-  public FieldReader getReader() {
-    throw new UnsupportedOperationException("ObjectVector does not support this");
-  }
-
-  public final class Mutator implements ValueVector.Mutator {
-
-    public void set(int index, Object obj) {
-      int listOffset = index / allocationSize;
-      if (listOffset >= objectArrayList.size()) {
-        addNewArray();
-      }
-      objectArrayList.get(listOffset)[index % allocationSize] = obj;
-    }
-
-    public boolean setSafe(int index, long value) {
-      set(index, value);
-      return true;
-    }
-
-    protected void set(int index, ObjectHolder holder) {
-      set(index, holder.obj);
-    }
-
-    public boolean setSafe(int index, ObjectHolder holder){
-      set(index, holder);
-      return true;
-    }
-
-    @Override
-    public void setValueCount(int valueCount) {
-      count = valueCount;
-    }
-
-    @Override
-    public void reset() {
-      count = 0;
-      maxCount = 0;
-      objectArrayList = new ArrayList<>();
-      addNewArray();
-    }
-
-    @Override
-    public void generateTestData(int values) {
-    }
-  }
-
-  @Override
-  public void setInitialCapacity(int numRecords) {
-    // NoOp
-  }
-
-  @Override
-  public void allocateNew() throws OutOfMemoryRuntimeException {
-    addNewArray();
-  }
-
-  public void allocateNew(int valueCount) throws OutOfMemoryRuntimeException {
-    while (maxCount < valueCount) {
-      addNewArray();
-    }
-  }
-
-  @Override
-  public boolean allocateNewSafe() {
-    allocateNew();
-    return true;
-  }
-
-  @Override
-  public int getBufferSize() {
-    throw new UnsupportedOperationException("ObjectVector does not support this");
-  }
-
-  @Override
-  public int getBufferSizeFor(final int valueCount) {
-    throw new UnsupportedOperationException("ObjectVector does not support this");
-  }
-
-  @Override
-  public void close() {
-    clear();
-  }
-
-  @Override
-  public void clear() {
-    objectArrayList.clear();
-    maxCount = 0;
-    count = 0;
-  }
-
-  @Override
-  public MaterializedField getField() {
-    return field;
-  }
-
-  @Override
-  public TransferPair getTransferPair() {
-    throw new UnsupportedOperationException("ObjectVector does not support this");
-  }
-
-  @Override
-  public TransferPair makeTransferPair(ValueVector to) {
-    throw new UnsupportedOperationException("ObjectVector does not support this");
-  }
-
-  @Override
-  public TransferPair getTransferPair(FieldReference ref) {
-    throw new UnsupportedOperationException("ObjectVector does not support this");
-  }
-
-  @Override
-  public int getValueCapacity() {
-    return maxCount;
-  }
-
-  @Override
-  public Accessor getAccessor() {
-    return accessor;
-  }
-
-  @Override
-  public DrillBuf[] getBuffers(boolean clear) {
-    throw new UnsupportedOperationException("ObjectVector does not support this");
-  }
-
-  @Override
-  public void load(UserBitShared.SerializedField metadata, DrillBuf buffer) {
-    throw new UnsupportedOperationException("ObjectVector does not support this");
-  }
-
-  @Override
-  public UserBitShared.SerializedField getMetadata() {
-    throw new UnsupportedOperationException("ObjectVector does not support this");
-  }
-
-  @Override
-  public Mutator getMutator() {
-    return mutator;
-  }
-
-  @Override
-  public Iterator<ValueVector> iterator() {
-    throw new UnsupportedOperationException("ObjectVector does not support this");
-  }
-
-  public final class Accessor extends BaseAccessor {
-    @Override
-    public Object getObject(int index) {
-      int listOffset = index / allocationSize;
-      if (listOffset >= objectArrayList.size()) {
-        addNewArray();
-      }
-      return objectArrayList.get(listOffset)[index % allocationSize];
-    }
-
-    @Override
-    public int getValueCount() {
-      return count;
-    }
-
-    public Object get(int index) {
-      return getObject(index);
-    }
-
-    public void get(int index, ObjectHolder holder){
-      holder.obj = getObject(index);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/SchemaChangeCallBack.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/SchemaChangeCallBack.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/SchemaChangeCallBack.java
deleted file mode 100644
index 4c2491c..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/SchemaChangeCallBack.java
+++ /dev/null
@@ -1,52 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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;
-
-import org.apache.drill.exec.util.CallBack;
-
-
-public class SchemaChangeCallBack implements CallBack {
-  private boolean schemaChanged = false;
-
-  /**
-   * Constructs a schema-change callback with the schema-changed state set to
-   * {@code false}.
-   */
-  public SchemaChangeCallBack() {
-  }
-
-  /**
-   * Sets the schema-changed state to {@code true}.
-   */
-  @Override
-  public void doWork() {
-    schemaChanged = true;
-  }
-
-  /**
-   * Returns the value of schema-changed state, <strong>resetting</strong> the
-   * schema-changed state to {@code false}.
-   */
-  public boolean getSchemaChangedAndReset() {
-    final boolean current = schemaChanged;
-    schemaChanged = false;
-    return current;
-  }
-}
-

http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/ValueHolderHelper.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/ValueHolderHelper.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/ValueHolderHelper.java
deleted file mode 100644
index 42384cb..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/ValueHolderHelper.java
+++ /dev/null
@@ -1,201 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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;
-
-import io.netty.buffer.DrillBuf;
-
-import java.math.BigDecimal;
-
-import org.apache.drill.exec.expr.holders.BigIntHolder;
-import org.apache.drill.exec.expr.holders.BitHolder;
-import org.apache.drill.exec.expr.holders.DateHolder;
-import org.apache.drill.exec.expr.holders.Decimal18Holder;
-import org.apache.drill.exec.expr.holders.Decimal28SparseHolder;
-import org.apache.drill.exec.expr.holders.Decimal38SparseHolder;
-import org.apache.drill.exec.expr.holders.Decimal9Holder;
-import org.apache.drill.exec.expr.holders.Float4Holder;
-import org.apache.drill.exec.expr.holders.Float8Holder;
-import org.apache.drill.exec.expr.holders.IntHolder;
-import org.apache.drill.exec.expr.holders.IntervalDayHolder;
-import org.apache.drill.exec.expr.holders.IntervalYearHolder;
-import org.apache.drill.exec.expr.holders.NullableBitHolder;
-import org.apache.drill.exec.expr.holders.TimeHolder;
-import org.apache.drill.exec.expr.holders.TimeStampHolder;
-import org.apache.drill.exec.expr.holders.VarCharHolder;
-import org.apache.drill.exec.memory.BufferAllocator;
-import org.apache.drill.exec.util.DecimalUtility;
-
-import com.google.common.base.Charsets;
-
-
-public class ValueHolderHelper {
-  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ValueHolderHelper.class);
-
-  public static IntHolder getIntHolder(int value) {
-    IntHolder holder = new IntHolder();
-    holder.value = value;
-
-    return holder;
-  }
-
-  public static BigIntHolder getBigIntHolder(long value) {
-    BigIntHolder holder = new BigIntHolder();
-    holder.value = value;
-
-    return holder;
-  }
-
-  public static Float4Holder getFloat4Holder(float value) {
-    Float4Holder holder = new Float4Holder();
-    holder.value = value;
-
-    return holder;
-  }
-
-  public static Float8Holder getFloat8Holder(double value) {
-    Float8Holder holder = new Float8Holder();
-    holder.value = value;
-
-    return holder;
-  }
-
-  public static DateHolder getDateHolder(long value) {
-    DateHolder holder = new DateHolder();
-    holder.value = value;
-    return holder;
-  }
-
-  public static TimeHolder getTimeHolder(int value) {
-    TimeHolder holder = new TimeHolder();
-    holder.value = value;
-    return holder;
-  }
-
-  public static TimeStampHolder getTimeStampHolder(long value) {
-    TimeStampHolder holder = new TimeStampHolder();
-    holder.value = value;
-    return holder;
-  }
-
-  public static BitHolder getBitHolder(int value) {
-    BitHolder holder = new BitHolder();
-    holder.value = value;
-
-    return holder;
-  }
-
-  public static NullableBitHolder getNullableBitHolder(boolean isNull, int value) {
-    NullableBitHolder holder = new NullableBitHolder();
-    holder.isSet = isNull? 0 : 1;
-    if (! isNull) {
-      holder.value = value;
-    }
-
-    return holder;
-  }
-
-  public static VarCharHolder getVarCharHolder(DrillBuf buf, String s){
-    VarCharHolder vch = new VarCharHolder();
-
-    byte[] b = s.getBytes(Charsets.UTF_8);
-    vch.start = 0;
-    vch.end = b.length;
-    vch.buffer = buf.reallocIfNeeded(b.length);
-    vch.buffer.setBytes(0, b);
-    return vch;
-  }
-
-  public static VarCharHolder getVarCharHolder(BufferAllocator a, String s){
-    VarCharHolder vch = new VarCharHolder();
-
-    byte[] b = s.getBytes(Charsets.UTF_8);
-    vch.start = 0;
-    vch.end = b.length;
-    vch.buffer = a.buffer(b.length); //
-    vch.buffer.setBytes(0, b);
-    return vch;
-  }
-
-
-  public static IntervalYearHolder getIntervalYearHolder(int intervalYear) {
-    IntervalYearHolder holder = new IntervalYearHolder();
-
-    holder.value = intervalYear;
-    return holder;
-  }
-
-  public static IntervalDayHolder getIntervalDayHolder(int days, int millis) {
-      IntervalDayHolder dch = new IntervalDayHolder();
-
-      dch.days = days;
-      dch.milliseconds = millis;
-      return dch;
-  }
-
-  public static Decimal9Holder getDecimal9Holder(int decimal, int scale, int precision) {
-    Decimal9Holder dch = new Decimal9Holder();
-
-    dch.scale = scale;
-    dch.precision = precision;
-    dch.value = decimal;
-
-    return dch;
-  }
-
-  public static Decimal18Holder getDecimal18Holder(long decimal, int scale, int precision) {
-    Decimal18Holder dch = new Decimal18Holder();
-
-    dch.scale = scale;
-    dch.precision = precision;
-    dch.value = decimal;
-
-    return dch;
-  }
-
-  public static Decimal28SparseHolder getDecimal28Holder(DrillBuf buf, String decimal) {
-
-    Decimal28SparseHolder dch = new Decimal28SparseHolder();
-
-    BigDecimal bigDecimal = new BigDecimal(decimal);
-
-    dch.scale = bigDecimal.scale();
-    dch.precision = bigDecimal.precision();
-    Decimal28SparseHolder.setSign(bigDecimal.signum() == -1, dch.start, dch.buffer);
-    dch.start = 0;
-    dch.buffer = buf.reallocIfNeeded(5 * DecimalUtility.integerSize);
-    DecimalUtility.getSparseFromBigDecimal(bigDecimal, dch.buffer, dch.start, dch.scale, dch.precision, dch.nDecimalDigits);
-
-    return dch;
-  }
-
-  public static Decimal38SparseHolder getDecimal38Holder(DrillBuf buf, String decimal) {
-
-      Decimal38SparseHolder dch = new Decimal38SparseHolder();
-
-      BigDecimal bigDecimal = new BigDecimal(decimal);
-
-      dch.scale = bigDecimal.scale();
-      dch.precision = bigDecimal.precision();
-      Decimal38SparseHolder.setSign(bigDecimal.signum() == -1, dch.start, dch.buffer);
-      dch.start = 0;
-      dch.buffer = buf.reallocIfNeeded(dch.maxPrecision * DecimalUtility.integerSize);
-      DecimalUtility.getSparseFromBigDecimal(bigDecimal, dch.buffer, dch.start, dch.scale, dch.precision, dch.nDecimalDigits);
-
-      return dch;
-  }
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/ValueVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/ValueVector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/ValueVector.java
deleted file mode 100644
index 8627d1a..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/ValueVector.java
+++ /dev/null
@@ -1,221 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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;
-
-import java.io.Closeable;
-
-import io.netty.buffer.DrillBuf;
-
-import org.apache.drill.common.expression.FieldReference;
-import org.apache.drill.exec.memory.OutOfMemoryRuntimeException;
-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.vector.complex.reader.FieldReader;
-
-/**
- * An abstraction that is used to store a sequence of values in an individual column.
- *
- * A {@link ValueVector value vector} stores underlying data in-memory in a columnar fashion that is compact and
- * efficient. The column whose data is stored, is referred by {@link #getField()}.
- *
- * A vector when instantiated, relies on a {@link org.apache.drill.exec.record.DeadBuf dead buffer}. It is important
- * that vector is allocated before attempting to read or write.
- *
- * There are a few "rules" around vectors:
- *
- * <ul>
- *   <li>values need to be written in order (e.g. index 0, 1, 2, 5)</li>
- *   <li>null vectors start with all values as null before writing anything</li>
- *   <li>for variable width types, the offset vector should be all zeros before writing</li>
- *   <li>you must call setValueCount before a vector can be read</li>
- *   <li>you should never write to a vector once it has been read.</li>
- * </ul>
- *
- * Please note that the current implementation doesn't enfore those rules, hence we may find few places that
- * deviate from these rules (e.g. offset vectors in Variable Length and Repeated vector)
- *
- * This interface "should" strive to guarantee this order of operation:
- * <blockquote>
- * allocate > mutate > setvaluecount > access > clear (or allocate to start the process over).
- * </blockquote>
- */
-public interface ValueVector extends Closeable, Iterable<ValueVector> {
-  /**
-   * Allocate new buffers. ValueVector implements logic to determine how much to allocate.
-   * @throws OutOfMemoryRuntimeException Thrown if no memory can be allocated.
-   */
-  void allocateNew() throws OutOfMemoryRuntimeException;
-
-  /**
-   * Allocates new buffers. ValueVector implements logic to determine how much to allocate.
-   * @return Returns true if allocation was succesful.
-   */
-  boolean allocateNewSafe();
-
-  /**
-   * Set the initial record capacity
-   * @param numRecords
-   */
-  void setInitialCapacity(int numRecords);
-
-  /**
-   * Returns the maximum number of values that can be stored in this vector instance.
-   */
-  int getValueCapacity();
-
-  /**
-   * Alternative to clear(). Allows use as an AutoCloseable in try-with-resources.
-   */
-  @Override
-  void close();
-
-  /**
-   * Release the underlying DrillBuf and reset the ValueVector to empty.
-   */
-  void clear();
-
-  /**
-   * Get information about how this field is materialized.
-   */
-  MaterializedField getField();
-
-  /**
-   * Returns a {@link org.apache.drill.exec.record.TransferPair transfer pair}, creating a new target vector of
-   * the same type.
-   */
-  TransferPair getTransferPair();
-
-  TransferPair getTransferPair(FieldReference ref);
-
-  /**
-   * Returns a new {@link org.apache.drill.exec.record.TransferPair transfer pair} that is used to transfer underlying
-   * buffers into the target vector.
-   */
-  TransferPair makeTransferPair(ValueVector target);
-
-  /**
-   * Returns an {@link org.apache.drill.exec.vector.ValueVector.Accessor accessor} that is used to read from this vector
-   * instance.
-   */
-  Accessor getAccessor();
-
-  /**
-   * Returns an {@link org.apache.drill.exec.vector.ValueVector.Mutator mutator} that is used to write to this vector
-   * instance.
-   */
-  Mutator getMutator();
-
-  /**
-   * Returns a {@link org.apache.drill.exec.vector.complex.reader.FieldReader field reader} that supports reading values
-   * from this vector.
-   */
-  FieldReader getReader();
-
-  /**
-   * Get the metadata for this field. Used in serialization
-   *
-   * @return FieldMetadata for this field.
-   */
-  SerializedField getMetadata();
-
-  /**
-   * Returns the number of bytes that is used by this vector instance.
-   */
-  int getBufferSize();
-
-  /**
-   * Returns the number of bytes that is used by this vector if it holds the given number
-   * of values. The result will be the same as if Mutator.setValueCount() were called, followed
-   * by calling getBufferSize(), but without any of the closing side-effects that setValueCount()
-   * implies wrt finishing off the population of a vector. Some operations might wish to use
-   * this to determine how much memory has been used by a vector so far, even though it is
-   * not finished being populated.
-   *
-   * @param valueCount the number of values to assume this vector contains
-   * @return the buffer size if this vector is holding valueCount values
-   */
-  int getBufferSizeFor(int valueCount);
-
-  /**
-   * Return the underlying buffers associated with this vector. Note that this doesn't impact the reference counts for
-   * this buffer so it only should be used for in-context access. Also note that this buffer changes regularly thus
-   * external classes shouldn't hold a reference to it (unless they change it).
-   * @param clear Whether to clear vector before returning; the buffers will still be refcounted;
-   *   but the returned array will be the only reference to them
-   *
-   * @return The underlying {@link io.netty.buffer.DrillBuf buffers} that is used by this vector instance.
-   */
-  DrillBuf[] getBuffers(boolean clear);
-
-  /**
-   * Load the data provided in the buffer. Typically used when deserializing from the wire.
-   *
-   * @param metadata
-   *          Metadata used to decode the incoming buffer.
-   * @param buffer
-   *          The buffer that contains the ValueVector.
-   */
-  void load(SerializedField metadata, DrillBuf buffer);
-
-  /**
-   * An abstraction that is used to read from this vector instance.
-   */
-  interface Accessor {
-    /**
-     * Get the Java Object representation of the element at the specified position. Useful for testing.
-     *
-     * @param index
-     *          Index of the value to get
-     */
-    Object getObject(int index);
-
-    /**
-     * Returns the number of values that is stored in this vector.
-     */
-    int getValueCount();
-
-    /**
-     * Returns true if the value at the given index is null, false otherwise.
-     */
-    boolean isNull(int index);
-  }
-
-  /**
-   * An abstractiong that is used to write into this vector instance.
-   */
-  interface Mutator {
-    /**
-     * Sets the number of values that is stored in this vector to the given value count.
-     *
-     * @param valueCount  value count to set.
-     */
-    void setValueCount(int valueCount);
-
-    /**
-     * Resets the mutator to pristine state.
-     */
-    void reset();
-
-    /**
-     * @deprecated  this has nothing to do with value vector abstraction and should be removed.
-     */
-    @Deprecated
-    void generateTestData(int values);
-  }
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/VariableWidthVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/VariableWidthVector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/VariableWidthVector.java
deleted file mode 100644
index ee9c039..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/VariableWidthVector.java
+++ /dev/null
@@ -1,51 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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;
-
-import io.netty.buffer.DrillBuf;
-
-public interface VariableWidthVector extends ValueVector{
-
-  /**
-   * Allocate a new memory space for this vector.  Must be called prior to using the ValueVector.
-   *
-   * @param totalBytes   Desired size of the underlying data buffer.
-   * @param valueCount   Number of values in the vector.
-   */
-  void allocateNew(int totalBytes, int valueCount);
-
-  /**
-   * Provide the maximum amount of variable width bytes that can be stored int his vector.
-   * @return
-   */
-  int getByteCapacity();
-
-  VariableWidthMutator getMutator();
-
-  VariableWidthAccessor getAccessor();
-
-  interface VariableWidthAccessor extends Accessor {
-    int getValueLength(int index);
-  }
-
-  int getCurrentSizeInBytes();
-
-  interface VariableWidthMutator extends Mutator {
-    void setValueLengthSafe(int index, int length);
-  }
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/VectorDescriptor.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/VectorDescriptor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/VectorDescriptor.java
deleted file mode 100644
index 2ecaef6..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/VectorDescriptor.java
+++ /dev/null
@@ -1,83 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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;
-
-import java.util.Collection;
-
-import com.google.common.base.Preconditions;
-import org.apache.drill.common.expression.FieldReference;
-import org.apache.drill.common.types.TypeProtos;
-import org.apache.drill.exec.record.MaterializedField;
-
-public class VectorDescriptor {
-  private static final String DEFAULT_NAME = "NONE";
-
-  private final MaterializedField field;
-
-  public VectorDescriptor(final TypeProtos.MajorType type) {
-    this(DEFAULT_NAME, type);
-  }
-
-  public VectorDescriptor(final String name, final TypeProtos.MajorType type) {
-    this(MaterializedField.create(name, type));
-  }
-
-  public VectorDescriptor(final MaterializedField field) {
-    this.field = Preconditions.checkNotNull(field, "field cannot be null");
-  }
-
-  public MaterializedField getField() {
-    return field;
-  }
-
-  public TypeProtos.MajorType getType() {
-    return field.getType();
-  }
-
-  public String getName() {
-    return field.getLastName();
-  }
-
-  public Collection<MaterializedField> getChildren() {
-    return field.getChildren();
-  }
-
-  public boolean hasName() {
-    return getName() != DEFAULT_NAME;
-  }
-
-  public VectorDescriptor withName(final String name) {
-    return new VectorDescriptor(field.withPath(new FieldReference(name)));
-  }
-
-  public VectorDescriptor withType(final TypeProtos.MajorType type) {
-    return new VectorDescriptor(field.withType(type));
-  }
-
-  public static VectorDescriptor create(final String name, final TypeProtos.MajorType type) {
-    return new VectorDescriptor(name, type);
-  }
-
-  public static VectorDescriptor create(final TypeProtos.MajorType type) {
-    return new VectorDescriptor(type);
-  }
-
-  public static VectorDescriptor create(final MaterializedField field) {
-    return new VectorDescriptor(field);
-  }
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/VectorTrimmer.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/VectorTrimmer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/VectorTrimmer.java
deleted file mode 100644
index 7f977f2..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/VectorTrimmer.java
+++ /dev/null
@@ -1,33 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.DrillBuf;
-
-public class VectorTrimmer {
-  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(VectorTrimmer.class);
-
-  public static void trim(ByteBuf data, int idx) {
-    data.writerIndex(idx);
-    if (data instanceof DrillBuf) {
-      // data.capacity(idx);
-      data.writerIndex(idx);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/ZeroVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/ZeroVector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/ZeroVector.java
deleted file mode 100644
index 9fb151f..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/ZeroVector.java
+++ /dev/null
@@ -1,175 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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;
-
-import java.util.Iterator;
-
-import com.google.common.collect.Iterators;
-import io.netty.buffer.DrillBuf;
-import org.apache.drill.common.expression.FieldReference;
-import org.apache.drill.common.types.Types;
-import org.apache.drill.exec.memory.BufferAllocator;
-import org.apache.drill.exec.memory.OutOfMemoryRuntimeException;
-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.vector.complex.impl.NullReader;
-import org.apache.drill.exec.vector.complex.reader.FieldReader;
-
-public class ZeroVector implements ValueVector {
-  public final static ZeroVector INSTANCE = new ZeroVector();
-
-  private final MaterializedField field = MaterializedField.create("[DEFAULT]", Types.LATE_BIND_TYPE);
-
-  private final TransferPair defaultPair = new TransferPair() {
-    @Override
-    public void transfer() { }
-
-    @Override
-    public void splitAndTransfer(int startIndex, int length) { }
-
-    @Override
-    public ValueVector getTo() {
-      return ZeroVector.this;
-    }
-
-    @Override
-    public void copyValueSafe(int from, int to) { }
-  };
-
-  private final Accessor defaultAccessor = new Accessor() {
-    @Override
-    public Object getObject(int index) {
-      return null;
-    }
-
-    @Override
-    public int getValueCount() {
-      return 0;
-    }
-
-    @Override
-    public boolean isNull(int index) {
-      return true;
-    }
-  };
-
-  private final Mutator defaultMutator = new Mutator() {
-    @Override
-    public void setValueCount(int valueCount) { }
-
-    @Override
-    public void reset() { }
-
-    @Override
-    public void generateTestData(int values) { }
-  };
-
-  public ZeroVector() { }
-
-  @Override
-  public void close() { }
-
-  @Override
-  public void clear() { }
-
-  @Override
-  public MaterializedField getField() {
-    return field;
-  }
-
-  @Override
-  public TransferPair getTransferPair() {
-    return defaultPair;
-  }
-
-  @Override
-  public UserBitShared.SerializedField getMetadata() {
-    return getField()
-        .getAsBuilder()
-        .setBufferLength(getBufferSize())
-        .setValueCount(getAccessor().getValueCount())
-        .build();
-  }
-
-  @Override
-  public Iterator iterator() {
-    return Iterators.emptyIterator();
-  }
-
-  @Override
-  public int getBufferSize() {
-    return 0;
-  }
-
-  @Override
-  public int getBufferSizeFor(final int valueCount) {
-    return 0;
-  }
-
-  @Override
-  public DrillBuf[] getBuffers(boolean clear) {
-    return new DrillBuf[0];
-  }
-
-  @Override
-  public void allocateNew() throws OutOfMemoryRuntimeException {
-    allocateNewSafe();
-  }
-
-  @Override
-  public boolean allocateNewSafe() {
-    return true;
-  }
-
-  @Override
-  public void setInitialCapacity(int numRecords) { }
-
-  @Override
-  public int getValueCapacity() {
-    return 0;
-  }
-
-  @Override
-  public TransferPair getTransferPair(FieldReference ref) {
-    return defaultPair;
-  }
-
-  @Override
-  public TransferPair makeTransferPair(ValueVector target) {
-    return defaultPair;
-  }
-
-  @Override
-  public Accessor getAccessor() {
-    return defaultAccessor;
-  }
-
-  @Override
-  public Mutator getMutator() {
-    return defaultMutator;
-  }
-
-  @Override
-  public FieldReader getReader() {
-    return NullReader.INSTANCE;
-  }
-
-  @Override
-  public void load(UserBitShared.SerializedField metadata, DrillBuf buffer) { }
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/AbstractContainerVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/AbstractContainerVector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/AbstractContainerVector.java
deleted file mode 100644
index 5f6d0d2..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/AbstractContainerVector.java
+++ /dev/null
@@ -1,148 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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 java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-
-import javax.annotation.Nullable;
-import javax.validation.constraints.DecimalMin.List;
-
-import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import org.apache.drill.common.expression.PathSegment;
-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.memory.BufferAllocator;
-import org.apache.drill.exec.memory.OutOfMemoryRuntimeException;
-import org.apache.drill.exec.record.MaterializedField;
-import org.apache.drill.exec.record.TypedFieldId;
-import org.apache.drill.exec.util.CallBack;
-import org.apache.drill.exec.vector.ValueVector;
-
-/**
- * Base class for composite vectors.
- *
- * This class implements common functionality of composite vectors.
- */
-public abstract class AbstractContainerVector implements ValueVector {
-  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AbstractContainerVector.class);
-
-  protected final MaterializedField field;
-  protected final BufferAllocator allocator;
-  protected final CallBack callBack;
-
-  protected AbstractContainerVector(MaterializedField field, BufferAllocator allocator, CallBack callBack) {
-    this.field = Preconditions.checkNotNull(field);
-    this.allocator = allocator;
-    this.callBack = callBack;
-  }
-
-  @Override
-  public void allocateNew() throws OutOfMemoryRuntimeException {
-    if (!allocateNewSafe()) {
-      throw new OutOfMemoryRuntimeException();
-    }
-  }
-
-  /**
-   * Returns the field definition of this instance.
-   */
-  @Override
-  public MaterializedField getField() {
-    return field;
-  }
-
-  /**
-   * Returns a {@link org.apache.drill.exec.vector.ValueVector} corresponding to the given field name if exists or null.
-   */
-  public ValueVector getChild(String name) {
-    return getChild(name, ValueVector.class);
-  }
-
-  /**
-   * Returns a sequence of field names in the order that they show up in the schema.
-   */
-  protected Collection<String> getChildFieldNames() {
-    return Sets.newLinkedHashSet(Iterables.transform(field.getChildren(), new Function<MaterializedField, String>() {
-      @Nullable
-      @Override
-      public String apply(MaterializedField field) {
-        return Preconditions.checkNotNull(field).getLastName();
-      }
-    }));
-  }
-
-  /**
-   * Clears out all underlying child vectors.
-   */
- @Override
-  public void close() {
-    for (ValueVector vector:(Iterable<ValueVector>)this) {
-      vector.close();
-    }
-  }
-
-  protected <T extends ValueVector> T typeify(ValueVector v, Class<T> clazz) {
-    if (clazz.isAssignableFrom(v.getClass())) {
-      return (T) v;
-    }
-    throw new IllegalStateException(String.format("Vector requested [%s] was different than type stored [%s].  Drill doesn't yet support hetergenous types.", clazz.getSimpleName(), v.getClass().getSimpleName()));
-  }
-
-  public TypedFieldId getFieldIdIfMatches(TypedFieldId.Builder builder, boolean addToBreadCrumb, PathSegment seg) {
-    return FieldIdUtil.getFieldIdIfMatches(this, builder, addToBreadCrumb, seg);
-  }
-
-  MajorType getLastPathType() {
-    if((this.getField().getType().getMinorType() == MinorType.LIST  &&
-        this.getField().getType().getMode() == DataMode.REPEATED)) {  // Use Repeated scalar type instead of Required List.
-      VectorWithOrdinal vord = getChildVectorWithOrdinal(null);
-      ValueVector v = vord.vector;
-      if (! (v instanceof  AbstractContainerVector)) {
-        return v.getField().getType();
-      }
-    } else if (this.getField().getType().getMinorType() == MinorType.MAP  &&
-        this.getField().getType().getMode() == DataMode.REPEATED) {  // Use Required Map
-      return this.getField().getType().toBuilder().setMode(DataMode.REQUIRED).build();
-    }
-
-    return this.getField().getType();
-  }
-
-  protected boolean supportsDirectRead() {
-    return false;
-  }
-
-  // return the number of child vectors
-  public abstract int size();
-
-  // add a new vector with the input MajorType or return the existing vector if we already added one with the same type
-  public abstract <T extends ValueVector> T addOrGet(String name, MajorType type, Class<T> clazz);
-
-  // return the child vector with the input name
-  public abstract <T extends ValueVector> T getChild(String name, Class<T> clazz);
-
-  // return the child vector's ordinal in the composite container
-  public abstract VectorWithOrdinal getChildVectorWithOrdinal(String name);
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/AbstractMapVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/AbstractMapVector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/AbstractMapVector.java
deleted file mode 100644
index 35df691..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/AbstractMapVector.java
+++ /dev/null
@@ -1,276 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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 com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import io.netty.buffer.DrillBuf;
-import org.apache.drill.common.collections.MapWithOrdinal;
-import org.apache.drill.common.types.TypeProtos;
-import org.apache.drill.exec.expr.TypeHelper;
-import org.apache.drill.exec.memory.BufferAllocator;
-import org.apache.drill.exec.record.MaterializedField;
-import org.apache.drill.exec.util.CallBack;
-import org.apache.drill.exec.vector.ValueVector;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-/*
- * Base class for MapVectors. Currently used by RepeatedMapVector and MapVector
- */
-public abstract class AbstractMapVector extends AbstractContainerVector {
-  private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AbstractContainerVector.class);
-
-  // Maintains a map with key as field name and value is the vector itself
-  private final MapWithOrdinal<String, ValueVector> vectors =  new MapWithOrdinal<>();
-
-  protected AbstractMapVector(MaterializedField field, BufferAllocator allocator, CallBack callBack) {
-    super(field.clone(), allocator, callBack);
-    MaterializedField clonedField = field.clone();
-    // create the hierarchy of the child vectors based on the materialized field
-    for (MaterializedField child : clonedField.getChildren()) {
-      if (!child.equals(BaseRepeatedValueVector.OFFSETS_FIELD)) {
-        final String fieldName = child.getLastName();
-        final ValueVector v = TypeHelper.getNewVector(child, allocator, callBack);
-        putVector(fieldName, v);
-      }
-    }
-  }
-
-  @Override
-  public void close() {
-    for(final ValueVector valueVector : vectors.values()) {
-      valueVector.close();
-    }
-    vectors.clear();
-
-    super.close();
-  }
-
-  @Override
-  public boolean allocateNewSafe() {
-    /* boolean to keep track if all the memory allocation were successful
-     * Used in the case of composite vectors when we need to allocate multiple
-     * buffers for multiple vectors. If one of the allocations failed we need to
-     * clear all the memory that we allocated
-     */
-    boolean success = false;
-    try {
-      for (final ValueVector v : vectors.values()) {
-        if (!v.allocateNewSafe()) {
-          return false;
-        }
-      }
-      success = true;
-    } finally {
-      if (!success) {
-        clear();
-      }
-    }
-    return true;
-  }
-
-  /**
-   * Adds a new field with the given parameters or replaces the existing one and consequently returns the resultant
-   * {@link org.apache.drill.exec.vector.ValueVector}.
-   *
-   * Execution takes place in the following order:
-   * <ul>
-   *   <li>
-   *     if field is new, create and insert a new vector of desired type.
-   *   </li>
-   *   <li>
-   *     if field exists and existing vector is of desired vector type, return the vector.
-   *   </li>
-   *   <li>
-   *     if field exists and null filled, clear the existing vector; create and insert a new vector of desired type.
-   *   </li>
-   *   <li>
-   *     otherwise, throw an {@link java.lang.IllegalStateException}
-   *   </li>
-   * </ul>
-   *
-   * @param name name of the field
-   * @param type type of the field
-   * @param clazz class of expected vector type
-   * @param <T> class type of expected vector type
-   * @throws java.lang.IllegalStateException raised if there is a hard schema change
-   *
-   * @return resultant {@link org.apache.drill.exec.vector.ValueVector}
-   */
-  @Override
-  public <T extends ValueVector> T addOrGet(String name, TypeProtos.MajorType type, Class<T> clazz) {
-    final ValueVector existing = getChild(name);
-    boolean create = false;
-    if (existing == null) {
-      create = true;
-    } else if (clazz.isAssignableFrom(existing.getClass())) {
-      return (T) existing;
-    } else if (nullFilled(existing)) {
-      existing.clear();
-      create = true;
-    }
-    if (create) {
-      final T vector = (T) TypeHelper.getNewVector(field.getPath(), name, allocator, type, callBack);
-      putChild(name, vector);
-      if (callBack!=null) {
-        callBack.doWork();
-      }
-      return vector;
-    }
-    final String message = "Drill does not support schema change yet. Existing[{}] and desired[{}] vector types mismatch";
-    throw new IllegalStateException(String.format(message, existing.getClass().getSimpleName(), clazz.getSimpleName()));
-  }
-
-  private boolean nullFilled(ValueVector vector) {
-    for (int r = 0; r < vector.getAccessor().getValueCount(); r++) {
-      if (!vector.getAccessor().isNull(r)) {
-        return false;
-      }
-    }
-    return true;
-  }
-
-  /**
-   * Returns a {@link org.apache.drill.exec.vector.ValueVector} corresponding to the given ordinal identifier.
-   */
-  public ValueVector getChildByOrdinal(int id) {
-    return vectors.getByOrdinal(id);
-  }
-
-  /**
-   * Returns a {@link org.apache.drill.exec.vector.ValueVector} instance of subtype of <T> corresponding to the given
-   * field name if exists or null.
-   */
-  @Override
-  public <T extends ValueVector> T getChild(String name, Class<T> clazz) {
-    final ValueVector v = vectors.get(name.toLowerCase());
-    if (v == null) {
-      return null;
-    }
-    return typeify(v, clazz);
-  }
-
-  /**
-   * Inserts the vector with the given name if it does not exist else replaces it with the new value.
-   *
-   * Note that this method does not enforce any vector type check nor throws a schema change exception.
-   */
-  protected void putChild(String name, ValueVector vector) {
-    putVector(name, vector);
-    field.addChild(vector.getField());
-  }
-
-  /**
-   * Inserts the input vector into the map if it does not exist, replaces if it exists already
-   * @param name  field name
-   * @param vector  vector to be inserted
-   */
-  protected void putVector(String name, ValueVector vector) {
-    final ValueVector old = vectors.put(
-        Preconditions.checkNotNull(name, "field name cannot be null").toLowerCase(),
-        Preconditions.checkNotNull(vector, "vector cannot be null")
-    );
-    if (old != null && old != vector) {
-      logger.debug("Field [{}] mutated from [{}] to [{}]", name, old.getClass().getSimpleName(),
-                   vector.getClass().getSimpleName());
-    }
-  }
-
-  /**
-   * Returns a sequence of underlying child vectors.
-   */
-  protected Collection<ValueVector> getChildren() {
-    return vectors.values();
-  }
-
-  /**
-   * Returns the number of underlying child vectors.
-   */
-  @Override
-  public int size() {
-    return vectors.size();
-  }
-
-  @Override
-  public Iterator<ValueVector> iterator() {
-    return vectors.values().iterator();
-  }
-
-  /**
-   * Returns a list of scalar child vectors recursing the entire vector hierarchy.
-   */
-  public List<ValueVector> getPrimitiveVectors() {
-    final List<ValueVector> primitiveVectors = Lists.newArrayList();
-    for (final ValueVector v : vectors.values()) {
-      if (v instanceof AbstractMapVector) {
-        AbstractMapVector mapVector = (AbstractMapVector) v;
-        primitiveVectors.addAll(mapVector.getPrimitiveVectors());
-      } else {
-        primitiveVectors.add(v);
-      }
-    }
-    return primitiveVectors;
-  }
-
-  /**
-   * Returns a vector with its corresponding ordinal mapping if field exists or null.
-   */
-  @Override
-  public VectorWithOrdinal getChildVectorWithOrdinal(String name) {
-    final int ordinal = vectors.getOrdinal(name.toLowerCase());
-    if (ordinal < 0) {
-      return null;
-    }
-    final ValueVector vector = vectors.getByOrdinal(ordinal);
-    return new VectorWithOrdinal(vector, ordinal);
-  }
-
-  @Override
-  public DrillBuf[] getBuffers(boolean clear) {
-    final List<DrillBuf> buffers = Lists.newArrayList();
-
-    for (final ValueVector vector : vectors.values()) {
-      for (final DrillBuf buf : vector.getBuffers(false)) {
-        buffers.add(buf);
-        if (clear) {
-          buf.retain(1);
-        }
-      }
-      if (clear) {
-        vector.clear();
-      }
-    }
-
-    return buffers.toArray(new DrillBuf[buffers.size()]);
-  }
-
-  @Override
-  public int getBufferSize() {
-    int actualBufSize = 0 ;
-
-    for (final ValueVector v : vectors.values()) {
-      for (final DrillBuf buf : v.getBuffers(false)) {
-        actualBufSize += buf.writerIndex();
-      }
-    }
-    return actualBufSize;
-  }
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/BaseRepeatedValueVector.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/BaseRepeatedValueVector.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/BaseRepeatedValueVector.java
deleted file mode 100644
index de4ad95..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/BaseRepeatedValueVector.java
+++ /dev/null
@@ -1,258 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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 java.util.Collections;
-import java.util.Iterator;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ObjectArrays;
-import io.netty.buffer.DrillBuf;
-import org.apache.drill.common.types.TypeProtos;
-import org.apache.drill.common.types.Types;
-import org.apache.drill.exec.exception.SchemaChangeRuntimeException;
-import org.apache.drill.exec.expr.TypeHelper;
-import org.apache.drill.exec.memory.BufferAllocator;
-import org.apache.drill.exec.proto.UserBitShared;
-import org.apache.drill.exec.record.MaterializedField;
-import org.apache.drill.exec.vector.AddOrGetResult;
-import org.apache.drill.exec.vector.BaseValueVector;
-import org.apache.drill.exec.vector.UInt4Vector;
-import org.apache.drill.exec.vector.ValueVector;
-import org.apache.drill.exec.vector.VectorDescriptor;
-import org.apache.drill.exec.vector.ZeroVector;
-
-public abstract class BaseRepeatedValueVector extends BaseValueVector implements RepeatedValueVector {
-
-  public final static ValueVector DEFAULT_DATA_VECTOR = ZeroVector.INSTANCE;
-  public final static String OFFSETS_VECTOR_NAME = "$offsets$";
-  public final static String DATA_VECTOR_NAME = "$data$";
-
-  public final static MaterializedField OFFSETS_FIELD =
-      MaterializedField.create(OFFSETS_VECTOR_NAME, Types.required(TypeProtos.MinorType.UINT4));
-
-  protected final UInt4Vector offsets;
-  protected ValueVector vector;
-
-  protected BaseRepeatedValueVector(MaterializedField field, BufferAllocator allocator) {
-    this(field, allocator, DEFAULT_DATA_VECTOR);
-  }
-
-  protected BaseRepeatedValueVector(MaterializedField field, BufferAllocator allocator, ValueVector vector) {
-    super(field, allocator);
-    this.offsets = new UInt4Vector(OFFSETS_FIELD, allocator);
-    this.vector = Preconditions.checkNotNull(vector, "data vector cannot be null");
-  }
-
-  @Override
-  public boolean allocateNewSafe() {
-    /* boolean to keep track if all the memory allocation were successful
-     * Used in the case of composite vectors when we need to allocate multiple
-     * buffers for multiple vectors. If one of the allocations failed we need to
-     * clear all the memory that we allocated
-     */
-    boolean success = false;
-    try {
-      if (!offsets.allocateNewSafe()) {
-        return false;
-      }
-      success = vector.allocateNewSafe();
-    } finally {
-      if (!success) {
-        clear();
-      }
-    }
-    offsets.zeroVector();
-    return success;
-  }
-
-
-  @Override
-  public UInt4Vector getOffsetVector() {
-    return offsets;
-  }
-
-  @Override
-  public ValueVector getDataVector() {
-    return vector;
-  }
-
-  @Override
-  public void setInitialCapacity(int numRecords) {
-    offsets.setInitialCapacity(numRecords + 1);
-    vector.setInitialCapacity(numRecords * RepeatedValueVector.DEFAULT_REPEAT_PER_RECORD);
-  }
-
-  @Override
-  public int getValueCapacity() {
-    final int offsetValueCapacity = Math.max(offsets.getValueCapacity() - 1, 0);
-    if (vector == DEFAULT_DATA_VECTOR) {
-      return offsetValueCapacity;
-    }
-    return Math.min(vector.getValueCapacity(), offsetValueCapacity);
-  }
-
-  @Override
-  protected UserBitShared.SerializedField.Builder getMetadataBuilder() {
-    return super.getMetadataBuilder()
-        .addChild(offsets.getMetadata())
-        .addChild(vector.getMetadata());
-  }
-
-  @Override
-  public int getBufferSize() {
-    if (getAccessor().getValueCount() == 0) {
-      return 0;
-    }
-    return offsets.getBufferSize() + vector.getBufferSize();
-  }
-
-  @Override
-  public int getBufferSizeFor(int valueCount) {
-    if (valueCount == 0) {
-      return 0;
-    }
-
-    return offsets.getBufferSizeFor(valueCount + 1) + vector.getBufferSizeFor(valueCount);
-  }
-
-  @Override
-  public Iterator<ValueVector> iterator() {
-    return Collections.singleton(getDataVector()).iterator();
-  }
-
-  @Override
-  public void clear() {
-    offsets.clear();
-    vector.clear();
-    super.clear();
-  }
-
-  @Override
-  public DrillBuf[] getBuffers(boolean clear) {
-    final DrillBuf[] buffers = ObjectArrays.concat(offsets.getBuffers(false), vector.getBuffers(false), DrillBuf.class);
-    if (clear) {
-      for (DrillBuf buffer:buffers) {
-        buffer.retain();
-      }
-      clear();
-    }
-    return buffers;
-  }
-
-  @Override
-  public void load(UserBitShared.SerializedField metadata, DrillBuf buffer) {
-    final UserBitShared.SerializedField offsetMetadata = metadata.getChild(0);
-    offsets.load(offsetMetadata, buffer);
-
-    final UserBitShared.SerializedField vectorMetadata = metadata.getChild(1);
-    if (getDataVector() == DEFAULT_DATA_VECTOR) {
-      addOrGetVector(VectorDescriptor.create(vectorMetadata.getMajorType()));
-    }
-
-    final int offsetLength = offsetMetadata.getBufferLength();
-    final int vectorLength = vectorMetadata.getBufferLength();
-    vector.load(vectorMetadata, buffer.slice(offsetLength, vectorLength));
-  }
-
-  /**
-   * Returns 1 if inner vector is explicitly set via #addOrGetVector else 0
-   *
-   * @see {@link ContainerVectorLike#size}
-   */
-  @Override
-  public int size() {
-    return vector == DEFAULT_DATA_VECTOR ? 0:1;
-  }
-
-  @Override
-  public <T extends ValueVector> AddOrGetResult<T> addOrGetVector(VectorDescriptor descriptor) {
-    boolean created = false;
-    if (vector == DEFAULT_DATA_VECTOR && descriptor.getType().getMinorType() != TypeProtos.MinorType.LATE) {
-      final MaterializedField field = descriptor.withName(DATA_VECTOR_NAME).getField();
-      vector = TypeHelper.getNewVector(field, allocator);
-      // returned vector must have the same field
-      assert field.equals(vector.getField());
-      getField().addChild(field);
-      created = true;
-    }
-
-    final TypeProtos.MajorType actual = vector.getField().getType();
-    if (!actual.equals(descriptor.getType())) {
-      final String msg = String.format("Inner vector type mismatch. Requested type: [%s], actual type: [%s]",
-          descriptor.getType(), actual);
-      throw new SchemaChangeRuntimeException(msg);
-    }
-
-    return new AddOrGetResult<>((T)vector, created);
-  }
-
-  protected void replaceDataVector(ValueVector v) {
-    vector.clear();
-    vector = v;
-  }
-
-  public abstract class BaseRepeatedAccessor extends BaseValueVector.BaseAccessor implements RepeatedAccessor {
-
-    @Override
-    public int getValueCount() {
-      return Math.max(offsets.getAccessor().getValueCount() - 1, 0);
-    }
-
-    @Override
-    public int getInnerValueCount() {
-      return vector.getAccessor().getValueCount();
-    }
-
-    @Override
-    public int getInnerValueCountAt(int index) {
-      return offsets.getAccessor().get(index+1) - offsets.getAccessor().get(index);
-    }
-
-    @Override
-    public boolean isNull(int index) {
-      return false;
-    }
-
-    @Override
-    public boolean isEmpty(int index) {
-      return false;
-    }
-  }
-
-  public abstract class BaseRepeatedMutator extends BaseValueVector.BaseMutator implements RepeatedMutator {
-
-    @Override
-    public void startNewValue(int index) {
-      while (offsets.getValueCapacity() <= index) {
-        offsets.reAlloc();
-      }
-      offsets.getMutator().setSafe(index+1, offsets.getAccessor().get(index));
-      setValueCount(index+1);
-    }
-
-    @Override
-    public void setValueCount(int valueCount) {
-      // TODO: populate offset end points
-      offsets.getMutator().setValueCount(valueCount == 0 ? 0 : valueCount+1);
-      final int childValueCount = valueCount == 0 ? 0 : offsets.getAccessor().get(valueCount);
-      vector.getMutator().setValueCount(childValueCount);
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/9969d8bd/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/ContainerVectorLike.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/ContainerVectorLike.java b/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/ContainerVectorLike.java
deleted file mode 100644
index 999b47d..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/ContainerVectorLike.java
+++ /dev/null
@@ -1,43 +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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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.exec.vector.AddOrGetResult;
-import org.apache.drill.exec.vector.ValueVector;
-import org.apache.drill.exec.vector.VectorDescriptor;
-
-/**
- * A mix-in used for introducing container vector-like behaviour.
- */
-public interface ContainerVectorLike {
-
-  /**
-   * Creates and adds a child vector if none with the same name exists, else returns the vector instance.
-   *
-   * @param  descriptor vector descriptor
-   * @return  result of operation wrapping vector corresponding to the given descriptor and whether it's newly created
-   * @throws org.apache.drill.common.exceptions.DrillRuntimeException
-   *    if schema change is not permissible between the given and existing data vector types.
-   */
-  <T extends ValueVector> AddOrGetResult<T> addOrGetVector(VectorDescriptor descriptor);
-
-  /**
-   * Returns the number of child vectors in this container vector-like instance.
-   */
-  int size();
-}


Mime
View raw message