jecsand838 commented on code in PR #8100:
URL: https://github.com/apache/arrow-rs/pull/8100#discussion_r2267919050


##########
arrow-avro/src/reader/mod.rs:
##########
@@ -270,6 +271,24 @@ impl Decoder {
                 self.active_decoder = new_decoder;
             }
         }
+    }
+
+    fn apply_pending_schema_if_batch_empty(&mut self) {
+        if self.remaining_capacity != self.batch_size {
+            return;
+        }
+        self.apply_pending_schema();
+    }
+
+    /// Produce a `RecordBatch` if at least one row is fully decoded, returning
+    /// `Ok(None)` if no new rows are available.
+    pub fn flush(&mut self) -> Result<Option<RecordBatch>, ArrowError> {
+        if self.remaining_capacity == self.batch_size {
+            return Ok(None);
+        }
+        let batch = self.active_decoder.flush()?;
+        self.remaining_capacity = self.batch_size;
+        self.apply_pending_schema();

Review Comment:
   I just pushed up changes which include a new `flush_and_reset` method:
   
   ```rust
       fn flush_and_reset(&mut self) -> Result<Option<RecordBatch>, ArrowError> 
{
           if self.batch_is_empty() {
               return Ok(None);
           }
           let batch = self.active_decoder.flush()?;
           self.remaining_capacity = self.batch_size;
           Ok(Some(batch))
       }
   ```
   
   It abstracted out most of the flush logic and `flush_block` is now just a 
public wrapper for that new method. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to