http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/sort/Sorter.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/sort/Sorter.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/sort/Sorter.java index dcb159c..eb8dfdf 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/sort/Sorter.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/sort/Sorter.java @@ -20,14 +20,13 @@ package org.apache.drill.exec.physical.impl.sort; import org.apache.drill.exec.compile.TemplateClassDefinition; import org.apache.drill.exec.exception.SchemaChangeException; import org.apache.drill.exec.ops.FragmentContext; -import org.apache.drill.exec.record.RecordBatch; import org.apache.drill.exec.record.VectorContainer; import org.apache.drill.exec.record.selection.SelectionVector4; public interface Sorter { public void setup(FragmentContext context, SelectionVector4 vector4, VectorContainer hyperBatch) throws SchemaChangeException; public void sort(SelectionVector4 vector4, VectorContainer container); - + public static TemplateClassDefinition<Sorter> TEMPLATE_DEFINITION = new TemplateClassDefinition<Sorter>(Sorter.class, SortTemplate.class); }
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/Copier.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/Copier.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/Copier.java index dfc37c6..8ead6ab 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/Copier.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/Copier.java @@ -21,7 +21,6 @@ import org.apache.drill.exec.compile.TemplateClassDefinition; import org.apache.drill.exec.exception.SchemaChangeException; import org.apache.drill.exec.ops.FragmentContext; import org.apache.drill.exec.record.RecordBatch; -import org.apache.drill.exec.vector.allocator.VectorAllocator; public interface Copier { public static TemplateClassDefinition<Copier> TEMPLATE_DEFINITION2 = new TemplateClassDefinition<Copier>(Copier.class, CopierTemplate2.class); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/CopierTemplate4.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/CopierTemplate4.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/CopierTemplate4.java index 7a1c029..c42332d 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/CopierTemplate4.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/CopierTemplate4.java @@ -23,9 +23,7 @@ import org.apache.drill.exec.exception.SchemaChangeException; import org.apache.drill.exec.ops.FragmentContext; import org.apache.drill.exec.record.RecordBatch; import org.apache.drill.exec.record.VectorWrapper; -import org.apache.drill.exec.record.selection.SelectionVector2; import org.apache.drill.exec.record.selection.SelectionVector4; -import org.apache.drill.exec.vector.allocator.VectorAllocator; public abstract class CopierTemplate4 implements Copier{ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(CopierTemplate4.class); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/RemovingRecordBatch.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/RemovingRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/RemovingRecordBatch.java index 4ca2cdf..97f3608 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/RemovingRecordBatch.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/RemovingRecordBatch.java @@ -23,26 +23,19 @@ import java.util.List; import org.apache.drill.exec.exception.ClassTransformationException; import org.apache.drill.exec.exception.SchemaChangeException; import org.apache.drill.exec.expr.CodeGenerator; -import org.apache.drill.exec.expr.TypeHelper; import org.apache.drill.exec.memory.BufferAllocator; import org.apache.drill.exec.memory.OutOfMemoryException; import org.apache.drill.exec.ops.FragmentContext; import org.apache.drill.exec.physical.config.SelectionVectorRemover; import org.apache.drill.exec.record.AbstractSingleRecordBatch; import org.apache.drill.exec.record.BatchSchema.SelectionVectorMode; -import org.apache.drill.exec.record.HyperVectorWrapper; import org.apache.drill.exec.record.RecordBatch; import org.apache.drill.exec.record.TransferPair; import org.apache.drill.exec.record.VectorContainer; import org.apache.drill.exec.record.VectorWrapper; import org.apache.drill.exec.record.WritableBatch; import org.apache.drill.exec.vector.CopyUtil; -import org.apache.drill.exec.vector.FixedWidthVector; import org.apache.drill.exec.vector.ValueVector; -import org.apache.drill.exec.vector.VariableWidthVector; -import org.apache.drill.exec.vector.allocator.FixedVectorAllocator; -import org.apache.drill.exec.vector.allocator.VariableEstimatedVector; -import org.apache.drill.exec.vector.allocator.VectorAllocator; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; @@ -186,6 +179,7 @@ public class RemovingRecordBatch extends AbstractSingleRecordBatch<SelectionVect incoming.getSchema())); } + @Override public void cleanup(){ super.cleanup(); } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/SVRemoverCreator.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/SVRemoverCreator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/SVRemoverCreator.java index a932b44..455a5f9 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/SVRemoverCreator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/svremover/SVRemoverCreator.java @@ -35,6 +35,6 @@ public class SVRemoverCreator implements BatchCreator<SelectionVectorRemover>{ Preconditions.checkArgument(children.size() == 1); return new RemovingRecordBatch(config, context, children.iterator().next()); } - - + + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/trace/TraceBatchCreator.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/trace/TraceBatchCreator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/trace/TraceBatchCreator.java index a24ec70..12afa33 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/trace/TraceBatchCreator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/trace/TraceBatchCreator.java @@ -18,16 +18,14 @@ package org.apache.drill.exec.physical.impl.trace; +import java.util.List; + import org.apache.drill.common.exceptions.ExecutionSetupException; import org.apache.drill.exec.ops.FragmentContext; import org.apache.drill.exec.physical.config.Trace; import org.apache.drill.exec.physical.impl.BatchCreator; import org.apache.drill.exec.record.RecordBatch; -import com.google.common.base.Preconditions; - -import java.util.List; - public class TraceBatchCreator implements BatchCreator<Trace> { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TraceBatchCreator.class); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/trace/TraceRecordBatch.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/trace/TraceRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/trace/TraceRecordBatch.java index b012cec..609cb29 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/trace/TraceRecordBatch.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/trace/TraceRecordBatch.java @@ -27,8 +27,6 @@ import org.apache.drill.exec.cache.VectorAccessibleSerializable; import org.apache.drill.exec.exception.SchemaChangeException; import org.apache.drill.exec.ops.FragmentContext; import org.apache.drill.exec.physical.config.Trace; -import org.apache.drill.exec.proto.ExecProtos.FragmentHandle; -import org.apache.drill.exec.proto.helper.QueryIdHelper; import org.apache.drill.exec.record.AbstractSingleRecordBatch; import org.apache.drill.exec.record.BatchSchema.SelectionVectorMode; import org.apache.drill.exec.record.RecordBatch; http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllBatchCreator.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllBatchCreator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllBatchCreator.java index 395cab4..7f7e110 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllBatchCreator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllBatchCreator.java @@ -35,6 +35,6 @@ public class UnionAllBatchCreator implements BatchCreator<UnionAll>{ Preconditions.checkArgument(children.size() >= 1); return new UnionAllRecordBatch(config, children, context); } - - + + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java index 1f2f843..6b83d04 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java @@ -149,7 +149,7 @@ public class UnionAllRecordBatch extends AbstractRecordBatch<UnionAll> { public WritableBatch getWritableBatch() { return WritableBatch.get(this); } - + @Override public void cleanup() { super.cleanup(); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unorderedreceiver/UnorderedReceiverBatch.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unorderedreceiver/UnorderedReceiverBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unorderedreceiver/UnorderedReceiverBatch.java index 16a68b8..8e7d9c6 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unorderedreceiver/UnorderedReceiverBatch.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unorderedreceiver/UnorderedReceiverBatch.java @@ -17,10 +17,11 @@ */ package org.apache.drill.exec.physical.impl.unorderedreceiver; +import io.netty.buffer.ByteBuf; + import java.io.IOException; import java.util.Iterator; -import io.netty.buffer.ByteBuf; import org.apache.drill.common.expression.SchemaPath; import org.apache.drill.exec.exception.SchemaChangeException; import org.apache.drill.exec.memory.OutOfMemoryException; @@ -46,7 +47,6 @@ import org.apache.drill.exec.record.selection.SelectionVector2; import org.apache.drill.exec.record.selection.SelectionVector4; import org.apache.drill.exec.rpc.RpcException; import org.apache.drill.exec.rpc.RpcOutcomeListener; -import org.apache.drill.exec.rpc.control.ControlTunnel.ReceiverFinished; public class UnorderedReceiverBatch implements RecordBatch { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(UnorderedReceiverBatch.class); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unorderedreceiver/UnorderedReceiverCreator.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unorderedreceiver/UnorderedReceiverCreator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unorderedreceiver/UnorderedReceiverCreator.java index 6be8714..d9864f9 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unorderedreceiver/UnorderedReceiverCreator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unorderedreceiver/UnorderedReceiverCreator.java @@ -36,12 +36,12 @@ public class UnorderedReceiverCreator implements BatchCreator<UnorderedReceiver> assert children == null || children.isEmpty(); IncomingBuffers bufHolder = context.getBuffers(); assert bufHolder != null : "IncomingBuffers must be defined for any place a receiver is declared."; - + RawBatchBuffer[] buffers = bufHolder.getBuffers(receiver.getOppositeMajorFragmentId()); assert buffers.length == 1; RawBatchBuffer buffer = buffers[0]; return new UnorderedReceiverBatch(context, buffer, receiver); } - - + + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/validate/IteratorValidatorBatchIterator.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/validate/IteratorValidatorBatchIterator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/validate/IteratorValidatorBatchIterator.java index 14110e3..0e69bcf 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/validate/IteratorValidatorBatchIterator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/validate/IteratorValidatorBatchIterator.java @@ -21,7 +21,6 @@ import java.util.Iterator; import org.apache.drill.common.expression.SchemaPath; import org.apache.drill.exec.ops.FragmentContext; -import org.apache.drill.exec.record.AbstractRecordBatch; import org.apache.drill.exec.record.BatchSchema; import org.apache.drill.exec.record.RecordBatch; import org.apache.drill.exec.record.TypedFieldId; @@ -153,7 +152,7 @@ public class IteratorValidatorBatchIterator implements RecordBatch { public void cleanup() { incoming.cleanup(); } - + @Override public VectorContainer getOutgoingContainer() { throw new UnsupportedOperationException(String.format(" You should not call getOutgoingContainer() for class %s", this.getClass().getCanonicalName())); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/ExternalSortBatchCreator.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/ExternalSortBatchCreator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/ExternalSortBatchCreator.java index 0078e18..eb5d83b 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/ExternalSortBatchCreator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/ExternalSortBatchCreator.java @@ -17,14 +17,15 @@ */ package org.apache.drill.exec.physical.impl.xsort; -import com.google.common.base.Preconditions; +import java.util.List; + import org.apache.drill.common.exceptions.ExecutionSetupException; import org.apache.drill.exec.ops.FragmentContext; import org.apache.drill.exec.physical.config.ExternalSort; import org.apache.drill.exec.physical.impl.BatchCreator; import org.apache.drill.exec.record.RecordBatch; -import java.util.List; +import com.google.common.base.Preconditions; public class ExternalSortBatchCreator implements BatchCreator<ExternalSort>{ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ExternalSortBatchCreator.class); @@ -34,6 +35,6 @@ public class ExternalSortBatchCreator implements BatchCreator<ExternalSort>{ Preconditions.checkArgument(children.size() == 1); return new ExternalSortBatch(config, context, children.iterator().next()); } - - + + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSortTemplate.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSortTemplate.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSortTemplate.java index 0c98c6f..df79b1a 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSortTemplate.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSortTemplate.java @@ -17,9 +17,10 @@ */ package org.apache.drill.exec.physical.impl.xsort; -import com.google.common.base.Preconditions; -import com.google.common.base.Stopwatch; -import com.google.common.collect.Queues; +import java.util.Queue; + +import javax.inject.Named; + import org.apache.drill.exec.exception.SchemaChangeException; import org.apache.drill.exec.memory.BufferAllocator; import org.apache.drill.exec.ops.FragmentContext; @@ -28,8 +29,9 @@ import org.apache.drill.exec.record.VectorContainer; import org.apache.drill.exec.record.selection.SelectionVector4; import org.apache.hadoop.util.IndexedSortable; -import javax.inject.Named; -import java.util.Queue; +import com.google.common.base.Preconditions; +import com.google.common.base.Stopwatch; +import com.google.common.collect.Queues; public abstract class MSortTemplate implements MSorter, IndexedSortable{ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(MSortTemplate.class); @@ -93,7 +95,7 @@ public abstract class MSortTemplate implements MSorter, IndexedSortable{ public SelectionVector4 getSV4() { return vector4; } - + @Override public void sort(VectorContainer container){ Stopwatch watch = new Stopwatch(); @@ -137,7 +139,7 @@ public abstract class MSortTemplate implements MSorter, IndexedSortable{ vector4.set(sv0, vector4.get(sv1)); vector4.set(sv1, tmp); } - + @Override public int compare(int leftIndex, int rightIndex) { int sv1 = vector4.get(leftIndex); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSorter.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSorter.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSorter.java index 1300830..e80d309 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSorter.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSorter.java @@ -28,7 +28,7 @@ public interface MSorter { public void setup(FragmentContext context, BufferAllocator allocator, SelectionVector4 vector4, VectorContainer hyperBatch) throws SchemaChangeException; public void sort(VectorContainer container); public SelectionVector4 getSV4(); - + public static TemplateClassDefinition<MSorter> TEMPLATE_DEFINITION = new TemplateClassDefinition<MSorter>(MSorter.class, MSortTemplate.class); } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/PriorityQueueCopier.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/PriorityQueueCopier.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/PriorityQueueCopier.java index 0eda0a6..4da3c36 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/PriorityQueueCopier.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/PriorityQueueCopier.java @@ -17,20 +17,15 @@ */ package org.apache.drill.exec.physical.impl.xsort; +import java.util.List; + import org.apache.drill.exec.compile.TemplateClassDefinition; import org.apache.drill.exec.exception.SchemaChangeException; import org.apache.drill.exec.memory.BufferAllocator; import org.apache.drill.exec.ops.FragmentContext; -import org.apache.drill.exec.physical.impl.sort.RecordBatchData; -import org.apache.drill.exec.physical.impl.svremover.Copier; -import org.apache.drill.exec.record.RecordBatch; import org.apache.drill.exec.record.VectorAccessible; -import org.apache.drill.exec.record.VectorContainer; -import org.apache.drill.exec.record.selection.SelectionVector4; import org.apache.drill.exec.vector.allocator.VectorAllocator; -import java.util.List; - public interface PriorityQueueCopier { public void setup(FragmentContext context, BufferAllocator allocator, VectorAccessible hyperBatch, List<BatchGroup> batchGroups, VectorAccessible outgoing, List<VectorAllocator> allocators) throws SchemaChangeException; http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/PriorityQueueCopierTemplate.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/PriorityQueueCopierTemplate.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/PriorityQueueCopierTemplate.java index b1c316c..951397c 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/PriorityQueueCopierTemplate.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/PriorityQueueCopierTemplate.java @@ -31,7 +31,7 @@ import org.apache.drill.exec.vector.allocator.VectorAllocator; public abstract class PriorityQueueCopierTemplate implements PriorityQueueCopier { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PriorityQueueCopierTemplate.class); - + private SelectionVector4 vector4; private List<BatchGroup> batchGroups; private VectorAccessible hyperBatch; @@ -165,7 +165,7 @@ public abstract class PriorityQueueCopierTemplate implements PriorityQueueCopier vector4.set(sv0, vector4.get(sv1)); vector4.set(sv1, tmp); } - + public int compare(int leftIndex, int rightIndex) { int sv1 = vector4.get(leftIndex); int sv2 = vector4.get(rightIndex); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/SingleBatchSorter.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/SingleBatchSorter.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/SingleBatchSorter.java index 761e421..b37229d 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/SingleBatchSorter.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/SingleBatchSorter.java @@ -20,16 +20,13 @@ package org.apache.drill.exec.physical.impl.xsort; import org.apache.drill.exec.compile.TemplateClassDefinition; import org.apache.drill.exec.exception.SchemaChangeException; import org.apache.drill.exec.ops.FragmentContext; -import org.apache.drill.exec.physical.impl.sort.SortTemplate; import org.apache.drill.exec.record.RecordBatch; -import org.apache.drill.exec.record.VectorContainer; import org.apache.drill.exec.record.selection.SelectionVector2; -import org.apache.drill.exec.record.selection.SelectionVector4; public interface SingleBatchSorter { public void setup(FragmentContext context, SelectionVector2 vector2, RecordBatch incoming) throws SchemaChangeException; public void sort(SelectionVector2 vector2); - + public static TemplateClassDefinition<SingleBatchSorter> TEMPLATE_DEFINITION = new TemplateClassDefinition<SingleBatchSorter>(SingleBatchSorter.class, SingleBatchSorterTemplate.class); } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/SingleBatchSorterTemplate.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/SingleBatchSorterTemplate.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/SingleBatchSorterTemplate.java index 3cb7641..75892f9 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/SingleBatchSorterTemplate.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/SingleBatchSorterTemplate.java @@ -17,20 +17,19 @@ */ package org.apache.drill.exec.physical.impl.xsort; -import com.google.common.base.Preconditions; -import com.google.common.base.Stopwatch; +import java.util.concurrent.TimeUnit; + +import javax.inject.Named; + import org.apache.drill.exec.exception.SchemaChangeException; import org.apache.drill.exec.ops.FragmentContext; -import org.apache.drill.exec.physical.impl.sort.Sorter; import org.apache.drill.exec.record.RecordBatch; -import org.apache.drill.exec.record.VectorContainer; import org.apache.drill.exec.record.selection.SelectionVector2; -import org.apache.drill.exec.record.selection.SelectionVector4; import org.apache.hadoop.util.IndexedSortable; import org.apache.hadoop.util.QuickSort; -import javax.inject.Named; -import java.util.concurrent.TimeUnit; +import com.google.common.base.Preconditions; +import com.google.common.base.Stopwatch; public abstract class SingleBatchSorterTemplate implements SingleBatchSorter, IndexedSortable{ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(SingleBatchSorterTemplate.class); @@ -42,7 +41,7 @@ public abstract class SingleBatchSorterTemplate implements SingleBatchSorter, In this.vector2 = vector2; doSetup(context, incoming, null); } - + @Override public void sort(SelectionVector2 vector2){ QuickSort qs = new QuickSort(); @@ -60,7 +59,7 @@ public abstract class SingleBatchSorterTemplate implements SingleBatchSorter, In vector2.setIndex(sv0, vector2.getIndex(sv1)); vector2.setIndex(sv1, tmp); } - + @Override public int compare(int leftIndex, int rightIndex) { char sv1 = vector2.getIndex(leftIndex); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/StarColumnHelper.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/StarColumnHelper.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/StarColumnHelper.java index 591faf9..aa2f786 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/StarColumnHelper.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/StarColumnHelper.java @@ -24,26 +24,26 @@ import java.util.Set; import org.eigenbase.reltype.RelDataType; public class StarColumnHelper { - + public final static String PREFIX_DELIMITER = "\u00a6\u00a6"; public final static String STAR_COLUMN = "*"; - + public final static String PREFIXED_STAR_COLUMN = PREFIX_DELIMITER + STAR_COLUMN; - + public static boolean containsStarColumn(RelDataType type) { List<String> fieldNames = type.getFieldNames(); - + for (String s : fieldNames) { if (s.startsWith(STAR_COLUMN)) return true; } - + return false; } - + public static boolean isPrefixedStarColumn(String fieldName) { - return fieldName.indexOf(PREFIXED_STAR_COLUMN) > 0 ; // the delimiter * starts at none-zero position. + return fieldName.indexOf(PREFIXED_STAR_COLUMN) > 0 ; // the delimiter * starts at none-zero position. } public static boolean isNonPrefixedStarColumn(String fieldName) { @@ -55,26 +55,26 @@ public class StarColumnHelper { } public static String extractStarColumnPrefix(String fieldName) { - + assert (isPrefixedStarColumn(fieldName)); - - return fieldName.substring(0, fieldName.indexOf(PREFIXED_STAR_COLUMN)); + + return fieldName.substring(0, fieldName.indexOf(PREFIXED_STAR_COLUMN)); } - + public static String extractColumnPrefix(String fieldName) { - if (fieldName.indexOf(PREFIX_DELIMITER) >=0) { + if (fieldName.indexOf(PREFIX_DELIMITER) >=0) { return fieldName.substring(0, fieldName.indexOf(PREFIX_DELIMITER)); } else { return ""; } } - - // Given a set of prefixes, check if a regular column is subsumed by any of the prefixed star column in the set. + + // Given a set of prefixes, check if a regular column is subsumed by any of the prefixed star column in the set. public static boolean subsumeRegColumn(Set<String> prefixes, String fieldName) { if (isPrefixedStarColumn(fieldName)) return false; // only applies to regular column. - - return prefixes.contains(extractColumnPrefix(fieldName)); + + return prefixes.contains(extractColumnPrefix(fieldName)); } - + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillAggregateRelBase.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillAggregateRelBase.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillAggregateRelBase.java index 98f6bd5..c733f77 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillAggregateRelBase.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillAggregateRelBase.java @@ -40,15 +40,15 @@ public abstract class DrillAggregateRelBase extends AggregateRelBase implements List<AggregateCall> aggCalls) throws InvalidRelException { super(cluster, traits, child, groupSet, aggCalls); } - + @Override public RelOptCost computeSelfCost(RelOptPlanner planner) { for (AggregateCall aggCall : getAggCallList()) { String name = aggCall.getAggregation().getName(); - // For avg, stddev_pop, stddev_samp, var_pop and var_samp, the ReduceAggregatesRule is supposed + // For avg, stddev_pop, stddev_samp, var_pop and var_samp, the ReduceAggregatesRule is supposed // to convert them to use sum and count. Here, we make the cost of the original functions high - // enough such that the planner does not choose them and instead chooses the rewritten functions. - if (name.equals("AVG") || name.equals("STDDEV_POP") || name.equals("STDDEV_SAMP") + // enough such that the planner does not choose them and instead chooses the rewritten functions. + if (name.equals("AVG") || name.equals("STDDEV_POP") || name.equals("STDDEV_SAMP") || name.equals("VAR_POP") || name.equals("VAR_SAMP")) { return ((DrillCostFactory)planner.getCostFactory()).makeHugeCost(); } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillFilterRelBase.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillFilterRelBase.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillFilterRelBase.java index 865c0fb..f9b1e42 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillFilterRelBase.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillFilterRelBase.java @@ -17,21 +17,13 @@ */ package org.apache.drill.exec.planner.common; -import java.util.List; - import org.apache.drill.common.expression.LogicalExpression; -import org.apache.drill.common.logical.data.Filter; -import org.apache.drill.common.logical.data.LogicalOperator; import org.apache.drill.exec.planner.cost.DrillCostBase; import org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory; -import org.apache.drill.exec.planner.logical.DrillImplementor; import org.apache.drill.exec.planner.logical.DrillOptiq; import org.apache.drill.exec.planner.logical.DrillParseContext; -import org.apache.drill.exec.planner.logical.DrillRel; import org.apache.drill.exec.planner.physical.PrelUtil; -import org.apache.drill.exec.planner.torel.ConversionContext; import org.eigenbase.rel.FilterRelBase; -import org.eigenbase.rel.InvalidRelException; import org.eigenbase.rel.RelNode; import org.eigenbase.rel.metadata.RelMetadataQuery; import org.eigenbase.relopt.Convention; @@ -47,27 +39,27 @@ import org.eigenbase.rex.RexNode; */ public abstract class DrillFilterRelBase extends FilterRelBase implements DrillRelNode { int numConjuncts = 0; - + protected DrillFilterRelBase(Convention convention, RelOptCluster cluster, RelTraitSet traits, RelNode child, RexNode condition) { super(cluster, traits, child, condition); assert getConvention() == convention; - - // save the number of conjuncts that make up the filter condition such + + // save the number of conjuncts that make up the filter condition such // that repeated calls to the costing function can use the saved copy numConjuncts = RelOptUtil.conjunctions(condition).size(); assert numConjuncts >= 1; } - + @Override public RelOptCost computeSelfCost(RelOptPlanner planner) { if(PrelUtil.getSettings(getCluster()).useDefaultCosting()) { - return super.computeSelfCost(planner).multiplyBy(.1); + return super.computeSelfCost(planner).multiplyBy(.1); } RelNode child = this.getChild(); double inputRows = RelMetadataQuery.getRowCount(child); double cpuCost = DrillCostBase.COMPARE_CPU_COST * numConjuncts * inputRows; DrillCostFactory costFactory = (DrillCostFactory)planner.getCostFactory(); - return costFactory.makeCost(inputRows, cpuCost, 0, 0); + return costFactory.makeCost(inputRows, cpuCost, 0, 0); } protected LogicalExpression getFilterExpression(DrillParseContext context){ http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillLimitRelBase.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillLimitRelBase.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillLimitRelBase.java index ab6bc02..11164fb 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillLimitRelBase.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillLimitRelBase.java @@ -17,29 +17,18 @@ */ package org.apache.drill.exec.planner.common; -import java.math.BigDecimal; -import java.util.List; - -import org.apache.drill.common.logical.data.Limit; -import org.apache.drill.common.logical.data.LogicalOperator; import org.apache.drill.exec.planner.cost.DrillCostBase; import org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory; -import org.apache.drill.exec.planner.logical.DrillImplementor; -import org.apache.drill.exec.planner.logical.DrillRel; import org.apache.drill.exec.planner.physical.PrelUtil; -import org.apache.drill.exec.planner.torel.ConversionContext; -import org.eigenbase.rel.InvalidRelException; import org.eigenbase.rel.RelNode; import org.eigenbase.rel.RelWriter; import org.eigenbase.rel.SingleRel; -import org.eigenbase.rel.metadata.RelMetadataQuery; import org.eigenbase.relopt.RelOptCluster; import org.eigenbase.relopt.RelOptCost; import org.eigenbase.relopt.RelOptPlanner; import org.eigenbase.relopt.RelTraitSet; import org.eigenbase.rex.RexLiteral; import org.eigenbase.rex.RexNode; -import org.eigenbase.sql.type.SqlTypeName; /** * Base class for logical and physical Limits implemented in Drill @@ -57,30 +46,31 @@ public abstract class DrillLimitRelBase extends SingleRel implements DrillRelNod public RexNode getOffset() { return this.offset; } - + public RexNode getFetch() { return this.fetch; } - + @Override public RelOptCost computeSelfCost(RelOptPlanner planner) { if(PrelUtil.getSettings(getCluster()).useDefaultCosting()) { - return super.computeSelfCost(planner).multiplyBy(.1); + return super.computeSelfCost(planner).multiplyBy(.1); } - + int off = offset != null ? RexLiteral.intValue(offset) : 0 ; int f = fetch != null ? RexLiteral.intValue(fetch) : 0 ; double numRows = off + f; double cpuCost = DrillCostBase.COMPARE_CPU_COST * numRows; DrillCostFactory costFactory = (DrillCostFactory)planner.getCostFactory(); - return costFactory.makeCost(numRows, cpuCost, 0, 0); + return costFactory.makeCost(numRows, cpuCost, 0, 0); } - + + @Override public RelWriter explainTerms(RelWriter pw) { super.explainTerms(pw); pw.itemIf("offset", offset, offset != null); pw.itemIf("fetch", fetch, fetch != null); return pw; - } + } } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillProjectRelBase.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillProjectRelBase.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillProjectRelBase.java index 7658bb0..f440c29 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillProjectRelBase.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillProjectRelBase.java @@ -74,24 +74,24 @@ public abstract class DrillProjectRelBase extends ProjectRelBase implements Dril // By default, the project will not allow duplicate columns, caused by expanding from * column. // For example, if we have T1_*, T1_Col1, T1_Col2, Col1 and Col2 will have two copies if we expand // * into a list of regular columns. For the intermediate project, the duplicate columns are not - // necessary; it will impact performance. + // necessary; it will impact performance. protected List<NamedExpression> getProjectExpressions(DrillParseContext context) { List<NamedExpression> expressions = Lists.newArrayList(); - + HashSet<String> starColPrefixes = new HashSet<String>(); - + // To remove duplicate columns caused by expanding from * column, we'll keep track of // all the prefix in the project expressions. If a regular column C1 have the same prefix, that - // regular column is not included in the project expression, since at execution time, * will be - // expanded into a list of column, including column C1. + // regular column is not included in the project expression, since at execution time, * will be + // expanded into a list of column, including column C1. for (String fieldName : getRowType().getFieldNames()) { if (StarColumnHelper.isPrefixedStarColumn(fieldName)) { starColPrefixes.add(StarColumnHelper.extractStarColumnPrefix(fieldName)); } } - + for (Pair<RexNode, String> pair : projects()) { - if (! StarColumnHelper.subsumeRegColumn(starColPrefixes, pair.right)) { + if (! StarColumnHelper.subsumeRegColumn(starColPrefixes, pair.right)) { LogicalExpression expr = DrillOptiq.toDrill(context, getChild(), pair.left); expressions.add(new NamedExpression(expr, FieldReference.getWithQuotedRef(pair.right))); } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillRelOptUtil.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillRelOptUtil.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillRelOptUtil.java index 58dc34d..270462b 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillRelOptUtil.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillRelOptUtil.java @@ -25,7 +25,7 @@ import org.eigenbase.sql.type.SqlTypeName; import org.eigenbase.util.Pair; /** - * Utility class that is a subset of the RelOptUtil class and is a placeholder for Drill specific + * Utility class that is a subset of the RelOptUtil class and is a placeholder for Drill specific * static methods that are needed during either logical or physical planning. */ public abstract class DrillRelOptUtil { @@ -34,7 +34,7 @@ public abstract class DrillRelOptUtil { public static boolean areRowTypesEqual( RelDataType rowType1, RelDataType rowType2, - boolean compareNames, + boolean compareNames, boolean allowSubstring) { if (rowType1 == rowType2) { return true; @@ -58,11 +58,11 @@ public abstract class DrillRelOptUtil { continue; } if (!type1.equals(type2)) { - if (allowSubstring - && (type1.getSqlTypeName() == SqlTypeName.CHAR && type2.getSqlTypeName() == SqlTypeName.CHAR) + if (allowSubstring + && (type1.getSqlTypeName() == SqlTypeName.CHAR && type2.getSqlTypeName() == SqlTypeName.CHAR) && (type1.getPrecision() <= type2.getPrecision())) { return true; - } + } return false; } } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillScanRelBase.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillScanRelBase.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillScanRelBase.java index 331069d..0934818 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillScanRelBase.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillScanRelBase.java @@ -25,8 +25,8 @@ import org.eigenbase.relopt.RelOptTable; import org.eigenbase.relopt.RelTraitSet; /** - * Base class for logical scan rel implemented in Drill. - * NOTE: we should eventually make this class independent of TableAccessRelBase and then + * Base class for logical scan rel implemented in Drill. + * NOTE: we should eventually make this class independent of TableAccessRelBase and then * make it the base class for logical and physical scan rels. */ public abstract class DrillScanRelBase extends TableAccessRelBase implements DrillRelNode { @@ -37,5 +37,5 @@ public abstract class DrillScanRelBase extends TableAccessRelBase implements Dri this.drillTable = table.unwrap(DrillTable.class); assert drillTable != null; } - + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillScreenRelBase.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillScreenRelBase.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillScreenRelBase.java index 23b53f3..9b31fb0 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillScreenRelBase.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillScreenRelBase.java @@ -17,7 +17,6 @@ */ package org.apache.drill.exec.planner.common; -import org.apache.drill.exec.planner.cost.DrillCostBase; import org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory; import org.apache.drill.exec.planner.physical.PrelUtil; import org.eigenbase.rel.RelNode; @@ -42,7 +41,7 @@ public abstract class DrillScreenRelBase extends SingleRel implements DrillRelNo @Override public RelOptCost computeSelfCost(RelOptPlanner planner) { if(PrelUtil.getSettings(getCluster()).useDefaultCosting()) { - return super.computeSelfCost(planner).multiplyBy(.1); + return super.computeSelfCost(planner).multiplyBy(.1); } // by default, assume cost is proportional to number of rows double rowCount = RelMetadataQuery.getRowCount(this); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillStoreRelBase.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillStoreRelBase.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillStoreRelBase.java index c6e3ae1..adf7d6b 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillStoreRelBase.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillStoreRelBase.java @@ -36,7 +36,7 @@ public abstract class DrillStoreRelBase extends TableModificationRelBase impleme protected DrillStoreRelBase(RelOptCluster cluster, RelTraitSet traits, RelOptTable table, CatalogReader catalogReader, RelNode child, Operation operation, List<String> updateColumnList, boolean flattened) { super(cluster, traits, table, catalogReader, child, operation, updateColumnList, flattened); - + } } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillUnionRelBase.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillUnionRelBase.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillUnionRelBase.java index fa0465f..127798f 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillUnionRelBase.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/common/DrillUnionRelBase.java @@ -23,18 +23,14 @@ import org.eigenbase.rel.InvalidRelException; import org.eigenbase.rel.RelNode; import org.eigenbase.rel.UnionRelBase; import org.eigenbase.relopt.RelOptCluster; -import org.eigenbase.relopt.RelOptUtil; import org.eigenbase.relopt.RelTraitSet; import org.eigenbase.reltype.RelDataType; -import org.eigenbase.reltype.RelDataTypeField; -import org.eigenbase.sql.type.SqlTypeName; -import org.eigenbase.util.Pair; /** * Base class for logical and physical Union implemented in Drill */ public abstract class DrillUnionRelBase extends UnionRelBase implements DrillRelNode { - + public DrillUnionRelBase(RelOptCluster cluster, RelTraitSet traits, List<RelNode> inputs, boolean all) throws InvalidRelException { super(cluster, traits, inputs, all); @@ -43,7 +39,7 @@ public abstract class DrillUnionRelBase extends UnionRelBase implements DrillRel throw new InvalidRelException("Input row types of the Union are not compatible."); } } - + public boolean isCompatible(boolean compareNames, boolean allowSubstring) { RelDataType unionType = getRowType(); for (RelNode input : getInputs()) { http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillCostBase.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillCostBase.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillCostBase.java index 50e4fb6..c33bb22 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillCostBase.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillCostBase.java @@ -29,12 +29,12 @@ public class DrillCostBase implements DrillRelOptCost { /** * NOTE: the multiplication factors below are not calibrated yet...these - * are chosen based on approximations for now. For reference purposes, - * assume each disk on a server can have a sustained I/O throughput of + * are chosen based on approximations for now. For reference purposes, + * assume each disk on a server can have a sustained I/O throughput of * 100 MBytes/sec. Suppose there is an array of 16 disks per server..theoretically - * one could get 1.6GBytes/sec. Suppose network speed is 1GBit/sec which is + * one could get 1.6GBytes/sec. Suppose network speed is 1GBit/sec which is * 128MBytes/sec, although actual transfer rate over the network may be lower. - * We are only concerned with relative costs, not absolute values. + * We are only concerned with relative costs, not absolute values. * For relative costing, let's assume sending data over the network is * about 16x slower than reading/writing to an array of local disks. */ @@ -47,48 +47,50 @@ public class DrillCostBase implements DrillRelOptCost { public static final int FUNC_CPU_COST = 12 * BASE_CPU_COST; // cpu cost for a function evaluation // cpu cost for projecting an expression; note that projecting an expression - // that is not a simple column or constant may include evaluation, but we - // currently don't model it at that level of detail. - public static final int PROJECT_CPU_COST = 4 * BASE_CPU_COST; + // that is not a simple column or constant may include evaluation, but we + // currently don't model it at that level of detail. + public static final int PROJECT_CPU_COST = 4 * BASE_CPU_COST; - // hash cpu cost per field (for now we don't distinguish between fields of different types) involves - // the cost of the following operations: + // hash cpu cost per field (for now we don't distinguish between fields of different types) involves + // the cost of the following operations: // compute hash value, probe hash table, walk hash chain and compare with each element, // add to the end of hash chain if no match found - public static final int HASH_CPU_COST = 8 * BASE_CPU_COST; - + public static final int HASH_CPU_COST = 8 * BASE_CPU_COST; + public static final int RANGE_PARTITION_CPU_COST = 12 * BASE_CPU_COST; - - // cost of comparing one field with another (ignoring data types for now) - public static final int COMPARE_CPU_COST = 4 * BASE_CPU_COST; + + // cost of comparing one field with another (ignoring data types for now) + public static final int COMPARE_CPU_COST = 4 * BASE_CPU_COST; public static final int AVG_FIELD_WIDTH = 8; - - /** For the costing formulas in computeSelfCost(), assume the following notations: - * Let - * C = Cost per node. + + /** For the costing formulas in computeSelfCost(), assume the following notations: + * Let + * C = Cost per node. * k = number of fields on which to distribute on - * h = CPU cost of computing hash value on 1 field + * h = CPU cost of computing hash value on 1 field * s = CPU cost of Selection-Vector remover per row * w = Network cost of sending 1 row to 1 destination * c = CPU cost of comparing an incoming row with one on a heap of size N */ - + static final DrillCostBase INFINITY = new DrillCostBase( Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, - Double.POSITIVE_INFINITY, + Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY) { + @Override public String toString() { return "{inf}"; } }; static final DrillCostBase HUGE = - new DrillCostBase(Double.MAX_VALUE, - Double.MAX_VALUE, - Double.MAX_VALUE, + new DrillCostBase(Double.MAX_VALUE, + Double.MAX_VALUE, + Double.MAX_VALUE, Double.MAX_VALUE) { + @Override public String toString() { return "{huge}"; } @@ -96,6 +98,7 @@ public class DrillCostBase implements DrillRelOptCost { static final DrillCostBase ZERO = new DrillCostBase(0.0, 0.0, 0.0, 0.0) { + @Override public String toString() { return "{0}"; } @@ -103,6 +106,7 @@ public class DrillCostBase implements DrillRelOptCost { static final DrillCostBase TINY = new DrillCostBase(1.0, 1.0, 0.0, 0.0) { + @Override public String toString() { return "{tiny}"; } @@ -160,7 +164,7 @@ public class DrillCostBase implements DrillRelOptCost { return (this == INFINITY) || (this.cpu == Double.POSITIVE_INFINITY) || (this.io == Double.POSITIVE_INFINITY) - || (this.network == Double.POSITIVE_INFINITY) + || (this.network == Double.POSITIVE_INFINITY) || (this.rowCount == Double.POSITIVE_INFINITY); } @@ -168,8 +172,8 @@ public class DrillCostBase implements DrillRelOptCost { public boolean equals(RelOptCost other) { // here we compare the individual components similar to VolcanoCost, however // an alternative would be to add up the components and compare the total. - // Note that VolcanoPlanner mainly uses isLe() and isLt() for cost comparisons, - // not equals(). + // Note that VolcanoPlanner mainly uses isLe() and isLt() for cost comparisons, + // not equals(). return this == other || (other instanceof DrillCostBase && (this.cpu == ((DrillCostBase) other).cpu) @@ -184,20 +188,20 @@ public class DrillCostBase implements DrillRelOptCost { return false; } DrillCostBase that = (DrillCostBase) other; - return (this == that) + return (this == that) || ((Math.abs(this.cpu - that.cpu) < RelOptUtil.EPSILON) && (Math.abs(this.io - that.io) < RelOptUtil.EPSILON) && (Math.abs(this.network - that.network) < RelOptUtil.EPSILON) && (Math.abs(this.rowCount - that.rowCount) < RelOptUtil.EPSILON)); } - + @Override public boolean isLe(RelOptCost other) { DrillCostBase that = (DrillCostBase) other; - - return this == that + + return this == that || ( (this.cpu + this.io + this.network) <= - (that.cpu + that.io + that.network) + (that.cpu + that.io + that.network) && this.rowCount <= that.rowCount ); } @@ -206,12 +210,12 @@ public class DrillCostBase implements DrillRelOptCost { public boolean isLt(RelOptCost other) { DrillCostBase that = (DrillCostBase) other; - return ( (this.cpu + this.io + this.network) < - (that.cpu + that.io + that.network) + return ( (this.cpu + this.io + this.network) < + (that.cpu + that.io + that.network) && this.rowCount <= that.rowCount ); } - + @Override public RelOptCost plus(RelOptCost other) { DrillCostBase that = (DrillCostBase) other; @@ -290,10 +294,11 @@ public class DrillCostBase implements DrillRelOptCost { return Math.pow(d, 1 / n); } + @Override public String toString() { return "{" + rowCount + " rows, " + cpu + " cpu, " + io + " io, " + network + " network, " + memory + " memory}"; } - + public static class DrillCostFactory implements DrillRelOptCostFactory { public RelOptCost makeCost(double dRows, double dCpu, double dIo, double dNetwork, double dMemory) { @@ -303,11 +308,11 @@ public class DrillCostBase implements DrillRelOptCost { public RelOptCost makeCost(double dRows, double dCpu, double dIo, double dNetwork) { return new DrillCostBase(dRows, dCpu, dIo, dNetwork, 0); } - + public RelOptCost makeCost(double dRows, double dCpu, double dIo) { return new DrillCostBase(dRows, dCpu, dIo, 0, 0); } - + public RelOptCost makeHugeCost() { return DrillCostBase.HUGE; } @@ -323,6 +328,6 @@ public class DrillCostBase implements DrillRelOptCost { public RelOptCost makeZeroCost() { return DrillCostBase.ZERO; } - } - + } + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelOptCost.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelOptCost.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelOptCost.java index 8f20658..88e4e28 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelOptCost.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/cost/DrillRelOptCost.java @@ -21,7 +21,7 @@ package org.apache.drill.exec.planner.cost; import org.eigenbase.relopt.RelOptCost; public interface DrillRelOptCost extends RelOptCost { - + double getNetwork(); } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Fragment.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Fragment.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Fragment.java index 5454e8f..47d6f14 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Fragment.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/Fragment.java @@ -23,30 +23,29 @@ import java.util.List; import org.apache.drill.exec.exception.FragmentSetupException; import org.apache.drill.exec.physical.base.Exchange; import org.apache.drill.exec.physical.base.PhysicalOperator; -import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; import com.google.common.collect.Lists; public class Fragment implements Iterable<Fragment.ExchangeFragmentPair>{ static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(Fragment.class); - + private PhysicalOperator root; private Exchange sendingExchange; private final List<ExchangeFragmentPair> receivingExchangePairs = Lists.newLinkedList(); private Stats stats = new Stats(); - + public void addOperator(PhysicalOperator o){ if(root == null){ root = o; } } - + public void addSendExchange(Exchange e) throws FragmentSetupException{ if(sendingExchange != null) throw new FragmentSetupException("Fragment was trying to add a second SendExchange. "); addOperator(e); sendingExchange = e; } - + public void addReceiveExchange(Exchange e, Fragment fragment){ this.receivingExchangePairs.add(new ExchangeFragmentPair(e, fragment)); } @@ -71,11 +70,11 @@ public class Fragment implements Iterable<Fragment.ExchangeFragmentPair>{ // public <T, V> T accept(FragmentVisitor<T, V> visitor, V extra){ // return visitor.visit(this, extra); // } - + public Stats getStats(){ return stats; } - + public class ExchangeFragmentPair { private Exchange exchange; private Fragment node; @@ -102,9 +101,9 @@ public class Fragment implements Iterable<Fragment.ExchangeFragmentPair>{ public String toString() { return "ExchangeFragmentPair [exchange=" + exchange + "]"; } - - - + + + } @Override @@ -145,6 +144,6 @@ public class Fragment implements Iterable<Fragment.ExchangeFragmentPair>{ + receivingExchangePairs + ", stats=" + stats + "]"; } - - + + } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/MakeFragmentsVisitor.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/MakeFragmentsVisitor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/MakeFragmentsVisitor.java index 58a5646..690fe45 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/MakeFragmentsVisitor.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/MakeFragmentsVisitor.java @@ -29,10 +29,10 @@ import org.apache.drill.exec.physical.base.SubScan; public class MakeFragmentsVisitor extends AbstractPhysicalVisitor<Fragment, Fragment, FragmentSetupException> { static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(MakeFragmentsVisitor.class); - + public MakeFragmentsVisitor(){ } - + @Override public Fragment visitExchange(Exchange exchange, Fragment value) throws FragmentSetupException { // logger.debug("Visiting Exchange {}", exchange); @@ -60,7 +60,7 @@ public class MakeFragmentsVisitor extends AbstractPhysicalVisitor<Fragment, Frag } return value; } - + private Fragment ensureBuilder(Fragment value) throws FragmentSetupException{ if(value != null){ return value; @@ -68,7 +68,7 @@ public class MakeFragmentsVisitor extends AbstractPhysicalVisitor<Fragment, Frag return getNextBuilder(); } } - + public Fragment getNextBuilder(){ return new Fragment(); } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/PlanningSet.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/PlanningSet.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/PlanningSet.java index da4380f..8cc6c85 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/PlanningSet.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/fragment/PlanningSet.java @@ -20,7 +20,6 @@ package org.apache.drill.exec.planner.fragment; import java.util.Iterator; import java.util.Map; -import org.apache.drill.exec.ops.QueryContext; import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint; import com.google.common.collect.Maps; http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/CreateTableEntry.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/CreateTableEntry.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/CreateTableEntry.java index 7f6acd9..673e8c6 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/CreateTableEntry.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/CreateTableEntry.java @@ -18,13 +18,14 @@ package org.apache.drill.exec.planner.logical; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonSubTypes.Type; -import com.fasterxml.jackson.annotation.JsonTypeInfo; +import java.io.IOException; + import org.apache.drill.exec.physical.base.PhysicalOperator; import org.apache.drill.exec.physical.base.Writer; -import java.io.IOException; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonSubTypes.Type; +import com.fasterxml.jackson.annotation.JsonTypeInfo; /** * Interface that provides the info needed to create a new table. A storage engine http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillAggregateRel.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillAggregateRel.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillAggregateRel.java index fe5130c..e31aaa7 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillAggregateRel.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillAggregateRel.java @@ -51,6 +51,7 @@ public class DrillAggregateRel extends DrillAggregateRelBase implements DrillRel super(cluster, traits, child, groupSet, aggCalls); } + @Override public AggregateRelBase copy(RelTraitSet traitSet, RelNode input, BitSet groupSet, List<AggregateCall> aggCalls) { try { return new DrillAggregateRel(getCluster(), traitSet, input, getGroupSet(), aggCalls); @@ -71,31 +72,31 @@ public class DrillAggregateRel extends DrillAggregateRelBase implements DrillRel FieldReference fr = new FieldReference(childFields.get(group), ExpressionPosition.UNKNOWN); builder.addKey(fr, fr); } - + for (Ord<AggregateCall> aggCall : Ord.zip(aggCalls)) { FieldReference ref = new FieldReference(fields.get(groupSet.cardinality() + aggCall.i)); LogicalExpression expr = toDrill(aggCall.e, childFields, implementor); builder.addExpr(ref, expr); } - + return builder.build(); } - - - + + + private LogicalExpression toDrill(AggregateCall call, List<String> fn, DrillImplementor implementor) { List<LogicalExpression> args = Lists.newArrayList(); for(Integer i : call.getArgList()){ args.add(new FieldReference(fn.get(i))); } - + // for count(1). if(args.isEmpty()) args.add(new ValueExpressions.LongExpression(1l)); LogicalExpression expr = FunctionCallFactory.createExpression(call.getAggregation().getName().toLowerCase(), ExpressionPosition.UNKNOWN, args); return expr; } - + public static DrillAggregateRel convert(GroupingAggregate groupBy, ConversionContext value) throws InvalidRelException { throw new UnsupportedOperationException(); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillFilterRel.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillFilterRel.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillFilterRel.java index fee62c9..63bef44 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillFilterRel.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillFilterRel.java @@ -47,7 +47,7 @@ public class DrillFilterRel extends DrillFilterRelBase implements DrillRel { f.setInput(input); return f; } - + public static DrillFilterRel convert(Filter filter, ConversionContext context) throws InvalidRelException{ RelNode input = context.toRel(filter.getInput()); return new DrillFilterRel(context.getCluster(), context.getLogicalTraits(), input, context.toRex(filter.getExpr())); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillFilterRule.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillFilterRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillFilterRule.java index 8f18838..cb47adb 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillFilterRule.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillFilterRule.java @@ -22,7 +22,6 @@ import org.eigenbase.rel.RelNode; import org.eigenbase.relopt.Convention; import org.eigenbase.relopt.RelOptRule; import org.eigenbase.relopt.RelOptRuleCall; -import org.eigenbase.relopt.RelTraitSet; /** * Rule that converts a {@link org.eigenbase.rel.FilterRel} to a Drill "filter" operation. http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillImplementor.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillImplementor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillImplementor.java index 6a7c8e4..7fff6e9 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillImplementor.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillImplementor.java @@ -33,21 +33,21 @@ import com.google.common.collect.Sets; * Context for converting a tree of {@link DrillRel} nodes into a Drill logical plan. */ public class DrillImplementor { - + static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillImplementor.class); - + private Set<DrillTable> tables = Sets.newHashSet(); private Set<String> storageEngineNames = Sets.newHashSet(); private LogicalPlanBuilder planBuilder = new LogicalPlanBuilder(); private LogicalPlan plan; private final DrillParseContext context; - - + + public DrillImplementor(DrillParseContext context, ResultMode mode) { planBuilder.planProperties(PlanType.APACHE_DRILL_LOGICAL, 1, DrillImplementor.class.getName(), "", mode); this.context = context; } - + public DrillParseContext getContext(){ return context; } @@ -62,7 +62,7 @@ public class DrillImplementor { LogicalOperator rootLOP = root.implement(this); rootLOP.accept(new AddOpsVisitor(), null); } - + public LogicalPlan getPlan(){ if(plan == null){ plan = planBuilder.build(); @@ -74,7 +74,7 @@ public class DrillImplementor { public LogicalOperator visitChild(DrillRel parent, int ordinal, RelNode child) { return ((DrillRel) child).implement(this); } - + private class AddOpsVisitor extends AbstractLogicalVisitor<Void, Void, RuntimeException> { @Override public Void visitOp(LogicalOperator op, Void value) throws RuntimeException { http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillJoinRel.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillJoinRel.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillJoinRel.java index 151318e..8d3e1bf 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillJoinRel.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillJoinRel.java @@ -18,8 +18,6 @@ package org.apache.drill.exec.planner.logical; import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; import java.util.List; import org.apache.drill.common.expression.FieldReference; @@ -30,13 +28,11 @@ import org.apache.drill.common.logical.data.Project; import org.apache.drill.exec.planner.common.DrillJoinRelBase; import org.apache.drill.exec.planner.torel.ConversionContext; import org.eigenbase.rel.InvalidRelException; -import org.eigenbase.rel.JoinRelBase; import org.eigenbase.rel.JoinRelType; import org.eigenbase.rel.RelNode; import org.eigenbase.relopt.RelOptCluster; import org.eigenbase.relopt.RelOptUtil; import org.eigenbase.relopt.RelTraitSet; -import org.eigenbase.reltype.RelDataType; import org.eigenbase.reltype.RelDataTypeField; import org.eigenbase.rex.RexNode; import org.eigenbase.rex.RexUtil; http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillLimitRel.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillLimitRel.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillLimitRel.java index 9f08117..75a38d8 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillLimitRel.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillLimitRel.java @@ -23,8 +23,6 @@ import java.util.List; import org.apache.drill.common.logical.data.Limit; import org.apache.drill.common.logical.data.LogicalOperator; import org.apache.drill.exec.planner.common.DrillLimitRelBase; -import org.apache.drill.exec.planner.logical.DrillImplementor; -import org.apache.drill.exec.planner.logical.DrillRel; import org.apache.drill.exec.planner.torel.ConversionContext; import org.eigenbase.rel.InvalidRelException; import org.eigenbase.rel.RelNode; @@ -48,7 +46,7 @@ public class DrillLimitRel extends DrillLimitRelBase implements DrillRel { @Override public LogicalOperator implement(DrillImplementor implementor) { LogicalOperator inputOp = implementor.visitChild(this, 0, getChild()); - + // First offset to include into results (inclusive). Null implies it is starting from offset 0 int first = offset != null ? Math.max(0, RexLiteral.intValue(offset)) : 0; @@ -59,7 +57,7 @@ public class DrillLimitRel extends DrillLimitRelBase implements DrillRel { limit.setInput(inputOp); return limit; } - + public static DrillLimitRel convert(Limit limit, ConversionContext context) throws InvalidRelException{ RelNode input = context.toRel(limit.getInput()); RexNode first = context.getRexBuilder().makeExactLiteral(BigDecimal.valueOf(limit.getFirst()), context.getTypeFactory().createSqlType(SqlTypeName.INTEGER)); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillMergeProjectRule.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillMergeProjectRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillMergeProjectRule.java index 7abc28b..b97d83e 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillMergeProjectRule.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillMergeProjectRule.java @@ -18,17 +18,14 @@ package org.apache.drill.exec.planner.logical; +import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry; import org.eigenbase.rel.ProjectRelBase; import org.eigenbase.rel.RelFactories.ProjectFactory; - import org.eigenbase.rel.rules.MergeProjectRule; import org.eigenbase.relopt.RelOptRuleCall; - import org.eigenbase.rex.RexCall; import org.eigenbase.rex.RexNode; -import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry; - public class DrillMergeProjectRule extends MergeProjectRule { private FunctionImplementationRegistry functionRegistry; http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java index 891b889..0627dcd 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java @@ -32,8 +32,8 @@ import org.apache.drill.common.expression.SchemaPath; import org.apache.drill.common.expression.TypedNullConstant; import org.apache.drill.common.expression.ValueExpressions; import org.apache.drill.common.expression.ValueExpressions.QuotedString; -import org.apache.drill.common.types.TypeProtos.MajorType; import org.apache.drill.common.types.TypeProtos; +import org.apache.drill.common.types.TypeProtos.MajorType; import org.apache.drill.common.types.TypeProtos.MinorType; import org.apache.drill.common.types.Types; import org.apache.drill.exec.planner.StarColumnHelper; http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillProjectRel.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillProjectRel.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillProjectRel.java index c3eb3fb..14ea894 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillProjectRel.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillProjectRel.java @@ -48,6 +48,7 @@ public class DrillProjectRel extends DrillProjectRelBase implements DrillRel { } + @Override public ProjectRelBase copy(RelTraitSet traitSet, RelNode input, List<RexNode> exps, RelDataType rowType) { return new DrillProjectRel(getCluster(), traitSet, input, exps, rowType); } http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java index 8305dd8..93fff35 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java @@ -39,7 +39,6 @@ import org.eigenbase.reltype.RelDataType; import org.eigenbase.reltype.RelDataTypeFactory; import org.eigenbase.reltype.RelDataTypeField; import org.eigenbase.rex.RexBuilder; -import org.eigenbase.rex.RexCall; import org.eigenbase.rex.RexLiteral; import org.eigenbase.rex.RexNode; import org.eigenbase.sql.SqlAggFunction; @@ -86,6 +85,7 @@ public class DrillReduceAggregatesRule extends RelOptRule { return containsAvgStddevVarCall(oldAggRel.getAggCallList()); } + @Override public void onMatch(RelOptRuleCall ruleCall) { AggregateRelBase oldAggRel = (AggregateRelBase) ruleCall.rels[0]; reduceAggs(ruleCall, oldAggRel); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillRuleSets.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillRuleSets.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillRuleSets.java index 65fa2d7..dbb85b2 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillRuleSets.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillRuleSets.java @@ -44,7 +44,6 @@ import org.eigenbase.rel.RelFactories; import org.eigenbase.rel.rules.PushFilterPastJoinRule; import org.eigenbase.rel.rules.PushFilterPastProjectRule; import org.eigenbase.rel.rules.PushJoinThroughJoinRule; -import org.eigenbase.rel.rules.PushProjectPastFilterRule; import org.eigenbase.rel.rules.PushProjectPastJoinRule; import org.eigenbase.rel.rules.RemoveDistinctAggregateRule; import org.eigenbase.rel.rules.RemoveDistinctRule; @@ -113,7 +112,7 @@ public class DrillRuleSets { return DRILL_BASIC_RULES; } - /* + /* public static final RuleSet DRILL_PHYSICAL_MEM = new DrillRuleSet(ImmutableSet.of( // // DrillScanRule.INSTANCE, // DrillFilterRule.INSTANCE, @@ -169,9 +168,9 @@ public class DrillRuleSets { )); public static final RuleSet getPhysicalRules(QueryContext qcontext) { - List<RelOptRule> ruleList = new ArrayList<RelOptRule>(); + List<RelOptRule> ruleList = new ArrayList<RelOptRule>(); + - ruleList.add(ConvertCountToDirectScan.AGG_ON_PROJ_ON_SCAN); ruleList.add(ConvertCountToDirectScan.AGG_ON_SCAN); ruleList.add(SortConvertPrule.INSTANCE); @@ -186,26 +185,26 @@ public class DrillRuleSets { ruleList.add(PushLimitToTopN.INSTANCE); ruleList.add(UnionAllPrule.INSTANCE); // ruleList.add(UnionDistinctPrule.INSTANCE); - + PlannerSettings ps = qcontext.getPlannerSettings(); - + if (ps.isHashAggEnabled()) { - ruleList.add(HashAggPrule.INSTANCE); + ruleList.add(HashAggPrule.INSTANCE); } - + if (ps.isStreamAggEnabled()) { - ruleList.add(StreamAggPrule.INSTANCE); + ruleList.add(StreamAggPrule.INSTANCE); } - + if (ps.isHashJoinEnabled()) { - ruleList.add(HashJoinPrule.INSTANCE); + ruleList.add(HashJoinPrule.INSTANCE); } - + if (ps.isMergeJoinEnabled()) { - ruleList.add(MergeJoinPrule.INSTANCE); + ruleList.add(MergeJoinPrule.INSTANCE); } - - return new DrillRuleSet(ImmutableSet.copyOf(ruleList)); + + return new DrillRuleSet(ImmutableSet.copyOf(ruleList)); } public static RuleSet create(ImmutableSet<RelOptRule> rules) { http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScanRel.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScanRel.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScanRel.java index d6bbcd3..5a0cc08 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScanRel.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScanRel.java @@ -18,21 +18,15 @@ package org.apache.drill.exec.planner.logical; import java.io.IOException; -import java.util.Collections; import java.util.List; -import com.google.common.base.Preconditions; -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; import org.apache.drill.common.JSONOptions; import org.apache.drill.common.exceptions.DrillRuntimeException; -import org.apache.drill.common.exceptions.ExecutionSetupException; import org.apache.drill.common.expression.SchemaPath; import org.apache.drill.common.logical.data.LogicalOperator; import org.apache.drill.common.logical.data.Scan; import org.apache.drill.exec.physical.base.AbstractGroupScan; import org.apache.drill.exec.physical.base.GroupScan; -import org.apache.drill.exec.physical.base.PhysicalOperator; import org.apache.drill.exec.physical.base.ScanStats; import org.apache.drill.exec.planner.common.DrillScanRelBase; import org.apache.drill.exec.planner.cost.DrillCostBase.DrillCostFactory; @@ -46,6 +40,10 @@ import org.eigenbase.relopt.RelOptTable; import org.eigenbase.relopt.RelTraitSet; import org.eigenbase.reltype.RelDataType; +import com.google.common.base.Preconditions; +import com.google.common.base.Predicate; +import com.google.common.collect.Iterables; + /** * GroupScan of a Drill table. */ http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScanRule.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScanRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScanRule.java index 4896ac9..d71019a 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScanRule.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScanRule.java @@ -19,8 +19,6 @@ package org.apache.drill.exec.planner.logical; import net.hydromatic.optiq.rules.java.JavaRules.EnumerableTableAccessRel; -import org.apache.drill.exec.planner.common.DrillScanRelBase; -import org.eigenbase.relopt.Convention; import org.eigenbase.relopt.RelOptRule; import org.eigenbase.relopt.RelOptRuleCall; import org.eigenbase.relopt.RelTraitSet; http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScreenRel.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScreenRel.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScreenRel.java index a63cae0..28f4205 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScreenRel.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillScreenRel.java @@ -39,7 +39,7 @@ public class DrillScreenRel extends DrillScreenRelBase implements DrillRel { public RelNode copy(RelTraitSet traitSet, List<RelNode> inputs) { return new DrillScreenRel(getCluster(), traitSet, sole(inputs)); } - + @Override public LogicalOperator implement(DrillImplementor implementor) { LogicalOperator childOp = implementor.visitChild(this, 0, getChild()); http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/39990292/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillSortRel.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillSortRel.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillSortRel.java index 04af9d5..830f5f2 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillSortRel.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillSortRel.java @@ -62,19 +62,19 @@ public class DrillSortRel extends SortRel implements DrillRel { public LogicalOperator implement(DrillImplementor implementor) { final Order.Builder builder = Order.builder(); builder.setInput(implementor.visitChild(this, 0, getChild())); - + final List<String> childFields = getChild().getRowType().getFieldNames(); for(RelFieldCollation fieldCollation : this.collation.getFieldCollations()){ - builder.addOrdering(fieldCollation.getDirection(), + builder.addOrdering(fieldCollation.getDirection(), new FieldReference(childFields.get(fieldCollation.getFieldIndex())), fieldCollation.nullDirection); } return builder.build(); } - + public static RelNode convert(Order order, ConversionContext context) throws InvalidRelException{ - + // if there are compound expressions in the order by, we need to convert into projects on either side. RelNode input = context.toRel(order.getInput()); List<String> fields = input.getRowType().getFieldNames(); @@ -86,9 +86,9 @@ public class DrillSortRel extends SortRel implements DrillRel { fieldMap.put(field, i); i++; } - + List<RelFieldCollation> collations = Lists.newArrayList(); - + for(Ordering o : order.getOrderings()){ String fieldName = ExprHelper.getFieldName(o.getExpr()); int fieldId = fieldMap.get(fieldName); @@ -96,5 +96,5 @@ public class DrillSortRel extends SortRel implements DrillRel { } return new DrillSortRel(context.getCluster(), context.getLogicalTraits(), input, RelCollationImpl.of(collations)); } - + }
