DRILL-5344: External sort priority queue copier fails with an empty batch Unit tests showed that the âpriority queue copierâ does not handle an empty batch. This has not been an issue because code elsewhere in the sort specifically works around this issue. This fix resolves the issue at the source to avoid the need for future work-arounds.
closes #778 Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/f1baec3c Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/f1baec3c Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/f1baec3c Branch: refs/heads/master Commit: f1baec3c6a876c274229d0b323a348a051f2f5b7 Parents: 35bccd0 Author: Paul Rogers <prog...@maprtech.com> Authored: Fri Mar 10 15:56:18 2017 -0800 Committer: Arina Ielchiieva <arina.yelchiy...@gmail.com> Committed: Fri May 5 15:45:56 2017 +0300 ---------------------------------------------------------------------- .../impl/xsort/managed/PriorityQueueCopierTemplate.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/f1baec3c/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/managed/PriorityQueueCopierTemplate.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/managed/PriorityQueueCopierTemplate.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/managed/PriorityQueueCopierTemplate.java index 81856fa..76b178c 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/managed/PriorityQueueCopierTemplate.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/managed/PriorityQueueCopierTemplate.java @@ -57,9 +57,12 @@ public abstract class PriorityQueueCopierTemplate implements PriorityQueueCopier queueSize = 0; for (int i = 0; i < size; i++) { - vector4.set(i, i, batchGroups.get(i).getNextIndex()); - siftUp(); - queueSize++; + int index = batchGroups.get(i).getNextIndex(); + vector4.set(i, i, index); + if (index > -1) { + siftUp(); + queueSize++; + } } }