You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by ja...@apache.org on 2013/04/14 04:35:11 UTC

[7/9] basic framework for physical plan. abstraction of graph classes.

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b53933f2/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/DeadBuf.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/DeadBuf.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/DeadBuf.java
new file mode 100644
index 0000000..dafb68c
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/DeadBuf.java
@@ -0,0 +1,848 @@
+/*******************************************************************************
+ * 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.record;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.channels.GatheringByteChannel;
+import java.nio.channels.ScatteringByteChannel;
+import java.nio.charset.Charset;
+
+import io.netty.buffer.BufType;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import io.netty.buffer.ByteBufIndexFinder;
+
+public class DeadBuf implements ByteBuf {
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DeadBuf.class);
+  
+  private static final String ERROR_MESSAGE = "Attemped to access a DeadBuf.  This would happen if you attempted to interact with a buffer that has been moved or not yet initialized.";
+  
+  public static final DeadBuf DEAD_BUFFER = new DeadBuf();
+
+  private DeadBuf(){}
+  
+  @Override
+  public BufType type() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public boolean isReadable(int size) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public boolean isWritable(int size) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int refCnt() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public boolean release() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public boolean release(int decrement) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int capacity() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf capacity(int newCapacity) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int maxCapacity() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBufAllocator alloc() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteOrder order() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf order(ByteOrder endianness) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf unwrap() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public boolean isDirect() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int readerIndex() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf readerIndex(int readerIndex) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int writerIndex() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf writerIndex(int writerIndex) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setIndex(int readerIndex, int writerIndex) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int readableBytes() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int writableBytes() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int maxWritableBytes() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public boolean isReadable() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  @Deprecated
+  public boolean readable() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public boolean isWritable() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  @Deprecated
+  public boolean writable() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf clear() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf markReaderIndex() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf resetReaderIndex() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf markWriterIndex() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf resetWriterIndex() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf discardReadBytes() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf discardSomeReadBytes() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf ensureWritable(int minWritableBytes) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  @Deprecated
+  public ByteBuf ensureWritableBytes(int minWritableBytes) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int ensureWritable(int minWritableBytes, boolean force) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public boolean getBoolean(int index) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public byte getByte(int index) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public short getUnsignedByte(int index) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public short getShort(int index) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int getUnsignedShort(int index) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int getMedium(int index) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int getUnsignedMedium(int index) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int getInt(int index) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public long getUnsignedInt(int index) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public long getLong(int index) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public char getChar(int index) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public float getFloat(int index) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public double getDouble(int index) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf getBytes(int index, ByteBuf dst) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf getBytes(int index, ByteBuf dst, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf getBytes(int index, ByteBuf dst, int dstIndex, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf getBytes(int index, byte[] dst) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf getBytes(int index, byte[] dst, int dstIndex, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf getBytes(int index, ByteBuffer dst) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf getBytes(int index, OutputStream out, int length) throws IOException {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int getBytes(int index, GatheringByteChannel out, int length) throws IOException {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setBoolean(int index, boolean value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setByte(int index, int value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setShort(int index, int value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setMedium(int index, int value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setInt(int index, int value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setLong(int index, long value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setChar(int index, int value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setFloat(int index, float value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setDouble(int index, double value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setBytes(int index, ByteBuf src) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setBytes(int index, ByteBuf src, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setBytes(int index, ByteBuf src, int srcIndex, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setBytes(int index, byte[] src) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setBytes(int index, byte[] src, int srcIndex, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setBytes(int index, ByteBuffer src) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int setBytes(int index, InputStream in, int length) throws IOException {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int setBytes(int index, ScatteringByteChannel in, int length) throws IOException {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf setZero(int index, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public boolean readBoolean() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public byte readByte() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public short readUnsignedByte() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public short readShort() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int readUnsignedShort() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int readMedium() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int readUnsignedMedium() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int readInt() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public long readUnsignedInt() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public long readLong() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public char readChar() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public float readFloat() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public double readDouble() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf readBytes(int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf readSlice(int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf readBytes(ByteBuf dst) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf readBytes(ByteBuf dst, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf readBytes(ByteBuf dst, int dstIndex, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf readBytes(byte[] dst) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf readBytes(byte[] dst, int dstIndex, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf readBytes(ByteBuffer dst) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf readBytes(OutputStream out, int length) throws IOException {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int readBytes(GatheringByteChannel out, int length) throws IOException {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf skipBytes(int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf writeBoolean(boolean value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf writeByte(int value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf writeShort(int value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf writeMedium(int value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf writeInt(int value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf writeLong(long value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf writeChar(int value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf writeFloat(float value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf writeDouble(double value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf writeBytes(ByteBuf src) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf writeBytes(ByteBuf src, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf writeBytes(ByteBuf src, int srcIndex, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf writeBytes(byte[] src) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf writeBytes(byte[] src, int srcIndex, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf writeBytes(ByteBuffer src) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int writeBytes(InputStream in, int length) throws IOException {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int writeBytes(ScatteringByteChannel in, int length) throws IOException {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf writeZero(int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int indexOf(int fromIndex, int toIndex, byte value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int indexOf(int fromIndex, int toIndex, ByteBufIndexFinder indexFinder) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int bytesBefore(byte value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int bytesBefore(ByteBufIndexFinder indexFinder) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int bytesBefore(int length, byte value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int bytesBefore(int length, ByteBufIndexFinder indexFinder) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int bytesBefore(int index, int length, byte value) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int bytesBefore(int index, int length, ByteBufIndexFinder indexFinder) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf copy() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf copy(int index, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf slice() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf slice(int index, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf duplicate() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int nioBufferCount() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuffer nioBuffer() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuffer nioBuffer(int index, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuffer[] nioBuffers() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuffer[] nioBuffers(int index, int length) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public boolean hasArray() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public byte[] array() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public int arrayOffset() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public boolean hasMemoryAddress() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public long memoryAddress() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public String toString(Charset charset) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public String toString(int index, int length, Charset charset) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+
+  }
+
+  @Override
+  public ByteBuf suspendIntermediaryDeallocations() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf resumeIntermediaryDeallocations() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public int compareTo(ByteBuf buffer) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf retain(int increment) {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+
+  @Override
+  public ByteBuf retain() {
+    throw new UnsupportedOperationException(ERROR_MESSAGE);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b53933f2/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/InvalidValueAccessor.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/InvalidValueAccessor.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/InvalidValueAccessor.java
new file mode 100644
index 0000000..403c7a3
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/InvalidValueAccessor.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.record;
+
+import org.apache.drill.exec.exception.ExecutionSetupException;
+
+public class InvalidValueAccessor extends ExecutionSetupException{
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(InvalidValueAccessor.class);
+
+  public InvalidValueAccessor() {
+    super();
+  }
+
+  public InvalidValueAccessor(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
+    super(message, cause, enableSuppression, writableStackTrace);
+  }
+
+  public InvalidValueAccessor(String message, Throwable cause) {
+    super(message, cause);
+  }
+
+  public InvalidValueAccessor(String message) {
+    super(message);
+  }
+
+  public InvalidValueAccessor(Throwable cause) {
+    super(cause);
+  }
+  
+  
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b53933f2/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/MaterializedField.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/MaterializedField.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/MaterializedField.java
new file mode 100644
index 0000000..3cadf89
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/MaterializedField.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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.record;
+
+import org.apache.drill.common.expression.types.DataType;
+import org.apache.drill.common.physical.RecordField.ValueMode;
+import org.apache.drill.exec.exception.SchemaChangeException;
+
+public class MaterializedField implements Comparable<MaterializedField>{
+  private int fieldId;
+  private DataType type;
+  private boolean nullable;
+  private ValueMode mode;
+  private Class<?> valueClass;
+  
+  public MaterializedField(int fieldId, DataType type, boolean nullable, ValueMode mode, Class<?> valueClass) {
+    super();
+    this.fieldId = fieldId;
+    this.type = type;
+    this.nullable = nullable;
+    this.mode = mode;
+    this.valueClass = valueClass;
+  }
+
+  public int getFieldId() {
+    return fieldId;
+  }
+
+  public DataType getType() {
+    return type;
+  }
+
+  public boolean isNullable() {
+    return nullable;
+  }
+
+  public ValueMode getMode() {
+    return mode;
+  }
+
+  public Class<?> getValueClass() {
+    return valueClass;
+  }
+
+  private void check(String name, Object val1, Object expected) throws SchemaChangeException{
+    if(expected.equals(val1)) return;
+    throw new SchemaChangeException("Expected and actual field definitions don't match. Actual %s: %s, expected %s: %s", name, val1, name, expected);
+  }
+  
+  public void checkMaterialization(MaterializedField expected) throws SchemaChangeException{
+    if(this.type == expected.type || expected.type == DataType.LATEBIND) throw new SchemaChangeException("Expected and actual field definitions don't match. Actual DataType: %s, expected DataTypes: %s", this.type, expected.type);
+    if(expected.valueClass != null) check("valueClass", this.valueClass, expected.valueClass);
+    check("fieldId", this.fieldId, expected.fieldId);
+    check("nullability", this.nullable, expected.nullable);
+    check("valueMode", this.mode, expected.mode);
+  }
+
+  @Override
+  public int compareTo(MaterializedField o) {
+    return Integer.compare(this.fieldId, o.fieldId);
+  }
+  
+  
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b53933f2/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordBatch.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordBatch.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordBatch.java
new file mode 100644
index 0000000..eca62bb
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordBatch.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * 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.record;
+
+import org.apache.drill.exec.ops.FragmentContext;
+import org.apache.drill.exec.record.vector.ValueVector;
+
+/**
+ * A record batch contains a set of field values for a particular range of records. In the case of a record batch
+ * composed of ValueVectors, ideally a batch fits within L2 cache (~256k per core). The set of value vectors do not
+ * change unless the next() IterOutcome is a *_NEW_SCHEMA type.
+ */
+public interface RecordBatch {
+
+  /**
+   * Describes the outcome of a RecordBatch being incremented forward.
+   */
+  public static enum IterOutcome {
+    NONE, // No more records were found.
+    OK, // A new range of records have been provided.
+    OK_NEW_SCHEMA, // A full collection of records
+    STOP // Informs parent nodes that the query has terminated. In this case, a consumer can consume their QueryContext
+         // to understand the current state of things.
+  }
+
+  /**
+   * Access the FragmentContext of the current query fragment. Useful for reporting failure information or other query
+   * level information.
+   * 
+   * @return
+   */
+  public FragmentContext getContext();
+
+  /**
+   * Provide the schema of the current RecordBatch. This changes if and only if a *_NEW_SCHEMA IterOutcome is provided.
+   * 
+   * @return
+   */
+  public BatchSchema getSchema();
+
+  /**
+   * Provide the number of records that are within this record count
+   * 
+   * @return
+   */
+  public int getRecordCount();
+
+  /**
+   * Inform child nodes that this query should be terminated. Child nodes should utilize the QueryContext to determine
+   * what has happened.
+   */
+  public void kill();
+
+
+  public abstract <T extends ValueVector<T>> T getValueVector(int fieldId, Class<T> clazz) throws InvalidValueAccessor;
+
+//  public abstract void getDictReader(int fieldId, Class<?> clazz) throws InvalidValueAccessor;
+//
+//  public abstract void getRleReader(int fieldId, Class<?> clazz) throws InvalidValueAccessor;
+
+  /**
+   * Update the data in each Field reading interface for the next range of records. Once a RecordBatch returns an
+   * IterOutcome.NONE, the consumer should no longer next(). Behavior at this point is undetermined and likely to throw
+   * an exception.
+   * 
+   * @return An IterOutcome describing the result of the iteration.
+   */
+  public IterOutcome next();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b53933f2/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordMaker.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordMaker.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordMaker.java
new file mode 100644
index 0000000..9bc6e5f
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/RecordMaker.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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.record;
+
+public class RecordMaker {
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(RecordMaker.class);
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b53933f2/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/AbstractFixedValueVector.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/AbstractFixedValueVector.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/AbstractFixedValueVector.java
new file mode 100644
index 0000000..735493d
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/AbstractFixedValueVector.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.record.vector;
+
+import io.netty.buffer.ByteBuf;
+
+import org.apache.drill.exec.BufferAllocator;
+
+/**
+ * Abstract class that fixed value vectors are derived from.
+ */
+abstract class AbstractFixedValueVector<T extends AbstractFixedValueVector<T>> extends BaseValueVector<T> {
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AbstractFixedValueVector.class);
+
+  private final int widthInBits;
+
+  protected int longWords = 0;
+
+  public AbstractFixedValueVector(int fieldId, BufferAllocator allocator, int widthInBits) {
+    super(fieldId, allocator);
+    this.widthInBits = widthInBits;
+  }
+  
+  @Override
+  protected int getAllocationSize(int valueCount) {
+    return (int) Math.ceil(valueCount*widthInBits*1.0/8);
+  }
+  
+  @Override
+  protected void childResetAllocation(int valueCount, ByteBuf buf) {
+    this.longWords = valueCount/8;
+  }
+
+  @Override
+  protected void childCloneMetadata(T other) {
+    other.longWords = this.longWords;
+  }
+
+  @Override
+  protected void childClear() {
+    longWords = 0;
+  }
+
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b53933f2/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/AnyVector.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/AnyVector.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/AnyVector.java
new file mode 100644
index 0000000..6becfcd
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/AnyVector.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.record.vector;
+
+/**
+ * A Vector that holds each value with type information. In the case of complex types, an any vector will inline the
+ * complex type within the value space.  The complex value will be stored in 
+ */
+public class AnyVector {
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AnyVector.class);
+
+  
+   
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b53933f2/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/BaseValueVector.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/BaseValueVector.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/BaseValueVector.java
new file mode 100644
index 0000000..33a81e5
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/BaseValueVector.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * 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.record.vector;
+
+import io.netty.buffer.ByteBuf;
+
+import org.apache.drill.exec.BufferAllocator;
+import org.apache.drill.exec.record.DeadBuf;
+
+public abstract class BaseValueVector<T extends BaseValueVector<T>> implements ValueVector<T>{
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(BaseValueVector.class);
+  
+  protected final BufferAllocator allocator;
+  protected ByteBuf data = DeadBuf.DEAD_BUFFER;
+  protected int valueCount = 0;
+  protected final int fieldId;
+  
+  public BaseValueVector(int fieldId, BufferAllocator allocator) {
+    this.allocator = allocator;
+    this.fieldId = fieldId;
+  }
+
+  public final void allocateNew(int valueCount){
+    int allocationSize = getAllocationSize(valueCount);
+    resetAllocation(valueCount, allocator.buffer(allocationSize));
+  }
+
+  protected abstract int getAllocationSize(int valueCount);
+  protected abstract void childResetAllocation(int valueCount, ByteBuf buf);
+  protected abstract void childCloneMetadata(T other);
+  protected abstract void childClear();
+  
+  protected final void resetAllocation(int valueCount, ByteBuf buf){
+    clear();
+    this.valueCount = valueCount;
+    this.data = buf;
+    childResetAllocation(valueCount, buf);
+  }
+  
+  public final void cloneMetadata(T other){
+    other.valueCount = this.valueCount;
+  }
+  
+  @Override
+  public final void cloneInto(T vector) {
+    vector.allocateNew(valueCount);
+    data.writeBytes(vector.data);
+    cloneMetadata(vector);
+    childResetAllocation(valueCount, vector.data);
+  }
+  
+  @Override
+  public final void transferTo(T vector) {
+    vector.data = this.data;
+    cloneMetadata(vector);
+    childResetAllocation(valueCount, data);
+    clear();
+  }
+
+  protected final void clear(){
+    if(this.data != DeadBuf.DEAD_BUFFER){
+      this.data.release();
+      this.data = DeadBuf.DEAD_BUFFER;
+      this.valueCount = 0;
+    }
+    childClear();
+  }
+  
+  /**
+   * Give the length of the value vector in bytes.
+   * 
+   * @return
+   */
+  public int size() {
+    return valueCount;
+  }
+  
+  @Override
+  public void close() {
+    clear();
+  }
+
+  @Override
+  public ByteBuf getBuffer() {
+    return data;
+  }
+  
+  
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b53933f2/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/BitUtil.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/BitUtil.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/BitUtil.java
new file mode 100644
index 0000000..4a3ae2f
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/BitUtil.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * 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.record.vector;  // from org.apache.solr.util rev 555343
+
+import io.netty.buffer.ByteBuf;
+
+
+/**  A variety of high efficiency bit twiddling routines.
+ * @lucene.internal
+ */
+public final class BitUtil {
+
+  private BitUtil() {} // no instance
+
+  // The pop methods used to rely on bit-manipulation tricks for speed but it
+  // turns out that it is faster to use the Long.bitCount method (which is an
+  // intrinsic since Java 6u18) in a naive loop, see LUCENE-2221
+
+  /** Returns the number of set bits in an array of longs. */
+  public static long pop_array(ByteBuf arr, int wordOffset, int numWords) {
+    long popCount = 0;
+    for (int i = wordOffset, end = wordOffset + numWords; i < end; i+=8) {
+      popCount += Long.bitCount(arr.getLong(i));
+    }
+    return popCount;
+  }
+
+  /** Returns the popcount or cardinality of the two sets after an intersection.
+   *  Neither array is modified. */
+  public static long pop_intersect(ByteBuf arr1, ByteBuf arr2, int wordOffset, int numWords) {
+    long popCount = 0;
+    for (int i = wordOffset, end = wordOffset + numWords; i < end; i+=8) {
+      popCount += Long.bitCount(arr1.getLong(i) & arr2.getLong(i));
+    }
+    return popCount;
+  }
+
+   /** Returns the popcount or cardinality of the union of two sets.
+    *  Neither array is modified. */
+   public static long pop_union(ByteBuf arr1, ByteBuf arr2, int wordOffset, int numWords) {
+     long popCount = 0;
+     for (int i = wordOffset, end = wordOffset + numWords; i < end; i+=8) {
+       popCount += Long.bitCount(arr1.getLong(i) | arr2.getLong(i));
+     }
+     return popCount;
+   }
+
+  /** Returns the popcount or cardinality of A & ~B.
+   *  Neither array is modified. */
+  public static long pop_andnot(ByteBuf arr1, ByteBuf arr2, int wordOffset, int numWords) {
+    long popCount = 0;
+    for (int i = wordOffset, end = wordOffset + numWords; i < end; i+=8) {
+      popCount += Long.bitCount(arr1.getLong(i) & ~arr2.getLong(i));
+    }
+    return popCount;
+  }
+
+  /** Returns the popcount or cardinality of A ^ B
+    * Neither array is modified. */
+  public static long pop_xor(ByteBuf arr1, ByteBuf arr2, int wordOffset, int numWords) {
+    long popCount = 0;
+    for (int i = wordOffset, end = wordOffset + numWords; i < end; i+=8) {
+      popCount += Long.bitCount(arr1.getLong(i) ^ arr2.getLong(i));
+    }
+    return popCount;
+  }
+
+  /** returns the next highest power of two, or the current value if it's already a power of two or zero*/
+  public static int nextHighestPowerOfTwo(int v) {
+    v--;
+    v |= v >> 1;
+    v |= v >> 2;
+    v |= v >> 4;
+    v |= v >> 8;
+    v |= v >> 16;
+    v++;
+    return v;
+  }
+
+  /** returns the next highest power of two, or the current value if it's already a power of two or zero*/
+   public static long nextHighestPowerOfTwo(long v) {
+    v--;
+    v |= v >> 1;
+    v |= v >> 2;
+    v |= v >> 4;
+    v |= v >> 8;
+    v |= v >> 16;
+    v |= v >> 32;
+    v++;
+    return v;
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b53933f2/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/BitVector.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/BitVector.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/BitVector.java
new file mode 100644
index 0000000..c157b12
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/BitVector.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * 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.record.vector;
+
+import org.apache.drill.common.expression.types.DataType;
+import org.apache.drill.common.physical.RecordField.ValueMode;
+import org.apache.drill.exec.BufferAllocator;
+import org.apache.drill.exec.record.MaterializedField;
+
+/**
+ * Describes a vector which holds a number of true/false values.
+ */
+public class BitVector extends AbstractFixedValueVector<BitVector> {
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(BitVector.class);
+
+  private final MaterializedField field;
+  
+  public BitVector(int fieldId, BufferAllocator allocator) {
+    super(fieldId, allocator, 1);
+    this.field = new MaterializedField(fieldId, DataType.BOOLEAN, false, ValueMode.VECTOR, this.getClass());
+  }
+
+  @Override
+  public MaterializedField getField() {
+    return field;
+  }
+  
+  /** Returns true or false for the specified bit index.
+   * The index should be less than the OpenBitSet size
+   */
+  public boolean get(int index) {
+    assert index >= 0 && index < this.valueCount;
+    int i = index >> 3;               // div 8
+    // signed shift will keep a negative index and force an
+    // array-index-out-of-bounds-exception, removing the need for an explicit check.
+    int bit = index & 0x3f;           // mod 64
+    long bitmask = 1L << bit;
+    return (data.getLong(i) & bitmask) != 0;
+  }
+  
+  /** Sets the bit at the specified index.
+   * The index should be less than the OpenBitSet size.
+   */
+   public void set(int index) {
+     assert index >= 0 && index < this.valueCount;
+     int wordNum = index >> 3;   
+     int bit = index & 0x3f;
+     long bitmask = 1L << bit;
+     data.setLong(wordNum, data.getLong(wordNum) | bitmask);
+   }
+   
+   public void clear(int index) {
+     assert index >= 0 && index < this.valueCount;
+     int wordNum = index >> 3;
+     int bit = index & 0x03f;
+     long bitmask = 1L << bit;
+     data.setLong(wordNum, data.getLong(wordNum) & ~bitmask);
+   }
+   
+   
+   /** Clears a range of bits.  Clearing past the end does not change the size of the set.
+   *
+   * @param startIndex lower index
+   * @param endIndex one-past the last bit to clear
+   */
+  private void clear(int startIndex, int endIndex) {
+    if (endIndex <= startIndex) return;
+
+    int startWord = (startIndex>>3);
+    if (startWord >= this.longWords) return;
+
+    // since endIndex is one past the end, this is index of the last
+    // word to be changed.
+    int endWord   = ((endIndex-1)>>3);
+
+    long startmask = -1L << startIndex;
+    long endmask = -1L >>> -endIndex;  // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+
+    // invert masks since we are clearing
+    startmask = ~startmask;
+    endmask = ~endmask;
+
+    if (startWord == endWord) {
+      data.setLong(startWord,  data.getLong(startWord) & (startmask | endmask));
+      return;
+    }
+
+    data.setLong(startWord,  data.getLong(startWord) & startmask);
+
+    int middle = Math.min(this.longWords, endWord);
+    for(int i =startWord+1; i < middle; i += 8){
+      data.setLong(i, 0L);
+    }
+    if (endWord < this.longWords) {
+      data.setLong(endWord,  data.getLong(endWord) & endmask);
+    }
+  }
+  
+  public void setAllFalse(){
+    clear(0, valueCount);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b53933f2/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/BufBitSet.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/BufBitSet.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/BufBitSet.java
new file mode 100644
index 0000000..574389f
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/BufBitSet.java
@@ -0,0 +1,847 @@
+/*
+ * 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.record.vector; // from org.apache.solr.util rev 555343
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+
+/**
+ * HEAVY WIP: ONLY PARTIALLY TRANSFERRED TO BUFFER METHODS. STILL NEEDS BIT SHIFT FIXES, GETLONG AND SETLONG updates to
+ * fix index postion AND OTHER THINGS.
+ * 
+ * An "open" BitSet implementation that allows direct access to the array of words storing the bits.
+ * <p/>
+ * Unlike java.util.bitset, the fact that bits are packed into an array of longs is part of the interface. This allows
+ * efficient implementation of other algorithms by someone other than the author. It also allows one to efficiently
+ * implement alternate serialization or interchange formats.
+ * <p/>
+ * <code>BufBitSet</code> is faster than <code>java.util.BitSet</code> in most operations and *much* faster at
+ * calculating cardinality of sets and results of set operations. It can also handle sets of larger cardinality (up to
+ * 64 * 2**32-1)
+ * <p/>
+ * The goals of <code>BufBitSet</code> are the fastest implementation possible, and maximum code reuse. Extra safety
+ * and encapsulation may always be built on top, but if that's built in, the cost can never be removed (and hence people
+ * re-implement their own version in order to get better performance). If you want a "safe", totally encapsulated (and
+ * slower and limited) BitSet class, use <code>java.util.BitSet</code>.
+ * <p/>
+ */
+
+public class BufBitSet {
+  private ByteBufAllocator allocator;
+  private ByteBuf buf;
+  // protected long[] bits;
+  protected int wlen; // number of words (elements) used in the array
+
+  // Used only for assert:
+  private long numBits;
+
+  // /** Constructs an BufBitSet large enough to hold <code>numBits</code>.
+  // */
+  // public BufBitSet(long numBits) {
+  // this.numBits = numBits;
+  // wlen = buf.capacity();
+  // }
+  //
+  // public BufBitSet() {
+  // this(64);
+  // }
+
+  public BufBitSet(long numBits, ByteBufAllocator allocator) {
+    this.allocator = allocator;
+    this.numBits = numBits;
+    int words = bits2words(numBits);
+    this.wlen = words;
+    buf = allocator.buffer(wlen);
+  }
+
+  private BufBitSet(ByteBufAllocator allocator, ByteBuf buf) {
+    this.allocator = allocator;
+    this.numBits = buf.capacity() * 8;
+    int words = buf.capacity();
+    this.wlen = words;
+    this.buf = buf;
+  }
+
+  /** Returns the current capacity in bits (1 greater than the index of the last bit) */
+  public long capacity() {
+    return buf.capacity() << 6;
+  }
+
+  /**
+   * Returns the current capacity of this set. Included for compatibility. This is *not* equal to {@link #cardinality}
+   */
+  public long size() {
+    return capacity();
+  }
+
+  public int length() {
+    return buf.capacity() << 6;
+  }
+
+  /** Returns true if there are no set bits */
+  public boolean isEmpty() {
+    return cardinality() == 0;
+  }
+
+  // /** Expert: returns the long[] storing the bits */
+  // public long[] getBits() { return bits; }
+  //
+  // /** Expert: sets a new long[] to use as the bit storage */
+  // public void setBits(long[] bits) { this.bits = bits; }
+
+  /** Expert: gets the number of longs in the array that are in use */
+  public int getNumWords() {
+    return wlen;
+  }
+
+  /** Expert: sets the number of longs in the array that are in use */
+  public void setNumWords(int nWords) {
+    this.wlen = nWords;
+  }
+
+  /** Returns true or false for the specified bit index. */
+  public boolean get(int index) {
+    int i = index >> 6; // div 64
+    // signed shift will keep a negative index and force an
+    // array-index-out-of-bounds-exception, removing the need for an explicit check.
+    if (i >= buf.capacity()) return false;
+
+    int bit = index & 0x3f; // mod 64
+    long bitmask = 1L << bit;
+    return (buf.getLong(i) & bitmask) != 0;
+  }
+
+  /**
+   * Returns true or false for the specified bit index. The index should be less than the BufBitSet size
+   */
+  public boolean fastGet(int index) {
+    assert index >= 0 && index < numBits;
+    int i = index >> 6; // div 64
+    // signed shift will keep a negative index and force an
+    // array-index-out-of-bounds-exception, removing the need for an explicit check.
+    int bit = index & 0x3f; // mod 64
+    long bitmask = 1L << bit;
+    return (buf.getLong(i) & bitmask) != 0;
+  }
+
+  /**
+   * Returns true or false for the specified bit index
+   */
+  public boolean get(long index) {
+    int i = (int) (index >> 6); // div 64
+    if (i >= buf.capacity()) return false;
+    int bit = (int) index & 0x3f; // mod 64
+    long bitmask = 1L << bit;
+    return (buf.getLong(i) & bitmask) != 0;
+  }
+
+  /**
+   * Returns true or false for the specified bit index. The index should be less than the BufBitSet size.
+   */
+  public boolean fastGet(long index) {
+    assert index >= 0 && index < numBits;
+    int i = (int) (index >> 6); // div 64
+    int bit = (int) index & 0x3f; // mod 64
+    long bitmask = 1L << bit;
+    return (buf.getLong(i) & bitmask) != 0;
+  }
+
+  /*
+   * // alternate implementation of get() public boolean get1(int index) { int i = index >> 6; // div 64 int bit = index
+   * & 0x3f; // mod 64 return ((buf.getLong(i)>>>bit) & 0x01) != 0; // this does a long shift and a bittest (on x86) vs
+   * // a long shift, and a long AND, (the test for zero is prob a no-op) // testing on a P4 indicates this is slower
+   * than (buf.getLong(i) & bitmask) != 0; }
+   */
+
+  /**
+   * returns 1 if the bit is set, 0 if not. The index should be less than the BufBitSet size
+   */
+  public int getBit(int index) {
+    assert index >= 0 && index < numBits;
+    int i = index >> 6; // div 64
+    int bit = index & 0x3f; // mod 64
+    return ((int) (buf.getLong(i) >>> bit)) & 0x01;
+  }
+
+  /*
+   * public boolean get2(int index) { int word = index >> 6; // div 64 int bit = index & 0x0000003f; // mod 64 return
+   * (buf.getLong(word) << bit) < 0; // hmmm, this would work if bit order were reversed // we could right shift and
+   * check for parity bit, if it was available to us. }
+   */
+
+  /** sets a bit, expanding the set size if necessary */
+  public void set(long index) {
+    int wordNum = expandingWordNum(index);
+    int bit = (int) index & 0x3f;
+    long bitmask = 1L << bit;
+    buf.setLong(wordNum, buf.getLong(wordNum) | bitmask);
+    buf.setLong(wordNum, buf.getLong(wordNum) | bitmask);
+  }
+
+  /**
+   * Sets the bit at the specified index. The index should be less than the BufBitSet size.
+   */
+  public void fastSet(int index) {
+    assert index >= 0 && index < numBits;
+    int wordNum = index >> 6; // div 64
+    int bit = index & 0x3f; // mod 64
+    long bitmask = 1L << bit;
+    buf.setLong(wordNum, buf.getLong(wordNum) | bitmask);
+  }
+
+  /**
+   * Sets the bit at the specified index. The index should be less than the BufBitSet size.
+   */
+  public void fastSet(long index) {
+    assert index >= 0 && index < numBits;
+    int wordNum = (int) (index >> 6);
+    int bit = (int) index & 0x3f;
+    long bitmask = 1L << bit;
+    buf.setLong(wordNum, buf.getLong(wordNum) | bitmask);
+  }
+
+  /**
+   * Sets a range of bits, expanding the set size if necessary
+   * 
+   * @param startIndex
+   *          lower index
+   * @param endIndex
+   *          one-past the last bit to set
+   */
+  public void set(long startIndex, long endIndex) {
+    if (endIndex <= startIndex) return;
+
+    int startWord = (int) (startIndex >> 6);
+
+    // since endIndex is one past the end, this is index of the last
+    // word to be changed.
+    int endWord = expandingWordNum(endIndex - 1);
+
+    long startmask = -1L << startIndex;
+    long endmask = -1L >>> -endIndex; // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+
+    if (startWord == endWord) {
+      buf.setLong(startWord, buf.getLong(startWord) | (startmask & endmask));
+      return;
+    }
+    buf.setLong(startWord, buf.getLong(startWord) | startmask);
+
+    fill(buf, startWord + 1, endWord, -1L);
+    buf.setLong(endWord, buf.getLong(endWord) | endmask);
+  }
+
+  private void fill(ByteBuf buf, int start, int end, long val) {
+    for (int i = 0; i < buf.capacity(); i += 8) {
+      buf.setLong(i, val);
+    }
+  }
+
+  private final void setLongWord(int pos, long value) {
+    buf.setLong(pos * 8, value);
+  }
+
+  private final long getLongWord(int pos) {
+    return buf.getLong(pos * 8);
+  }
+
+  protected int expandingWordNum(long index) {
+    int wordNum = (int) (index >> 6);
+    if (wordNum >= wlen) {
+      ensureCapacity(index + 1);
+      wlen = wordNum + 1;
+    }
+    assert (numBits = Math.max(numBits, index + 1)) >= 0;
+    return wordNum;
+  }
+
+  /**
+   * clears a bit. The index should be less than the BufBitSet size.
+   */
+  public void fastClear(int index) {
+    assert index >= 0 && index < numBits;
+    int wordNum = index >> 6;
+    int bit = index & 0x03f;
+    long bitmask = 1L << bit;
+    buf.setLong(wordNum, buf.getLong(wordNum) & ~bitmask);
+    // hmmm, it takes one more instruction to clear than it does to set... any
+    // way to work around this? If there were only 63 bits per word, we could
+    // use a right shift of 10111111...111 in binary to position the 0 in the
+    // correct place (using sign extension).
+    // Could also use Long.rotateRight() or rotateLeft() *if* they were converted
+    // by the JVM into a native instruction.
+    // buf.getLong(word) &= Long.rotateLeft(0xfffffffe,bit);
+  }
+
+  /**
+   * clears a bit. The index should be less than the BufBitSet size.
+   */
+  public void fastClear(long index) {
+    assert index >= 0 && index < numBits;
+    int wordNum = (int) (index >> 6); // div 64
+    int bit = (int) index & 0x3f; // mod 64
+    long bitmask = 1L << bit;
+    buf.setLong(wordNum, buf.getLong(wordNum) & ~bitmask);
+  }
+
+  /** clears a bit, allowing access beyond the current set size without changing the size. */
+  public void clear(long index) {
+    int wordNum = (int) (index >> 6); // div 64
+    if (wordNum >= wlen) return;
+    int bit = (int) index & 0x3f; // mod 64
+    long bitmask = 1L << bit;
+    buf.setLong(wordNum, buf.getLong(wordNum) & ~bitmask);
+  }
+
+  /**
+   * Clears a range of bits. Clearing past the end does not change the size of the set.
+   * 
+   * @param startIndex
+   *          lower index
+   * @param endIndex
+   *          one-past the last bit to clear
+   */
+  public void clear(int startIndex, int endIndex) {
+    if (endIndex <= startIndex) return;
+
+    int startWord = (startIndex >> 6);
+    if (startWord >= wlen) return;
+
+    // since endIndex is one past the end, this is index of the last
+    // word to be changed.
+    int endWord = ((endIndex - 1) >> 6);
+
+    long startmask = -1L << startIndex;
+    long endmask = -1L >>> -endIndex; // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+
+    // invert masks since we are clearing
+    startmask = ~startmask;
+    endmask = ~endmask;
+
+    if (startWord == endWord) {
+      buf.setLong(startWord, buf.getLong(startWord) & (startmask | endmask));
+      return;
+    }
+
+    buf.setLong(startWord, buf.getLong(startWord) & startmask);
+
+    int middle = Math.min(wlen, endWord);
+    fill(buf, startWord + 1, middle, 0L);
+    if (endWord < wlen) {
+      buf.setLong(endWord, buf.getLong(endWord) & endmask);
+    }
+  }
+
+  /**
+   * Clears a range of bits. Clearing past the end does not change the size of the set.
+   * 
+   * @param startIndex
+   *          lower index
+   * @param endIndex
+   *          one-past the last bit to clear
+   */
+  public void clear(long startIndex, long endIndex) {
+    if (endIndex <= startIndex) return;
+
+    int startWord = (int) (startIndex >> 6);
+    if (startWord >= wlen) return;
+
+    // since endIndex is one past the end, this is index of the last
+    // word to be changed.
+    int endWord = (int) ((endIndex - 1) >> 6);
+
+    long startmask = -1L << startIndex;
+    long endmask = -1L >>> -endIndex; // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+
+    // invert masks since we are clearing
+    startmask = ~startmask;
+    endmask = ~endmask;
+
+    if (startWord == endWord) {
+      buf.setLong(startWord, buf.getLong(startWord) & (startmask | endmask));
+      return;
+    }
+
+    buf.setLong(startWord, buf.getLong(startWord) & startmask);
+
+    int middle = Math.min(wlen, endWord);
+    fill(buf, startWord + 1, middle, 0L);
+    if (endWord < wlen) {
+      buf.setLong(endWord, buf.getLong(endWord) & endmask);
+    }
+  }
+
+  /**
+   * Sets a bit and returns the previous value. The index should be less than the BufBitSet size.
+   */
+  public boolean getAndSet(int index) {
+    assert index >= 0 && index < numBits;
+    int wordNum = index >> 6; // div 64
+    int bit = index & 0x3f; // mod 64
+    long bitmask = 1L << bit;
+    long longVal = buf.getLong(wordNum);
+    boolean val = (longVal & bitmask) != 0;
+    buf.setLong(wordNum, longVal | bitmask);
+    return val;
+  }
+
+  /**
+   * flips a bit. The index should be less than the BufBitSet size.
+   */
+  public void fastFlip(int index) {
+    assert index >= 0 && index < numBits;
+    int wordNum = index >> 6; // div 64
+    int bit = index & 0x3f; // mod 64
+    long bitmask = 1L << bit;
+    buf.setLong(wordNum, (buf.getLong(wordNum) ^ bitmask));
+  }
+
+  /**
+   * flips a bit. The index should be less than the BufBitSet size.
+   */
+  public void fastFlip(long index) {
+    assert index >= 0 && index < numBits;
+    int wordNum = (int) (index >> 6); // div 64
+    int bit = (int) index & 0x3f; // mod 64
+    long bitmask = 1L << bit;
+    buf.setLong(wordNum, (buf.getLong(wordNum) ^ bitmask));
+  }
+
+  /** flips a bit, expanding the set size if necessary */
+  public void flip(long index) {
+    int wordNum = expandingWordNum(index);
+    int bit = (int) index & 0x3f; // mod 64
+    long bitmask = 1L << bit;
+    buf.setLong(wordNum, (buf.getLong(wordNum) ^ bitmask));
+  }
+
+  /**
+   * flips a bit and returns the resulting bit value. The index should be less than the BufBitSet size.
+   */
+  public boolean flipAndGet(int index) {
+    assert index >= 0 && index < numBits;
+    int wordNum = index >> 6; // div 64
+    int bit = index & 0x3f; // mod 64
+    long bitmask = 1L << bit;
+    long longVal = buf.getLong(wordNum);
+    buf.setLong(wordNum, longVal ^ bitmask);
+    return (longVal & bitmask) != 0;
+  }
+
+  /**
+   * flips a bit and returns the resulting bit value. The index should be less than the BufBitSet size.
+   */
+  public boolean flipAndGet(long index) {
+    assert index >= 0 && index < numBits;
+    int wordNum = (int) (index >> 6); // div 64
+    int bit = (int) index & 0x3f; // mod 64
+    long bitmask = 1L << bit;
+    long longVal = buf.getLong(wordNum);
+    buf.setLong(wordNum, longVal ^ bitmask);
+    return (longVal & bitmask) != 0;
+  }
+
+  /**
+   * Flips a range of bits, expanding the set size if necessary
+   * 
+   * @param startIndex
+   *          lower index
+   * @param endIndex
+   *          one-past the last bit to flip
+   */
+  public void flip(long startIndex, long endIndex) {
+    if (endIndex <= startIndex) return;
+    int startWord = (int) (startIndex >> 6);
+
+    // since endIndex is one past the end, this is index of the last
+    // word to be changed.
+    int endWord = expandingWordNum(endIndex - 1);
+
+    /***
+     * Grrr, java shifting wraps around so -1L>>>64 == -1 for that reason, make sure not to use endmask if the bits to
+     * flip will be zero in the last word (redefine endWord to be the last changed...) long startmask = -1L <<
+     * (startIndex & 0x3f); // example: 11111...111000 long endmask = -1L >>> (64-(endIndex & 0x3f)); // example:
+     * 00111...111111
+     ***/
+
+    long startmask = -1L << startIndex;
+    long endmask = -1L >>> -endIndex; // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+
+    if (startWord == endWord) {
+      buf.setLong(startWord, buf.getLong(startWord) ^ (startmask & endmask));
+      return;
+    }
+
+    buf.setLong(startWord, buf.getLong(startWord) ^ startmask);
+
+    for (int i = startWord + 1; i < endWord; i++) {
+      buf.setLong(i, ~buf.getLong(i));
+    }
+
+    buf.setLong(endWord, buf.getLong(endWord) ^ endmask);
+  }
+
+  /*
+   * public static int pop(long v0, long v1, long v2, long v3) { // derived from pop_array by setting last four elems to
+   * 0. // exchanges one pop() call for 10 elementary operations // saving about 7 instructions... is there a better
+   * way? long twosA=v0 & v1; long ones=v0^v1;
+   * 
+   * long u2=ones^v2; long twosB =(ones&v2)|(u2&v3); ones=u2^v3;
+   * 
+   * long fours=(twosA&twosB); long twos=twosA^twosB;
+   * 
+   * return (pop(fours)<<2) + (pop(twos)<<1) + pop(ones);
+   * 
+   * }
+   */
+
+  /** @return the number of set bits */
+  public long cardinality() {
+    return BitUtil.pop_array(buf, 0, wlen);
+  }
+
+  /**
+   * Returns the popcount or cardinality of the intersection of the two sets. Neither set is modified.
+   */
+  public static long intersectionCount(BufBitSet a, BufBitSet b) {
+    return BitUtil.pop_intersect(a.buf, b.buf, 0, Math.min(a.wlen, b.wlen));
+  }
+
+  /**
+   * Returns the popcount or cardinality of the union of the two sets. Neither set is modified.
+   */
+  public static long unionCount(BufBitSet a, BufBitSet b) {
+    long tot = BitUtil.pop_union(a.buf, b.buf, 0, Math.min(a.wlen, b.wlen));
+    if (a.wlen < b.wlen) {
+      tot += BitUtil.pop_array(b.buf, a.wlen, b.wlen - a.wlen);
+    } else if (a.wlen > b.wlen) {
+      tot += BitUtil.pop_array(a.buf, b.wlen, a.wlen - b.wlen);
+    }
+    return tot;
+  }
+
+  /**
+   * Returns the popcount or cardinality of "a and not b" or "intersection(a, not(b))". Neither set is modified.
+   */
+  public static long andNotCount(BufBitSet a, BufBitSet b) {
+    long tot = BitUtil.pop_andnot(a.buf, b.buf, 0, Math.min(a.wlen, b.wlen));
+    if (a.wlen > b.wlen) {
+      tot += BitUtil.pop_array(a.buf, b.wlen, a.wlen - b.wlen);
+    }
+    return tot;
+  }
+
+  /**
+   * Returns the popcount or cardinality of the exclusive-or of the two sets. Neither set is modified.
+   */
+  public static long xorCount(BufBitSet a, BufBitSet b) {
+    long tot = BitUtil.pop_xor(a.buf, b.buf, 0, Math.min(a.wlen, b.wlen));
+    if (a.wlen < b.wlen) {
+      tot += BitUtil.pop_array(b.buf, a.wlen, b.wlen - a.wlen);
+    } else if (a.wlen > b.wlen) {
+      tot += BitUtil.pop_array(a.buf, b.wlen, a.wlen - b.wlen);
+    }
+    return tot;
+  }
+
+  /**
+   * Returns the index of the first set bit starting at the index specified. -1 is returned if there are no more set
+   * bits.
+   */
+  public int nextSetBit(int index) {
+    int i = index >> 6;
+    if (i >= wlen) return -1;
+    int subIndex = index & 0x3f; // index within the word
+    long word = buf.getLong(i) >> subIndex; // skip all the bits to the right of index
+
+    if (word != 0) {
+      return (i << 6) + subIndex + Long.numberOfTrailingZeros(word);
+    }
+
+    while (++i < wlen) {
+      word = buf.getLong(i);
+      if (word != 0) return (i << 6) + Long.numberOfTrailingZeros(word);
+    }
+
+    return -1;
+  }
+
+  /**
+   * Returns the index of the first set bit starting at the index specified. -1 is returned if there are no more set
+   * bits.
+   */
+  public long nextSetBit(long index) {
+    int i = (int) (index >>> 6);
+    if (i >= wlen) return -1;
+    int subIndex = (int) index & 0x3f; // index within the word
+    long word = buf.getLong(i) >>> subIndex; // skip all the bits to the right of index
+
+    if (word != 0) {
+      return (((long) i) << 6) + (subIndex + Long.numberOfTrailingZeros(word));
+    }
+
+    while (++i < wlen) {
+      word = buf.getLong(i);
+      if (word != 0) return (((long) i) << 6) + Long.numberOfTrailingZeros(word);
+    }
+
+    return -1;
+  }
+
+  /**
+   * Returns the index of the first set bit starting downwards at the index specified. -1 is returned if there are no
+   * more set bits.
+   */
+  public int prevSetBit(int index) {
+    int i = index >> 6;
+    final int subIndex;
+    long word;
+    if (i >= wlen) {
+      i = wlen - 1;
+      if (i < 0) return -1;
+      subIndex = 63; // last possible bit
+      word = buf.getLong(i);
+    } else {
+      if (i < 0) return -1;
+      subIndex = index & 0x3f; // index within the word
+      word = (buf.getLong(i) << (63 - subIndex)); // skip all the bits to the left of index
+    }
+
+    if (word != 0) {
+      return (i << 6) + subIndex - Long.numberOfLeadingZeros(word); // See LUCENE-3197
+    }
+
+    while (--i >= 0) {
+      word = buf.getLong(i);
+      if (word != 0) {
+        return (i << 6) + 63 - Long.numberOfLeadingZeros(word);
+      }
+    }
+
+    return -1;
+  }
+
+  /**
+   * Returns the index of the first set bit starting downwards at the index specified. -1 is returned if there are no
+   * more set bits.
+   */
+  public long prevSetBit(long index) {
+    int i = (int) (index >> 6);
+    final int subIndex;
+    long word;
+    if (i >= wlen) {
+      i = wlen - 1;
+      if (i < 0) return -1;
+      subIndex = 63; // last possible bit
+      word = buf.getLong(i);
+    } else {
+      if (i < 0) return -1;
+      subIndex = (int) index & 0x3f; // index within the word
+      word = (buf.getLong(i) << (63 - subIndex)); // skip all the bits to the left of index
+    }
+
+    if (word != 0) {
+      return (((long) i) << 6) + subIndex - Long.numberOfLeadingZeros(word); // See LUCENE-3197
+    }
+
+    while (--i >= 0) {
+      word = buf.getLong(i);
+      if (word != 0) {
+        return (((long) i) << 6) + 63 - Long.numberOfLeadingZeros(word);
+      }
+    }
+
+    return -1;
+  }
+
+  BufBitSet cloneTest() {
+    BufBitSet obs = new BufBitSet(allocator, buf.copy());
+    return obs;
+  }
+
+  /** this = this AND other */
+  public void intersect(BufBitSet other) {
+    int newLen = Math.min(this.wlen, other.wlen);
+    ByteBuf thisArr = this.buf;
+    ByteBuf otherArr = other.buf;
+    // testing against zero can be more efficient
+    int pos = newLen;
+    while (--pos >= 0) {
+      thisArr.setLong(pos, thisArr.getLong(pos) & otherArr.getLong(pos));
+    }
+    if (this.wlen > newLen) {
+      // fill zeros from the new shorter length to the old length
+      fill(buf, newLen, this.wlen, 0);
+    }
+    this.wlen = newLen;
+  }
+
+  /** this = this OR other */
+  public void union(BufBitSet other) {
+    int newLen = Math.max(wlen, other.wlen);
+    ensureCapacityWords(newLen);
+    assert (numBits = Math.max(other.numBits, numBits)) >= 0;
+
+    ByteBuf thisArr = this.buf;
+    ByteBuf otherArr = other.buf;
+
+    int pos = Math.min(wlen, other.wlen);
+    while (--pos >= 0) {
+      thisArr.setLong(pos, thisArr.getLong(pos) | otherArr.getLong(pos));
+    }
+    if (this.wlen < newLen) {
+      System.arraycopy(otherArr, this.wlen, thisArr, this.wlen, newLen - this.wlen);
+    }
+    this.wlen = newLen;
+  }
+
+  /** Remove all elements set in other. this = this AND_NOT other */
+  public void remove(BufBitSet other) {
+    int idx = Math.min(wlen, other.wlen);
+    ByteBuf thisArr = this.buf;
+    ByteBuf otherArr = other.buf;
+    while (--idx >= 0) {
+      thisArr.setLong(idx, thisArr.getLong(idx) & ~otherArr.getLong(idx));
+    }
+  }
+
+  /** this = this XOR other */
+  public void xor(BufBitSet other) {
+    int newLen = Math.max(wlen, other.wlen);
+    ensureCapacityWords(newLen);
+    assert (numBits = Math.max(other.numBits, numBits)) >= 0;
+
+    ByteBuf thisArr = this.buf;
+    ByteBuf otherArr = other.buf;
+    int pos = Math.min(wlen, other.wlen);
+    while (--pos >= 0) {
+      thisArr.setLong(pos, thisArr.getLong(pos) ^ otherArr.getLong(pos));
+    }
+    if (this.wlen < newLen) {
+      otherArr.readerIndex(wlen);
+      otherArr.writeBytes(thisArr);
+    }
+    this.wlen = newLen;
+
+  }
+
+  // some BitSet compatability methods
+
+  // ** see {@link intersect} */
+  public void and(BufBitSet other) {
+    intersect(other);
+  }
+
+  // ** see {@link union} */
+  public void or(BufBitSet other) {
+    union(other);
+  }
+
+  // ** see {@link andNot} */
+  public void andNot(BufBitSet other) {
+    remove(other);
+  }
+
+  /** returns true if the sets have any elements in common */
+  public boolean intersects(BufBitSet other) {
+    int pos = Math.min(this.wlen, other.wlen);
+    ByteBuf thisArr = this.buf;
+    ByteBuf otherArr = other.buf;
+    while (--pos >= 0) {
+      if ((thisArr.getLong(pos) & otherArr.getLong(pos)) != 0) return true;
+    }
+    return false;
+  }
+
+  public void ensureCapacityWords(int numWords) {
+    if (buf.capacity() < numWords) {
+      ByteBuf newBuf = allocator.buffer(numWords * 8);
+      buf.writeBytes(newBuf);
+      buf.release();
+      buf = newBuf;
+      this.numBits = numWords * 64;
+    }
+  }
+
+  /**
+   * Ensure that the long[] is big enough to hold numBits, expanding it if necessary. getNumWords() is unchanged by this
+   * call.
+   */
+  public void ensureCapacity(long numBits) {
+    ensureCapacityWords(bits2words(numBits));
+  }
+
+  /**
+   * Lowers numWords, the number of words in use, by checking for trailing zero words.
+   */
+  public void trimTrailingZeros() {
+    int idx = wlen - 1;
+    while (idx >= 0 && buf.getLong(idx) == 0)
+      idx--;
+    wlen = idx + 1;
+  }
+
+  /** returns the number of 64 bit words it would take to hold numBits */
+  public static int bits2words(long numBits) {
+    return (int) (((numBits - 1) >>> 6) + 1);
+  }
+
+  /** returns true if both sets have the same bits set */
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (!(o instanceof BufBitSet)) return false;
+    BufBitSet a;
+    BufBitSet b = (BufBitSet) o;
+    // make a the larger set.
+    if (b.wlen > this.wlen) {
+      a = b;
+      b = this;
+    } else {
+      a = this;
+    }
+
+    // check for any set bits out of the range of b
+    for (int i = a.wlen - 1; i >= b.wlen; i--) {
+      if (a.buf.getLong(i) != 0) return false;
+    }
+
+    for (int i = b.wlen - 1; i >= 0; i--) {
+      if (a.buf.getLong(i) != b.buf.getLong(i)) return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    // Start with a zero hash and use a mix that results in zero if the input is zero.
+    // This effectively truncates trailing zeros without an explicit check.
+    long h = 0;
+    for (int i = buf.capacity(); --i >= 0;) {
+      h ^= buf.getLong(i);
+      h = (h << 1) | (h >>> 63); // rotate left
+    }
+    // fold leftmost bits into right and add a constant to prevent
+    // empty sets from returning 0, which is too common.
+    return (int) ((h >> 32) ^ h) + 0x98761234;
+  }
+
+  public void release() {
+    this.buf.release();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b53933f2/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/ByteVector.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/ByteVector.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/ByteVector.java
new file mode 100644
index 0000000..258f1cc
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/ByteVector.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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.record.vector;
+
+import org.apache.drill.common.expression.types.DataType;
+import org.apache.drill.common.physical.RecordField.ValueMode;
+import org.apache.drill.exec.BufferAllocator;
+import org.apache.drill.exec.record.MaterializedField;
+
+
+public class ByteVector extends AbstractFixedValueVector<ByteVector>{
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ByteVector.class);
+
+  private final MaterializedField field;
+
+  public ByteVector(int fieldId, BufferAllocator allocator) {
+    super(fieldId, allocator, 8);
+    this.field = new MaterializedField(fieldId, DataType.SIGNED_BYTE, false, ValueMode.VECTOR, this.getClass());
+  }
+
+  @Override
+  public MaterializedField getField() {
+    return field;
+  }
+
+  public void setByte(int index, byte b){
+    data.setByte(index, b);
+  }
+
+  public byte getByte(int index){
+    return data.getByte(index);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b53933f2/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/Int32Vector.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/Int32Vector.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/Int32Vector.java
new file mode 100644
index 0000000..d8add04
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/Int32Vector.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * 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.record.vector;
+
+import org.apache.drill.common.expression.types.DataType;
+import org.apache.drill.common.physical.RecordField.ValueMode;
+import org.apache.drill.exec.BufferAllocator;
+import org.apache.drill.exec.record.MaterializedField;
+
+public class Int32Vector extends AbstractFixedValueVector<Int32Vector>{
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Int32Vector.class);
+  
+  private final MaterializedField field;
+
+  public Int32Vector(int fieldId, BufferAllocator allocator) {
+    super(fieldId, allocator, 32);
+    this.field = new MaterializedField(fieldId, DataType.INT32, false, ValueMode.VECTOR, this.getClass());
+  }
+
+  @Override
+  public MaterializedField getField() {
+    return field;
+  }
+
+  public final void set(int index, int value){
+    index*=4;
+    data.setInt(index, value);
+  }
+  
+  public final int get(int index){
+    index*=4;
+    return data.getInt(index);
+  }
+  
+  
+  
+}

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/b53933f2/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/NullableValueVector.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/NullableValueVector.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/NullableValueVector.java
new file mode 100644
index 0000000..b9bad6e
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/NullableValueVector.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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.record.vector;
+
+import io.netty.buffer.ByteBuf;
+
+import org.apache.drill.exec.BufferAllocator;
+
+/**
+ * Abstract class supports null versions.
+ */
+abstract class NullableValueVector<T extends NullableValueVector<T, E>, E extends BaseValueVector<E>> extends BaseValueVector<T> {
+  static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(NullableValueVector.class);
+
+  protected BitVector bits;
+  protected E value;
+
+  public NullableValueVector(int fieldId, BufferAllocator allocator) {
+    super(fieldId, allocator);
+    bits = new BitVector(fieldId, allocator);
+    value = getNewValueVector(fieldId, allocator);
+  }
+  
+  protected abstract E getNewValueVector(int fieldId, BufferAllocator allocator);
+
+  @Override
+  protected int getAllocationSize(int valueCount) {
+    return bits.getAllocationSize(valueCount) + value.getAllocationSize(valueCount);
+  }
+  
+  
+  @Override
+  protected void childResetAllocation(int valueCount, ByteBuf buf) {
+    super.resetAllocation(valueCount, buf);
+    int firstSize = bits.getAllocationSize(valueCount);
+    value.resetAllocation(valueCount, buf.slice(firstSize, value.getAllocationSize(valueCount)));
+    bits.resetAllocation(valueCount, buf.slice(0, firstSize));
+    bits.setAllFalse();
+  }
+
+  @Override
+  protected void childCloneMetadata(T other) {
+    bits.cloneMetadata(other.bits);
+    value.cloneInto(value);
+  }
+
+  @Override
+  protected void childClear() {
+    bits.clear();
+    value.clear();
+  }
+
+  
+}
+