DRILL-6254: IllegalArgumentException: the requested size must be non-negative
close apache/drill#1179 Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/67710bba Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/67710bba Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/67710bba Branch: refs/heads/master Commit: 67710bba7cdbc05428df7390bad8639b099769fc Parents: 7088bfe Author: Padma Penumarthy <[email protected]> Authored: Wed Mar 21 13:39:43 2018 -0700 Committer: Aman Sinha <[email protected]> Committed: Thu Mar 29 23:21:50 2018 -0700 ---------------------------------------------------------------------- .../drill/exec/physical/impl/flatten/FlattenRecordBatch.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/67710bba/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java index 9dd1770..7509809 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/flatten/FlattenRecordBatch.java @@ -237,7 +237,10 @@ public class FlattenRecordBatch extends AbstractSingleRecordBatch<FlattenPOP> { private void handleRemainder() { int remainingRecordCount = flattener.getFlattenField().getAccessor().getInnerValueCount() - remainderIndex; - if (!doAlloc(remainingRecordCount)) { + + // remainingRecordCount can be much higher than number of rows we will have in outgoing batch. + // Do memory allocation only for number of rows we are going to have in the batch. + if (!doAlloc(Math.min(remainingRecordCount, flattenMemoryManager.getOutputRowCount()))) { outOfMemory = true; return; }
