Repository: incubator-drill
Updated Branches:
  refs/heads/master 3db1d5a32 -> cca3cec18


DRILL-918: During Sort, handle the case where the child SelectionVector 
produces 0 records.


Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/5746032b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/5746032b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/5746032b

Branch: refs/heads/master
Commit: 5746032b78438e4c772ed2c6da6c7f7b2e70c868
Parents: 3db1d5a
Author: Aman Sinha <[email protected]>
Authored: Thu Jun 5 18:58:43 2014 -0700
Committer: Jacques Nadeau <[email protected]>
Committed: Thu Jun 5 19:54:42 2014 -0700

----------------------------------------------------------------------
 .../exec/physical/impl/xsort/ExternalSortBatch.java      | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/5746032b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/ExternalSortBatch.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/ExternalSortBatch.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/ExternalSortBatch.java
index d6cbbc4..7a2b251 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/ExternalSortBatch.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/ExternalSortBatch.java
@@ -185,6 +185,8 @@ public class ExternalSortBatch extends 
AbstractRecordBatch<ExternalSort> {
       }
     }
 
+    long totalcount = 0;
+    
     try{
       outer: while (true) {
         Stopwatch watch = new Stopwatch();
@@ -218,12 +220,15 @@ public class ExternalSortBatch extends 
AbstractRecordBatch<ExternalSort> {
             }
           }
           int count = sv2.getCount();
-          assert sv2.getCount() > 0;
+          totalcount += count;
+          if (count == 0) {
+            break outer;
+          }
           sorter.setup(context, sv2, incoming);
           Stopwatch w = new Stopwatch();
           w.start();
           sorter.sort(sv2);
-//          logger.debug("Took {} us to sort {} records", 
w.elapsed(TimeUnit.MICROSECONDS), sv2.getCount());
+//          logger.debug("Took {} us to sort {} records", 
w.elapsed(TimeUnit.MICROSECONDS), count);
           RecordBatchData rbd = new RecordBatchData(incoming);
           if (incoming.getSchema().getSelectionVectorMode() == 
SelectionVectorMode.NONE) {
             rbd.setSv2(sv2);
@@ -246,7 +251,7 @@ public class ExternalSortBatch extends 
AbstractRecordBatch<ExternalSort> {
         }
       }
 
-      if (schema == null){
+      if (schema == null || totalcount == 0){
         // builder may be null at this point if the first incoming batch is 
empty
         return IterOutcome.NONE;
       }

Reply via email to