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

    https://github.com/apache/drill/pull/1237#discussion_r184117938
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unorderedreceiver/UnorderedReceiverBatch.java
 ---
    @@ -182,13 +184,18 @@ public IterOutcome next() {
             return IterOutcome.OUT_OF_MEMORY;
           }
     
    +      // Transfer the ownership of this raw-batch to this operator for 
proper memory statistics reporting
    +      batch = batch.transferBodyOwnership(oContext.getAllocator());
    +
           final RecordBatchDef rbd = batch.getHeader().getDef();
           final boolean schemaChanged = batchLoader.load(rbd, batch.getBody());
           // TODO:  Clean:  DRILL-2933:  That load(...) no longer throws
           // SchemaChangeException, so check/clean catch clause below.
           stats.addLongStat(Metric.BYTES_RECEIVED, batch.getByteCount());
     
           batch.release();
    +      batch = null;
    --- End diff --
    
    Not sure what you mean but this is the goal of the current code:
    - After a batch is properly set, we need to decrease the ref count by one 
by the end of the next() method
    - If an exception happens before the release call, then the finally block 
will be able to release the batch since it will be different than null
    - Otherwise, the release will be performed and the batch set to null which 
will disable the release within the finally block 


---

Reply via email to