Github user paul-rogers commented on a diff in the pull request: https://github.com/apache/drill/pull/1058#discussion_r154477971 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/managed/BatchGroup.java --- @@ -280,17 +278,14 @@ private void closeInputStream() throws IOException { logger.trace("Summary: Read {} bytes from {}", readLength, path); } - public long closeOutputStream() throws IOException { - if (outputStream == null) { - return 0; + public void closeWriter() throws IOException { + if (writer == null) { + return; } - long writeSize = spillSet.getPosition(outputStream); - spillSet.tallyWriteBytes(writeSize); - outputStream.close(); - outputStream = null; + long writeSize = writer.close(); + long timeNs = writer.timeNs(); --- End diff -- See comment above. Updating spill set here decouples the writer from the spill set. The `BatchGroup` already knows about the spill set.
---