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/07/20 03:57:23 UTC
[02/53] [abbrv] WIP fragmentation, physical plan, byte compiling,
some vector work
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/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
index c157b12..83ad599 100644
--- 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
@@ -19,7 +19,7 @@ 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.memory.BufferAllocator;
import org.apache.drill.exec.record.MaterializedField;
/**
@@ -40,17 +40,25 @@ public class BitVector extends AbstractFixedValueVector<BitVector> {
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) {
+// /** 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;
+// }
+
+ public int getBit(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;
+ int i = 8*(index >> 6); // div 8
+ int bit = index & 0x3f; // mod 64
+ return ((int) (data.getLong(i) >>> bit)) & 0x01;
}
/** Sets the bit at the specified index.
@@ -73,41 +81,42 @@ public class BitVector extends AbstractFixedValueVector<BitVector> {
}
+
/** 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
+ * @param startBitIndex lower index
+ * @param lastBitIndex one-past the last bit to clear
*/
- private void clear(int startIndex, int endIndex) {
- if (endIndex <= startIndex) return;
+ private void clear2(int startBitIndex, int lastBitIndex) {
+ if (lastBitIndex <= startBitIndex) return;
- int startWord = (startIndex>>3);
- if (startWord >= this.longWords) return;
+ int firstWordStart = (startBitIndex>>3);
+ if (firstWordStart >= 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);
+ int lastWordStart = ((lastBitIndex-1)>>3);
- long startmask = -1L << startIndex;
- long endmask = -1L >>> -endIndex; // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+ long startmask = -1L << startBitIndex;
+ long endmask = -1L >>> -lastBitIndex; // 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));
+ if (firstWordStart == lastWordStart) {
+ data.setLong(firstWordStart, data.getLong(firstWordStart) & (startmask | endmask));
return;
}
+ data.setLong(firstWordStart, data.getLong(firstWordStart) & startmask);
- data.setLong(startWord, data.getLong(startWord) & startmask);
-
- int middle = Math.min(this.longWords, endWord);
- for(int i =startWord+1; i < middle; i += 8){
+ int middle = Math.min(this.longWords, lastWordStart);
+
+ for(int i =firstWordStart+8; i < middle; i += 8){
data.setLong(i, 0L);
}
- if (endWord < this.longWords) {
- data.setLong(endWord, data.getLong(endWord) & endmask);
+ if (lastWordStart < this.longWords) {
+ data.setLong(lastWordStart, data.getLong(lastWordStart) & endmask);
}
}
@@ -115,4 +124,43 @@ public class BitVector extends AbstractFixedValueVector<BitVector> {
clear(0, valueCount);
}
+
+ public void clear(int startIndex, int endIndex) {
+ if (endIndex <= startIndex) return;
+
+ int startWord = (startIndex >> 6);
+ if (startWord >= longWords) 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;
+
+ int startWordPos = startWord * 8;
+ if (startWord == endWord) {
+ data.setLong(startWordPos, data.getLong(startWordPos) & (startmask | endmask));
+ return;
+ }
+
+ int endWordPos = endWord * 8;
+
+ data.setLong(startWordPos, data.getLong(startWordPos) & startmask);
+
+ int middle = Math.min(longWords, endWord)*8;
+
+
+ for(int i =startWordPos+8; i < middle; i += 8){
+ data.setLong(i, 0L);
+ }
+
+ if (endWordPos < startWordPos) {
+ data.setLong(endWordPos, data.getLong(endWordPos) & endmask);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/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
index 258f1cc..d8e1c80 100644
--- 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
@@ -19,7 +19,7 @@ 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.memory.BufferAllocator;
import org.apache.drill.exec.record.MaterializedField;
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/Int16Vector.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/Int16Vector.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/Int16Vector.java
new file mode 100644
index 0000000..779b01b
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/Int16Vector.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.memory.BufferAllocator;
+import org.apache.drill.exec.record.MaterializedField;
+
+public final class Int16Vector extends AbstractFixedValueVector<Int16Vector>{
+ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Int16Vector.class);
+
+ private final MaterializedField field;
+
+ public Int16Vector(int fieldId, BufferAllocator allocator) {
+ super(fieldId, allocator, 32);
+ this.field = new MaterializedField(fieldId, DataType.INT16, false, ValueMode.VECTOR, this.getClass());
+ }
+
+ @Override
+ public MaterializedField getField() {
+ return field;
+ }
+
+ public final void set(int index, short value){
+ index*=2;
+ data.setShort(index, value);
+ }
+
+ public final short get(int index){
+ index*=2;
+ return data.getShort(index);
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/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
index d8add04..d142367 100644
--- 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
@@ -19,10 +19,10 @@ 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.memory.BufferAllocator;
import org.apache.drill.exec.record.MaterializedField;
-public class Int32Vector extends AbstractFixedValueVector<Int32Vector>{
+public final class Int32Vector extends AbstractFixedValueVector<Int32Vector>{
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Int32Vector.class);
private final MaterializedField field;
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/NullableInt32Vector.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/NullableInt32Vector.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/NullableInt32Vector.java
new file mode 100644
index 0000000..372de13
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/NullableInt32Vector.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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.exec.memory.BufferAllocator;
+import org.apache.drill.exec.record.MaterializedField;
+
+public final class NullableInt32Vector extends NullableValueVector<NullableInt32Vector, Int32Vector>{
+
+ public NullableInt32Vector(int fieldId, BufferAllocator allocator) {
+ super(fieldId, allocator, NullableInt32Vector.class);
+ }
+
+
+ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(NullableInt32Vector.class);
+
+
+ public int get(int index){
+ return this.value.get(index);
+ }
+
+ public void set(int index, int value){
+ this.value.set(index, value);
+ }
+
+
+ @Override
+ protected Int32Vector getNewValueVector(int fieldId, BufferAllocator allocator) {
+ return new Int32Vector(fieldId, allocator);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/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
index b9bad6e..8e714ed 100644
--- 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
@@ -19,7 +19,8 @@ package org.apache.drill.exec.record.vector;
import io.netty.buffer.ByteBuf;
-import org.apache.drill.exec.BufferAllocator;
+import org.apache.drill.exec.memory.BufferAllocator;
+import org.apache.drill.exec.record.MaterializedField;
/**
* Abstract class supports null versions.
@@ -29,24 +30,33 @@ abstract class NullableValueVector<T extends NullableValueVector<T, E>, E extend
protected BitVector bits;
protected E value;
+ private final MaterializedField field;
- public NullableValueVector(int fieldId, BufferAllocator allocator) {
+ public NullableValueVector(int fieldId, BufferAllocator allocator, Class<T> valueClass) {
super(fieldId, allocator);
bits = new BitVector(fieldId, allocator);
value = getNewValueVector(fieldId, allocator);
+ this.field = value.getField().getNullableVersion(valueClass);
}
protected abstract E getNewValueVector(int fieldId, BufferAllocator allocator);
+ public int isNull(int index){
+ return bits.getBit(index);
+ }
+
@Override
protected int getAllocationSize(int valueCount) {
return bits.getAllocationSize(valueCount) + value.getAllocationSize(valueCount);
}
-
+ @Override
+ public MaterializedField getField() {
+ return field;
+ }
+
@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));
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/SelectionVector.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/SelectionVector.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/SelectionVector.java
new file mode 100644
index 0000000..e9faa93
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/SelectionVector.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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.ByteBufAllocator;
+
+import org.apache.drill.exec.memory.BufferAllocator;
+
+public class SelectionVector extends UInt16Vector{
+ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(SelectionVector.class);
+
+ public SelectionVector(int fieldId, BufferAllocator allocator) {
+ super(fieldId, allocator);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/UInt16Vector.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/UInt16Vector.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/UInt16Vector.java
new file mode 100644
index 0000000..87c306b
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/UInt16Vector.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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.memory.BufferAllocator;
+import org.apache.drill.exec.record.MaterializedField;
+
+public class UInt16Vector extends AbstractFixedValueVector<Int32Vector>{
+ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(UInt16Vector.class);
+
+ private final MaterializedField field;
+
+ public UInt16Vector(int fieldId, BufferAllocator allocator) {
+ super(fieldId, allocator, 16);
+ this.field = new MaterializedField(fieldId, DataType.UINT16, false, ValueMode.VECTOR, this.getClass());
+ }
+
+ @Override
+ public MaterializedField getField() {
+ return field;
+ }
+
+ public final void set(int index, char value){
+ index*=2;
+ data.setChar(index, value);
+ }
+
+ public final char get(int index){
+ index*=2;
+ return data.getChar(index);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/ValueVector.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/ValueVector.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/ValueVector.java
index 97a9b3b..76b0e90 100644
--- a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/ValueVector.java
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/ValueVector.java
@@ -66,6 +66,7 @@ public interface ValueVector<T extends ValueVector<T>> extends Closeable {
*/
public abstract int size();
+
/**
* Release supporting resources.
*/
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/VariableVector.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/VariableVector.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/VariableVector.java
index bae45dc..dd84c94 100644
--- a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/VariableVector.java
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/record/vector/VariableVector.java
@@ -19,7 +19,7 @@ package org.apache.drill.exec.record.vector;
import io.netty.buffer.ByteBuf;
-import org.apache.drill.exec.BufferAllocator;
+import org.apache.drill.exec.memory.BufferAllocator;
import org.apache.drill.exec.record.DeadBuf;
/**
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/BitCom.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/BitCom.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/BitCom.java
index 5c1bf21..2349899 100644
--- a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/BitCom.java
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/BitCom.java
@@ -22,9 +22,10 @@ import io.netty.channel.socket.SocketChannel;
import io.netty.util.concurrent.GenericFutureListener;
import java.io.Closeable;
+import java.util.Collection;
+import org.apache.drill.common.proto.CoordinationProtos.DrillbitEndpoint;
import org.apache.drill.exec.ops.FragmentContext;
-import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
import org.apache.drill.exec.proto.ExecProtos.FragmentHandle;
import org.apache.drill.exec.proto.ExecProtos.FragmentStatus;
import org.apache.drill.exec.proto.ExecProtos.PlanFragment;
@@ -41,13 +42,21 @@ import org.apache.drill.exec.rpc.RpcBus;
public interface BitCom extends Closeable{
/**
- * Send a record batch to another node.
+ * Routes the output of a RecordBatch to another node. The record batch
* @param node The node id to send the record batch to.
* @param batch The record batch to send.
- * @return A Future<Ack> object that can be used to determine the outcome of sending.
+ * @return A SendProgress object which can be used to monitor the sending of the batch.
*/
public abstract DrillRpcFuture<Ack> sendRecordBatch(FragmentContext context, DrillbitEndpoint node, RecordBatch batch);
+
+ /**
+ * Requests an iterator to access an incoming record batch.
+ * @param fragmentId
+ * @return
+ */
+ public RecordBatch getReceivingRecordBatchHandle(int majorFragmentId, int minorFragmentId);
+
/**
* Send a query PlanFragment to another bit.
* @param context
@@ -56,6 +65,9 @@ public interface BitCom extends Closeable{
* @return
*/
public abstract DrillRpcFuture<FragmentHandle> sendFragment(FragmentContext context, DrillbitEndpoint node, PlanFragment fragment);
+
+ public abstract void startQuery(Collection<DrillbitEndpoint> firstNodes, long queryId);
+
public abstract DrillRpcFuture<Ack> cancelFragment(FragmentContext context, DrillbitEndpoint node, FragmentHandle handle);
@@ -65,5 +77,13 @@ public interface BitCom extends Closeable{
public interface TunnelListener extends GenericFutureListener<ChannelFuture> {
public void connectionEstablished(SocketChannel channel, DrillbitEndpoint endpoint, RpcBus<?> bus);
}
+
+ public interface SendManager{
+ /**
+ * Sender responsible for regularly checking this value to see whether it should continue to send or yield the process
+ * @return
+ */
+ public boolean canContinue();
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/BitComHandler.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/BitComHandler.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/BitComHandler.java
index 94e3eff..b2c5cbb 100644
--- a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/BitComHandler.java
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/BitComHandler.java
@@ -21,7 +21,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelFuture;
import io.netty.channel.socket.SocketChannel;
-import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
+import org.apache.drill.common.proto.CoordinationProtos.DrillbitEndpoint;
import org.apache.drill.exec.proto.ExecProtos.BitBatchChunk;
import org.apache.drill.exec.proto.ExecProtos.BitHandshake;
import org.apache.drill.exec.proto.ExecProtos.BitStatus;
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/BitComImpl.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/BitComImpl.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/BitComImpl.java
index dd00e04..aada154 100644
--- a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/BitComImpl.java
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/BitComImpl.java
@@ -21,12 +21,13 @@ import io.netty.channel.Channel;
import io.netty.channel.socket.SocketChannel;
import io.netty.util.concurrent.Future;
+import java.util.Collection;
import java.util.Map;
+import org.apache.drill.common.proto.CoordinationProtos.DrillbitEndpoint;
import org.apache.drill.exec.ExecConstants;
import org.apache.drill.exec.exception.DrillbitStartupException;
import org.apache.drill.exec.ops.FragmentContext;
-import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
import org.apache.drill.exec.proto.ExecProtos.FragmentHandle;
import org.apache.drill.exec.proto.ExecProtos.FragmentStatus;
import org.apache.drill.exec.proto.ExecProtos.PlanFragment;
@@ -81,10 +82,7 @@ public class BitComImpl implements BitCom {
// return null;
}
- @Override
- public DrillRpcFuture<Ack> sendRecordBatch(FragmentContext context, DrillbitEndpoint node, RecordBatch batch) {
- return null;
- }
+
@Override
public DrillRpcFuture<FragmentHandle> sendFragment(FragmentContext context, DrillbitEndpoint node,
@@ -129,7 +127,6 @@ public class BitComImpl implements BitCom {
tunnels.put(endpoint, new BitTunnel(bus));
}
}
-
}
public void close() {
@@ -139,4 +136,19 @@ public class BitComImpl implements BitCom {
}
}
+
+ @Override
+ public DrillRpcFuture<Ack> sendRecordBatch(FragmentContext context, DrillbitEndpoint node, RecordBatch batch) {
+ return null;
+ }
+
+ @Override
+ public RecordBatch getReceivingRecordBatchHandle(int majorFragmentId, int minorFragmentId) {
+ return null;
+ }
+
+ @Override
+ public void startQuery(Collection<DrillbitEndpoint> firstNodes, long queryId) {
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/SendProgress.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/SendProgress.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/SendProgress.java
new file mode 100644
index 0000000..8ede9e6
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/bit/SendProgress.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.rpc.bit;
+
+public class SendProgress {
+ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(SendProgress.class);
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserClient.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserClient.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserClient.java
index cd6e15d..0088522 100644
--- a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserClient.java
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserClient.java
@@ -43,6 +43,10 @@ public class UserClient extends BasicClient<RpcType> {
}
+ public DrillRpcFuture<QueryHandle> submitQuery(RunQuery query) throws RpcException {
+ return this.send(RpcType.RUN_QUERY, query, QueryHandle.class, null);
+ }
+
public DrillRpcFuture<QueryHandle> submitQuery(RunQuery query, ByteBuf data) throws RpcException {
return this.send(RpcType.RUN_QUERY, query, QueryHandle.class, data);
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java
index fe70c85..cccaa55 100644
--- a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java
@@ -66,7 +66,7 @@ public class UserServer extends BasicServer<RpcType> {
@Override
protected Response handle(SocketChannel channel, int rpcType, ByteBuf pBody, ByteBuf dBody) throws RpcException {
switch (rpcType) {
-
+
case RpcType.HANDSHAKE_VALUE:
// logger.debug("Received handshake, responding in kind.");
return new Response(RpcType.HANDSHAKE, BitToUserHandshake.getDefaultInstance(), null);
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java
index 2961fae..c33afce 100644
--- a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/server/Drillbit.java
@@ -17,9 +17,10 @@
******************************************************************************/
package org.apache.drill.exec.server;
-import com.google.common.io.Closeables;
+import java.net.InetAddress;
+
import org.apache.drill.common.config.DrillConfig;
-import org.apache.drill.exec.BufferAllocator;
+import org.apache.drill.common.proto.CoordinationProtos.DrillbitEndpoint;
import org.apache.drill.exec.ExecConstants;
import org.apache.drill.exec.cache.DistributedCache;
import org.apache.drill.exec.cache.HazelCache;
@@ -27,10 +28,10 @@ import org.apache.drill.exec.coord.ClusterCoordinator;
import org.apache.drill.exec.coord.ClusterCoordinator.RegistrationHandle;
import org.apache.drill.exec.coord.ZKClusterCoordinator;
import org.apache.drill.exec.exception.DrillbitStartupException;
-import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
+import org.apache.drill.exec.memory.BufferAllocator;
import org.apache.drill.exec.service.ServiceEngine;
-import java.net.InetAddress;
+import com.google.common.io.Closeables;
/**
* Starts, tracks and stops all the required services for a Drillbit daemon to work.
@@ -69,6 +70,7 @@ public class Drillbit {
final ClusterCoordinator coord;
final ServiceEngine engine;
final DistributedCache cache;
+ final DrillConfig config;
private RegistrationHandle handle;
public Drillbit(DrillConfig config) throws Exception {
@@ -79,6 +81,7 @@ public class Drillbit {
this.coord = new ZKClusterCoordinator(config);
this.engine = new ServiceEngine(context);
this.cache = new HazelCache(context.getConfig());
+ this.config = config;
}
public void run() throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/server/DrillbitContext.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/server/DrillbitContext.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/server/DrillbitContext.java
index e3a24d2..b08b070 100644
--- a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/server/DrillbitContext.java
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/server/DrillbitContext.java
@@ -20,13 +20,18 @@ package org.apache.drill.exec.server;
import io.netty.channel.nio.NioEventLoopGroup;
import java.util.Collection;
-import java.util.List;
import org.apache.drill.common.config.DrillConfig;
-import org.apache.drill.exec.BufferAllocator;
-import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
+import org.apache.drill.common.logical.StorageEngineConfig;
+import org.apache.drill.common.proto.CoordinationProtos.DrillbitEndpoint;
+import org.apache.drill.exec.ExecConstants;
+import org.apache.drill.exec.cache.DistributedCache;
+import org.apache.drill.exec.memory.BufferAllocator;
import org.apache.drill.exec.rpc.NamedThreadFactory;
import org.apache.drill.exec.rpc.bit.BitCom;
+import org.apache.drill.exec.store.StorageEngine;
+
+import com.yammer.metrics.MetricRegistry;
public class DrillbitContext {
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillbitContext.class);
@@ -34,12 +39,14 @@ public class DrillbitContext {
private final DrillConfig config;
private final Drillbit underlyingBit;
private final NioEventLoopGroup loop;
-
+ private final MetricRegistry metrics;
+
public DrillbitContext(DrillConfig config, Drillbit underlyingBit) {
super();
this.config = config;
this.underlyingBit = underlyingBit;
this.loop = new NioEventLoopGroup(1, new NamedThreadFactory("BitServer-"));
+ this.metrics = new MetricRegistry(config.getString(ExecConstants.METRICS_CONTEXT_NAME));
}
public DrillConfig getConfig() {
@@ -54,6 +61,9 @@ public class DrillbitContext {
return underlyingBit.pool;
}
+ public StorageEngine getStorageEngine(StorageEngineConfig config){
+ throw new UnsupportedOperationException();
+ }
public NioEventLoopGroup getBitLoopGroup(){
return loop;
@@ -63,4 +73,13 @@ public class DrillbitContext {
return underlyingBit.engine.getBitCom();
}
+ public MetricRegistry getMetrics(){
+ return metrics;
+ }
+
+ public DistributedCache getCache(){
+ return underlyingBit.cache;
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/AbstractStorageEngine.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/AbstractStorageEngine.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/AbstractStorageEngine.java
new file mode 100644
index 0000000..d89b431
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/AbstractStorageEngine.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * 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.store;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.drill.common.logical.data.Scan;
+import org.apache.drill.common.proto.CoordinationProtos.DrillbitEndpoint;
+import org.apache.drill.exec.ops.FragmentContext;
+
+import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Multimap;
+
+public class AbstractStorageEngine implements StorageEngine{
+ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AbstractStorageEngine.class);
+
+ @Override
+ public boolean supportsRead() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsWrite() {
+ return false;
+ }
+
+ @Override
+ public List<QueryOptimizerRule> getOptimizerRules() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public Collection<ReadEntry> getReadEntries(Scan scan) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public ListMultimap<ReadEntry, DrillbitEndpoint> getReadLocations(Collection<ReadEntry> entries) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public RecordReader getReader(FragmentContext context, ReadEntry readEntry) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public RecordRecorder getWriter(FragmentContext context, WriteEntry writeEntry) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Multimap<DrillbitEndpoint, ReadEntry> getEntryAssignments(List<DrillbitEndpoint> assignments,
+ Collection<ReadEntry> entries) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Multimap<DrillbitEndpoint, WriteEntry> getWriteAssignments(List<DrillbitEndpoint> assignments,
+ Collection<ReadEntry> entries) {
+ throw new UnsupportedOperationException();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/StorageEngine.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/StorageEngine.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/StorageEngine.java
index 83749c7..67ea5b6 100644
--- a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/StorageEngine.java
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/StorageEngine.java
@@ -22,10 +22,11 @@ import java.util.Collection;
import java.util.List;
import org.apache.drill.common.logical.data.Scan;
+import org.apache.drill.common.proto.CoordinationProtos.DrillbitEndpoint;
import org.apache.drill.exec.ops.FragmentContext;
-import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Multimap;
public interface StorageEngine {
public boolean supportsRead();
@@ -58,7 +59,22 @@ public interface StorageEngine {
public ListMultimap<ReadEntry, DrillbitEndpoint> getReadLocations(Collection<ReadEntry> entries);
/**
+ * Apply read entry assignments based on the list of actually assigned Endpoints. A storage engine is allowed to
+ * update or modify the read entries based on the nature of the assignments. For example, if two blocks are initially
+ * considered separate read entries but then the storage engine realizes that the assignments for those two reads are
+ * on the same system, the storage engine may decide to collapse those entries into a single read entry that covers
+ * both original read entries.
+ *
+ * @param assignments
+ * @param entries
+ * @return
+ */
+ public Multimap<DrillbitEndpoint, ReadEntry> getEntryAssignments(List<DrillbitEndpoint> assignments,
+ Collection<ReadEntry> entries);
+
+ /**
* Get a particular reader for a fragment context.
+ *
* @param context
* @param readEntry
* @return
@@ -67,6 +83,19 @@ public interface StorageEngine {
public RecordReader getReader(FragmentContext context, ReadEntry readEntry) throws IOException;
/**
+ * Apply write entry assignments based on the list of actually assigned endpoints. A storage engine is allowed to
+ * rewrite the WriteEntries if desired based on the nature of the assignments. For example, a storage engine could
+ * hold off actually determining the specific level of partitioning required until it finds out exactly the number of
+ * nodes associated with the operation.
+ *
+ * @param assignments
+ * @param entries
+ * @return
+ */
+ public Multimap<DrillbitEndpoint, WriteEntry> getWriteAssignments(List<DrillbitEndpoint> assignments,
+ Collection<ReadEntry> entries);
+
+ /**
*
* @param context
* @param writeEntry
@@ -75,7 +104,6 @@ public interface StorageEngine {
*/
public RecordRecorder getWriter(FragmentContext context, WriteEntry writeEntry) throws IOException;
-
public interface ReadEntry {
public Cost getCostEstimate();
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/StorageEngineRegistry.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/StorageEngineRegistry.java b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/StorageEngineRegistry.java
index b2e31e9..eef878e 100644
--- a/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/StorageEngineRegistry.java
+++ b/sandbox/prototype/exec/java-exec/src/main/java/org/apache/drill/exec/store/StorageEngineRegistry.java
@@ -51,14 +51,14 @@ public class StorageEngineRegistry {
for(Constructor<?> c : engine.getConstructors()){
Class<?>[] params = c.getParameterTypes();
if(params.length != 2 || params[1] == DrillbitContext.class || !StorageEngineConfig.class.isAssignableFrom(params[0])){
- logger.debug("Skipping ReferenceStorageEngine constructor {} for engine class {} since it doesn't implement a [constructor(StorageEngineConfig, DrillbitContext)]", c, engine);
+ logger.debug("Skipping StorageEngine constructor {} for engine class {} since it doesn't implement a [constructor(StorageEngineConfig, DrillbitContext)]", c, engine);
continue;
}
availableEngines.put(params[0], (Constructor<? extends StorageEngine>) c);
i++;
}
if(i == 0){
- logger.debug("Skipping registration of ReferenceStorageEngine {} as it doesn't have a constructor with the parameters of (StorangeEngineConfig, Config)", engine.getCanonicalName());
+ logger.debug("Skipping registration of StorageEngine {} as it doesn't have a constructor with the parameters of (StorangeEngineConfig, Config)", engine.getCanonicalName());
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/protobuf/Coordination.proto
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/protobuf/Coordination.proto b/sandbox/prototype/exec/java-exec/src/main/protobuf/Coordination.proto
deleted file mode 100644
index 43c408d..0000000
--- a/sandbox/prototype/exec/java-exec/src/main/protobuf/Coordination.proto
+++ /dev/null
@@ -1,32 +0,0 @@
-package exec;
-
-option java_package = "org.apache.drill.exec.proto";
-option java_outer_classname = "CoordinationProtos";
-option optimize_for = LITE_RUNTIME;
-
-message DrillbitEndpoint{
- optional string address = 1;
- optional int32 user_port = 2;
- optional int32 bit_port = 3;
- optional Roles roles = 4;
-}
-
-message DrillServiceInstance{
- optional string id = 1;
- optional int64 registrationTimeUTC = 2;
- optional DrillbitEndpoint endpoint = 3;
-}
-
-message WorkQueueStatus{
- optional DrillbitEndpoint endpoint = 1;
- optional int32 queue_length = 2;
- optional int64 report_time = 3;
-}
-
-message Roles{
- optional bool sql_query = 1 [default = true];
- optional bool logical_plan = 2 [default = true];
- optional bool physical_plan = 3 [default = true];
- optional bool java_executor = 4 [default = true];
- optional bool distributed_cache = 5 [default = true];
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/protobuf/ExecutionProtos.proto
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/protobuf/ExecutionProtos.proto b/sandbox/prototype/exec/java-exec/src/main/protobuf/ExecutionProtos.proto
index cd8bda2..77a7ee1 100644
--- a/sandbox/prototype/exec/java-exec/src/main/protobuf/ExecutionProtos.proto
+++ b/sandbox/prototype/exec/java-exec/src/main/protobuf/ExecutionProtos.proto
@@ -29,37 +29,63 @@ enum RpcType {
}
-message BitColumnData {
+message BitHandshake{
+ optional DrillbitEndpoint endpoint = 1;
+}
- enum ColumnEncoding {
- PROTOBUF = 0;
- }
-
- message BitColumn {
- optional int32 field = 1;
- optional int32 length = 2;
- optional ColumnEncoding mode = 3;
- }
+message BitBatchChunk {}
+
+message BitStatus {
+ repeated ActiveFragment fragment = 1;
+}
+
+message ActiveFragment {
+ optional FragmentStatus status = 1;
+ optional int64 fragment_id = 2;
+ optional int64 query_id = 3;
+}
+
+message FragmentStatus {
- optional SchemaDef schema = 1;
- optional int32 record_count = 2;
- optional int32 total_size = 3;
- repeated BitColumn column = 4;
+ enum FragmentState {
+ AWAITING_ALLOCATION = 0;
+ RUNNING = 1;
+ FINISHED = 2;
+ CANCELLED = 3;
+ FAILED = 4;
+ }
+ optional int64 memory_use = 1;
+ optional int64 batches_completed = 2;
+ optional int64 records_completed = 3;
+ optional int32 estimated_completion_percentage = 4;
+ optional FragmentState state = 5;
+ optional int64 data_processed = 6;
}
-
-message BitHandshake{
- optional DrillbitEndpoint endpoint = 1;
+message RecordBatchHeader {
}
-message BitBatchChunk {}
-message BitStatus {}
-message FragmentStatus {}
-message RecordBatchHeader {}
-message PlanFragment {}
+message PlanFragment {
+ optional int64 query_id = 1;
+ optional int32 major_fragment_id = 2;
+ optional int32 minor_fragment_id = 3;
+ optional float network_cost = 4;
+ optional float cpu_cost = 5;
+ optional float disk_cost = 6;
+ optional float memory_cost = 7;
+ optional string fragment_json = 8;
+ optional bool self_driven = 9;
+ optional DrillbitEndpoint assignment = 10;
+}
message FragmentHandle {
- optional int64 fragment_id = 1;
+ optional int32 major_fragment_id = 1;
+ optional int32 minor_fragment_id = 1;
}
+message WorkQueueStatus{
+ optional DrillbitEndpoint endpoint = 1;
+ optional int32 queue_length = 2;
+ optional int64 report_time = 3;
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/main/protobuf/SchemaDef.proto
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/main/protobuf/SchemaDef.proto b/sandbox/prototype/exec/java-exec/src/main/protobuf/SchemaDef.proto
index 44e2df9..6e983d4 100644
--- a/sandbox/prototype/exec/java-exec/src/main/protobuf/SchemaDef.proto
+++ b/sandbox/prototype/exec/java-exec/src/main/protobuf/SchemaDef.proto
@@ -27,11 +27,18 @@ message SchemaDef {
repeated FieldDef field = 1;
}
+enum ValueMode {
+ VALUE_VECTOR = 0;
+ RLE = 1;
+ DICT = 2;
+}
+
message FieldDef {
optional string name = 1;
- optional DataMode mode = 2;
+ optional DataMode data_mode = 2;
+ optional ValueMode value_mode = 3;
// If DataMode == 0-2, type should be populated and fields should be empty. Otherwise, type should empty and fields should be defined.
- optional DataType type = 3;
- repeated FieldDef fields = 4;
+ optional DataType type = 4;
+ repeated FieldDef fields = 5;
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/test/java/BBOutputStream.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/test/java/BBOutputStream.java b/sandbox/prototype/exec/java-exec/src/test/java/BBOutputStream.java
deleted file mode 100644
index 7f03dfa..0000000
--- a/sandbox/prototype/exec/java-exec/src/test/java/BBOutputStream.java
+++ /dev/null
@@ -1,38 +0,0 @@
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-
-/*******************************************************************************
- * 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.
- ******************************************************************************/
-
-public class BBOutputStream extends OutputStream{
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(BBOutputStream.class);
-
- private ByteBuffer buf;
-
- public BBOutputStream(ByteBuffer buf) {
- this.buf = buf;
- }
-
- @Override
- public void write(int b) throws IOException {
- buf.put((byte) b);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/test/java/CompressingBytesColumn.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/test/java/CompressingBytesColumn.java b/sandbox/prototype/exec/java-exec/src/test/java/CompressingBytesColumn.java
deleted file mode 100644
index 4fb67ed..0000000
--- a/sandbox/prototype/exec/java-exec/src/test/java/CompressingBytesColumn.java
+++ /dev/null
@@ -1,46 +0,0 @@
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-
-/*******************************************************************************
- * 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.
- ******************************************************************************/
-
-public class CompressingBytesColumn {
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(CompressingBytesColumn.class);
-
- int mb = 1024*1024;
-
- ByteBuffer values = ByteBuffer.allocateDirect(20*mb);
- ByteBuffer fromCompressBuffer = ByteBuffer.allocateDirect(mb);
- ByteBuffer toCompressBuffer = ByteBuffer.allocateDirect(mb);
-
-
- public CompressingBytesColumn(){
- }
-
- public void add(byte[] bytes, int start, int length){
-
- }
-
- public void add(ByteBuffer buffer){
-
- }
- public void write(OutputStream stream){
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/test/java/ExternalSort.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/test/java/ExternalSort.java b/sandbox/prototype/exec/java-exec/src/test/java/ExternalSort.java
deleted file mode 100644
index c6233ae..0000000
--- a/sandbox/prototype/exec/java-exec/src/test/java/ExternalSort.java
+++ /dev/null
@@ -1,21 +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.
- ******************************************************************************/
-
-public class ExternalSort {
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ExternalSort.class);
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/test/java/GenerateExternalSortData.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/test/java/GenerateExternalSortData.java b/sandbox/prototype/exec/java-exec/src/test/java/GenerateExternalSortData.java
deleted file mode 100644
index dca7d27..0000000
--- a/sandbox/prototype/exec/java-exec/src/test/java/GenerateExternalSortData.java
+++ /dev/null
@@ -1,124 +0,0 @@
-import java.io.BufferedReader;
-import java.nio.ByteBuffer;
-import java.nio.IntBuffer;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-
-import org.apache.hadoop.conf.Configuration;
-import org.xerial.snappy.Snappy;
-
-import com.google.common.base.Charsets;
-import com.google.protobuf.CodedOutputStream;
-
-/*******************************************************************************
- * 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.
- ******************************************************************************/
-
-public class GenerateExternalSortData {
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(GenerateExternalSortData.class);
-
- /** Convert sequence file in to compressed columnar format.
- *
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Exception{
- int mb = 1024*1024;
- final int blockSize = 1024;
- ByteBuffer keys = ByteBuffer.allocateDirect(2*mb);
- ByteBuffer values = ByteBuffer.allocateDirect(20*mb);
- ByteBuffer fromCompressBuffer = ByteBuffer.allocateDirect(mb);
- ByteBuffer toCompressBuffer = ByteBuffer.allocateDirect(mb);
-
- ByteBuffer valueLengthB = ByteBuffer.allocateDirect(blockSize*4);
- IntBuffer valueLengths = valueLengthB.asIntBuffer();
- //Opaque value stored as len,data.
-
- //
- //Snappy.compress(uncompressed, compressed);
- String file = "/opt/data/tera1gb/part-00000";
- Configuration config = new Configuration();
- //SequenceFile.Reader sf = new SequenceFile.Reader(FileSystem.getLocal(config), new Path(file), config);
-
- BufferedReader reader = Files.newBufferedReader(FileSystems.getDefault().getPath(file), Charsets.UTF_8);
-
- CodedOutputStream cos = CodedOutputStream.newInstance(new BBOutputStream(values));
-
- long originalBytes = 0;
- long compressedBytes = 0;
- String l;
- int round = 0;
- long nanos = 0;
- long x1 = System.nanoTime();
- while((l = reader.readLine()) != null){
-
- byte[] bytes = l.getBytes();
- keys.put(bytes, 0, 10);
- int len = bytes.length - 10;
- originalBytes += len;
-
-
- // Compress the value.
- long n1 = System.nanoTime();
- fromCompressBuffer.put(bytes, 10, len);
- fromCompressBuffer.flip();
- int newLen = Snappy.compress(fromCompressBuffer, toCompressBuffer);
- cos.writeRawVarint32(newLen);
- toCompressBuffer.flip();
- values.put(toCompressBuffer);
- fromCompressBuffer.clear();
- toCompressBuffer.clear();
- nanos += (System.nanoTime() - n1);
-
- compressedBytes += newLen;
- //valueLengths.put(newLen);
-
- round++;
-
- if(round >= blockSize){
- // flush
- keys.clear();
- values.clear();
- round = 0;
-
- }
-
-
- }
-
- System.out.println("Uncompressed: " + originalBytes);
- System.out.println("Compressed: " + compressedBytes);
- System.out.println("CompressionTime: " + nanos/1000/1000);
- System.out.println("Total Time: " + (System.nanoTime() - x1)/1000/1000);
-
- }
-
- private static void convertToDeltas(IntBuffer b){
- b.flip();
- int min = Integer.MAX_VALUE;
- for(int i =0; i < b.limit(); i++){
- min = Math.min(b.get(i), min);
- }
-
- for(int i =0; i < b.limit(); i++){
- int cur = b.get(i);
- b.put(i, cur - min);
- }
-
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/ExampleExternalInterface.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/ExampleExternalInterface.java b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/ExampleExternalInterface.java
new file mode 100644
index 0000000..66d2fac
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/ExampleExternalInterface.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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.compile;
+
+public interface ExampleExternalInterface {
+
+ public String getData();
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/ExampleInternalInterface.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/ExampleInternalInterface.java b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/ExampleInternalInterface.java
new file mode 100644
index 0000000..7ddf103
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/ExampleInternalInterface.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * 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.compile;
+
+public interface ExampleInternalInterface {
+ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ExampleInternalInterface.class);
+
+ public String getInternalData();
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/ExampleTemplate.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/ExampleTemplate.java b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/ExampleTemplate.java
new file mode 100644
index 0000000..e8ede05
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/ExampleTemplate.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.compile;
+
+public abstract class ExampleTemplate implements ExampleExternalInterface{
+ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ExampleTemplate.class);
+
+ @Override
+ public final String getData() {
+ return this.getInternalData();
+ }
+
+ abstract String getInternalData();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestClassCompilationTypes.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestClassCompilationTypes.java b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestClassCompilationTypes.java
new file mode 100644
index 0000000..3d5d84e
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestClassCompilationTypes.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * 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.compile;
+
+import org.codehaus.commons.compiler.jdk.ExpressionEvaluator;
+import org.junit.Test;
+
+public class TestClassCompilationTypes {
+ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestClassCompilationTypes.class);
+
+ @Test
+ public void comparePerfs() throws Exception {
+ for(int i =0; i < 50000; i++){
+ int r = 0;
+ long n0 = System.nanoTime();
+ r += janino();
+ long n1 = System.nanoTime();
+ //r += jdk();
+ long n2 = System.nanoTime();
+ long janinoT = (n1 - n0)/1000;
+ long jdkT = (n2 - n1)/1000;
+ System.out.println("Janino: " + janinoT + "micros. JDK: " + jdkT + "micros. Val" + r);
+ }
+
+ }
+
+ private int janino() throws Exception{
+ // Compile the expression once; relatively slow.
+ org.codehaus.janino.ExpressionEvaluator ee = new org.codehaus.janino.ExpressionEvaluator("c > d ? c : d", // expression
+ int.class, // expressionType
+ new String[] { "c", "d" }, // parameterNames
+ new Class[] { int.class, int.class } // parameterTypes
+ );
+
+ // Evaluate it with varying parameter values; very fast.
+ return (Integer) ee.evaluate(new Object[] { // parameterValues
+ new Integer(10), new Integer(11), });
+ }
+
+ private int jdk() throws Exception{
+ // Compile the expression once; relatively slow.
+ ExpressionEvaluator ee = new ExpressionEvaluator("c > d ? c : d", // expression
+ int.class, // expressionType
+ new String[] { "c", "d" }, // parameterNames
+ new Class[] { int.class, int.class } // parameterTypes
+ );
+
+ // Evaluate it with varying parameter values; very fast.
+ return (Integer) ee.evaluate(new Object[] { // parameterValues
+ new Integer(10), new Integer(11), });
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestClassTransformation.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestClassTransformation.java b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestClassTransformation.java
new file mode 100644
index 0000000..47aee7d
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/compile/TestClassTransformation.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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.compile;
+
+import static org.junit.Assert.*;
+
+import org.apache.drill.exec.exception.ClassTransformationException;
+import org.junit.Test;
+
+public class TestClassTransformation {
+ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestClassTransformation.class);
+
+ @Test
+ public void testJaninoCompilation() throws ClassTransformationException {
+ testBasicClassCompilation(true);
+ }
+
+ @Test
+ public void testJDKCompilation() throws ClassTransformationException{
+ testBasicClassCompilation(false);
+ }
+
+ private void testBasicClassCompilation(boolean useJanino) throws ClassTransformationException{
+ final String output = "hello world, the time is now " + System.currentTimeMillis();
+ @SuppressWarnings("unchecked")
+ TemplateClassDefinition<ExampleExternalInterface, Object> def = new TemplateClassDefinition(
+ ExampleExternalInterface.class, "org.apache.drill.exec.compile.ExampleTemplate",
+ ExampleInternalInterface.class, Object.class);
+ ClassTransformer ct = new ClassTransformer();
+ QueryClassLoader loader = new QueryClassLoader(useJanino);
+ ExampleExternalInterface instance = ct.getImplementationClass(loader, def,
+ "public String getInternalData(){return \"" + output + "\";}",
+ new Object());
+ System.out.println(String.format("Generated a new class %s that provides the following getData response '%s'.",
+ instance.getClass().getCanonicalName(), instance.getData()));
+ assertEquals(instance.getData(), output);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/pop/CheckFragmenter.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/pop/CheckFragmenter.java b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/pop/CheckFragmenter.java
new file mode 100644
index 0000000..98bb874
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/pop/CheckFragmenter.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * 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.pop;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.IOException;
+
+import org.apache.drill.common.config.DrillConfig;
+import org.apache.drill.common.physical.PhysicalPlan;
+import org.apache.drill.common.physical.pop.base.PhysicalOperator;
+import org.apache.drill.common.util.FileUtils;
+import org.apache.drill.exec.exception.FragmentSetupException;
+import org.apache.drill.exec.planner.FragmentNode;
+import org.apache.drill.exec.planner.FragmentingPhysicalVisitor;
+import org.apache.drill.exec.planner.FragmentNode.ExchangeFragmentPair;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.Files;
+
+public class CheckFragmenter {
+ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(CheckFragmenter.class);
+
+ static DrillConfig config;
+
+ @BeforeClass
+ public static void setup(){
+ config = DrillConfig.create();
+ }
+
+ @Test
+ public void ensureOneFragment() throws FragmentSetupException, IOException{
+ FragmentNode b = getRootFragment("/physical_test1.json");
+ assertEquals(1, getFragmentCount(b));
+ assertEquals(0, b.getReceivingExchangePairs().size());
+ assertNull(b.getSendingExchange());
+ }
+
+ @Test
+ public void ensureTwoFragments() throws FragmentSetupException, IOException{
+ FragmentNode b = getRootFragment("/physical_simpleexchange.json");
+ assertEquals(2, getFragmentCount(b));
+ assertEquals(1, b.getReceivingExchangePairs().size());
+ assertNull(b.getSendingExchange());
+
+ // get first child.
+ b = b.iterator().next().getNode();
+ assertEquals(0, b.getReceivingExchangePairs().size());
+ assertNotNull(b.getSendingExchange());
+ }
+
+ private int getFragmentCount(FragmentNode b){
+ int i =1;
+ for(ExchangeFragmentPair p : b){
+ i += getFragmentCount(p.getNode());
+ }
+ return i;
+ }
+
+ private FragmentNode getRootFragment(String file) throws FragmentSetupException, IOException{
+ FragmentingPhysicalVisitor f = new FragmentingPhysicalVisitor();
+
+ PhysicalPlan plan = PhysicalPlan.parse(config.getMapper().reader(PhysicalPlan.class), Files.toString(FileUtils.getResourceAsFile(file), Charsets.UTF_8));
+ PhysicalOperator o = plan.getSortedOperators(false).iterator().next();
+ return o.accept(f, null);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/pop/CheckInjectionValue.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/pop/CheckInjectionValue.java b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/pop/CheckInjectionValue.java
new file mode 100644
index 0000000..b8fd278
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/pop/CheckInjectionValue.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.pop;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import org.apache.drill.common.config.DrillConfig;
+import org.apache.drill.common.physical.PhysicalPlan;
+import org.apache.drill.common.physical.pop.Screen;
+import org.apache.drill.common.physical.pop.base.PhysicalOperator;
+import org.apache.drill.common.proto.CoordinationProtos.DrillbitEndpoint;
+import org.apache.drill.common.util.FileUtils;
+import org.apache.drill.exec.planner.PhysicalPlanReader;
+import org.apache.drill.exec.server.DrillbitContext;
+import org.apache.drill.exec.store.StorageEngineRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.google.common.base.Charsets;
+import com.google.common.io.Files;
+
+public class CheckInjectionValue {
+ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(CheckInjectionValue.class);
+
+ static DrillConfig config;
+
+ @BeforeClass
+ public static void setup(){
+ config = DrillConfig.create();
+ }
+
+ @Test
+ public void testInjected() throws Exception{
+ PhysicalPlanReader r = new PhysicalPlanReader(config.getMapper(), DrillbitEndpoint.getDefaultInstance());
+ PhysicalPlan p = r.read(Files.toString(FileUtils.getResourceAsFile("/physical_screen.json"), Charsets.UTF_8));
+
+ List<PhysicalOperator> o = p.getSortedOperators(false);
+
+ PhysicalOperator op = o.iterator().next();
+ assertEquals(Screen.class, op.getClass());
+ Screen s = (Screen) op;
+ assertEquals(DrillbitEndpoint.getDefaultInstance(), s.getEndpoint());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/rpc/user/RunRemoteQuery.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/rpc/user/RunRemoteQuery.java b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/rpc/user/RunRemoteQuery.java
new file mode 100644
index 0000000..d003373
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/rpc/user/RunRemoteQuery.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.rpc.user;
+
+import io.netty.buffer.UnpooledByteBufAllocator;
+import io.netty.channel.nio.NioEventLoopGroup;
+
+import org.apache.drill.exec.proto.UserProtos.QueryHandle;
+import org.apache.drill.exec.proto.UserProtos.RunQuery;
+import org.apache.drill.exec.rpc.DrillRpcFuture;
+import org.junit.Test;
+
+public class RunRemoteQuery {
+ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(RunRemoteQuery.class);
+
+ @Test
+ public void runRemoteQuery() throws Exception{
+ UserClient c = new UserClient(UnpooledByteBufAllocator.DEFAULT, new NioEventLoopGroup(1));
+ c.connectAsClient("localhost", 31010);
+ DrillRpcFuture<QueryHandle> futureHandle = c.submitQuery(RunQuery.getDefaultInstance());
+ QueryHandle h = futureHandle.checkedGet();
+ System.out.println(h);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/server/StartDrillbit.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/server/StartDrillbit.java b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/server/StartDrillbit.java
index 7b353df..ce79661 100644
--- a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/server/StartDrillbit.java
+++ b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/server/StartDrillbit.java
@@ -24,8 +24,8 @@ public class StartDrillbit {
static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(StartDrillbit.class);
- @Test public void startDrillbit() throws DrillbitStartupException, InterruptedException{
+ @Test
+ public void startDrillbit() throws DrillbitStartupException, InterruptedException{
Drillbit.main(new String[0]);
-
}
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/f0be80dc/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/store/MockRecordConfig.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/store/MockRecordConfig.java b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/store/MockRecordConfig.java
new file mode 100644
index 0000000..18c6955
--- /dev/null
+++ b/sandbox/prototype/exec/java-exec/src/test/java/org/apache/drill/exec/store/MockRecordConfig.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.store;
+
+import org.apache.drill.common.expression.types.DataType;
+import org.apache.drill.common.logical.StorageEngineConfigBase;
+
+import com.fasterxml.jackson.annotation.JsonTypeName;
+
+@JsonTypeName("mock-config")
+public class MockRecordConfig extends StorageEngineConfigBase{
+ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(MockRecordConfig.class);
+
+ private int recordCount;
+ private DataType[] types;
+
+ public int getRecordCount() {
+ return recordCount;
+ }
+ public void setRecordCount(int recordCount) {
+ this.recordCount = recordCount;
+ }
+ public DataType[] getTypes() {
+ return types;
+ }
+ public void setTypes(DataType[] types) {
+ this.types = types;
+ }
+
+
+}