Github user paul-rogers commented on a diff in the pull request: https://github.com/apache/drill/pull/767#discussion_r104275056 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/managed/ExternalSortBatch.java --- @@ -1333,8 +1339,43 @@ private void spillFromMemory() { mergeAndSpill(bufferedBatches, spillCount); } + private void mergeRuns(int targetCount) { + + // Determine the number of runs to merge. The count should be the + // target count. However, to prevent possible memory overrun, we + // double-check with actual spill batch size and only spill as much + // as fits in the merge memory pool. + + int mergeCount = 0; + long mergeSize = 0; + for (SpilledRun batch : spilledRuns) { --- End diff -- Fixed
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---