Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Drill >> mail # dev >> [04/10] git commit: DRILL-313: Fix for Limit operator only transferring buffers on new schema


Copy link to this message
-
[04/10] git commit: DRILL-313: Fix for Limit operator only transferring buffers on new schema
DRILL-313: Fix for Limit operator only transferring buffers on new schema
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/6c0389f3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/6c0389f3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/6c0389f3

Branch: refs/heads/master
Commit: 6c0389f394a789beb74103309f5bed13ddeccf95
Parents: b91f2e8
Author: Steven Phillips <[EMAIL PROTECTED]>
Authored: Sun Dec 1 19:48:57 2013 -0800
Committer: Jacques Nadeau <[EMAIL PROTECTED]>
Committed: Sun Dec 1 19:48:57 2013 -0800

----------------------------------------------------------------------
 .../physical/impl/limit/LimitRecordBatch.java   |  8 ++--
 .../drill/exec/fn/impl/GeneratorFunctions.java  | 22 ++++++++-
 .../physical/impl/limit/TestSimpleLimit.java    | 35 ++++++++++++++
 .../src/test/resources/limit/test4.json         | 49 ++++++++++++++++++++
 4 files changed, 109 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/6c0389f3/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/limit/LimitRecordBatch.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/limit/LimitRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/limit/LimitRecordBatch.java
index 8390997..712af9f 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/limit/LimitRecordBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/limit/LimitRecordBatch.java
@@ -36,6 +36,7 @@ public class LimitRecordBatch extends AbstractSingleRecordBatch<Limit> {
   private int recordsLeft;
   private boolean noEndLimit;
   private boolean skipBatch;
+  List<TransferPair> transfers = Lists.newArrayList();
 
   public LimitRecordBatch(Limit popConfig, FragmentContext context, RecordBatch incoming) {
     super(popConfig, context, incoming);
@@ -52,7 +53,6 @@ public class LimitRecordBatch extends AbstractSingleRecordBatch<Limit> {
   protected void setupNewSchema() throws SchemaChangeException {
     container.clear();
 
-    List<TransferPair> transfers = Lists.newArrayList();
 
     for(VectorWrapper<?> v : incoming){
       TransferPair pair = v.getValueVector().getTransferPair();
@@ -74,9 +74,6 @@ public class LimitRecordBatch extends AbstractSingleRecordBatch<Limit> {
 
     container.buildSchema(BatchSchema.SelectionVectorMode.TWO_BYTE);
 
-    for(TransferPair tp : transfers) {
-      tp.transfer();
-    }
   }
 
   @Override
@@ -96,6 +93,9 @@ public class LimitRecordBatch extends AbstractSingleRecordBatch<Limit> {
 
   @Override
   protected void doWork() {
+    for(TransferPair tp : transfers) {
+      tp.transfer();
+    }
     skipBatch = false;
     int recordCount = incoming.getRecordCount();
     if(recordCount <= recordsToSkip) {

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/6c0389f3/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/GeneratorFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/GeneratorFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/GeneratorFunctions.java
index d12633e..b79ccd0 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/GeneratorFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/GeneratorFunctions.java
@@ -26,6 +26,7 @@ import org.apache.drill.exec.expr.annotations.FunctionTemplate;
 import org.apache.drill.exec.expr.annotations.FunctionTemplate.FunctionScope;
 import org.apache.drill.exec.expr.annotations.Output;
 import org.apache.drill.exec.expr.annotations.Param;
+import org.apache.drill.exec.expr.annotations.Workspace;
 import org.apache.drill.exec.expr.holders.*;
 import org.apache.drill.exec.record.RecordBatch;
 
@@ -38,17 +39,36 @@ public class GeneratorFunctions {
           OutputTypeDeterminer.FIXED_BIGINT, "randomBigInt");
   public static final FunctionDefinition RANDOM_FLOAT8 = FunctionDefinition.simple("randomFloat8", new ArgumentValidators.NumericTypeAllowed(1,2, true),
           OutputTypeDeterminer.FIXED_FLOAT8, "randomFloat8");
+  public static final FunctionDefinition INCREASING_BIGINT = FunctionDefinition.simple("increasingBigInt", new ArgumentValidators.NumericTypeAllowed(1, true),
+          OutputTypeDeterminer.FIXED_BIGINT, "increasingBigInt");
 
   public static class Provider implements CallProvider {
 
     @Override
     public FunctionDefinition[] getFunctionDefintions() {
       return new FunctionDefinition[] { RANDOM_BIG_INT,
-                                        RANDOM_FLOAT8 };
+                                        RANDOM_FLOAT8,
+                                        INCREASING_BIGINT };
     }
 
   }
 
+  @FunctionTemplate(name = "increasingBigInt", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
+  public static class IncreasingBigInt implements DrillSimpleFunc {
+
+    @Param BigIntHolder start;
+    @Workspace long current;
+    @Output BigIntHolder out;
+
+    public void setup(RecordBatch incoming) {
+      current = 0;
+    }
+
+    public void eval() {
+      out.value = start.value + current++;
+    }
+  }
+
   @FunctionTemplate(name = "randomBigInt", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
   public static class RandomBigIntGauss implements DrillSimpleFunc {
 

http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/6c0389f3/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/limit/TestSimpleLimit.java
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/limit/TestSimpleLimit.java b/exec/java-exec/src/test/java