Github user jinfengni commented on a diff in the pull request:

    https://github.com/apache/drill/pull/906#discussion_r135709915
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/ScanBatch.java 
---
    @@ -252,14 +235,28 @@ public IterOutcome next() {
         }
       }
     
    +  private void releaseAssets() {
    +    container.zeroVectors();
    +  }
    +
    +  private void clearFieldVectorMap() {
    +    for (final ValueVector v : mutator.fieldVectorMap().values()) {
    +      v.clear();
    +    }
    +  }
    +
    +  private void advanceNextReader() throws ExecutionSetupException {
    +    currentReader = readers.next();
    +    implicitValues = implicitColumns.hasNext() ? implicitColumns.next() : 
null;
    +    currentReader.setup(oContext, mutator);
    --- End diff --
    
    Nice catch. You are right we should not advance to next reader if we need 
pass a batch to downstream, since `reader.setup()` for new reader could modify 
both mutator and container.  This seems to be true for original ScanBatch code 
as well. 
    
    In the revised batch,  I remove the code to get next reader in constructor, 
and put the code to get next reader in the beginning of loop when needed. In 
case of return a `OK_NEW_SCHEMA`, we will only get next reader in the next 
`next()` method call after `OK_NEW_SCHEMA` is returned.  
     


---
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.
---

Reply via email to