Github user paul-rogers commented on a diff in the pull request: https://github.com/apache/drill/pull/906#discussion_r134300698 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/ScanBatch.java --- @@ -152,97 +157,75 @@ public void kill(boolean sendUpstream) { } } - private void releaseAssets() { - container.zeroVectors(); - } - - private void clearFieldVectorMap() { - for (final ValueVector v : mutator.fieldVectorMap().values()) { - v.clear(); - } - } - @Override public IterOutcome next() { if (done) { return IterOutcome.NONE; } oContext.getStats().startProcessing(); try { - try { - injector.injectChecked(context.getExecutionControls(), "next-allocate", OutOfMemoryException.class); - - currentReader.allocate(mutator.fieldVectorMap()); - } catch (OutOfMemoryException e) { - clearFieldVectorMap(); - throw UserException.memoryError(e).build(logger); - } - while ((recordCount = currentReader.next()) == 0) { + while (true) { try { - if (!readers.hasNext()) { - // We're on the last reader, and it has no (more) rows. - currentReader.close(); - releaseAssets(); - done = true; // have any future call to next() return NONE - - if (mutator.isNewSchema()) { - // This last reader has a new schema (e.g., we have a zero-row - // file or other source). (Note that some sources have a non- - // null/non-trivial schema even when there are no rows.) + injector.injectChecked(context.getExecutionControls(), "next-allocate", OutOfMemoryException.class); --- End diff -- The code in `ScanBatch` changed significantly -- looks like a very good improvement. However, I could not readily find unit tests that execute all the complex new code paths. Can you perhaps point out the tests? Otherwise, as a reviewer, I find myself acting as the unit tests; I must "mentally execute" the code paths for all scenarios I can imagine. This is slow and will lead to many, many comments as I try to think through each and every step. Plus, the situation is made harder by the fact that code is duplicated along various execution branches.
--- 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. ---