MCPcopy Create free account
hub / github.com/apache/datafusion / fill_output_buffer

Method fill_output_buffer

datafusion/datasource-json/src/utils.rs:306–332  ·  view source on GitHub ↗

Fill the output buffer with transformed data. This method manages its own input buffer, reading from the inner reader as needed. When the output buffer is full, we stop processing but preserve the current position in the input buffer for the next call.

(&mut self)

Source from the content-addressed store, hash-verified

304 /// as needed. When the output buffer is full, we stop processing but preserve
305 /// the current position in the input buffer for the next call.
306 fn fill_output_buffer(&mut self) -> std::io::Result<()> {
307 let mut write_pos = 0;
308
309 while write_pos < self.output_buffer.len() {
310 // Refill input buffer if exhausted
311 if !self.refill_input_if_needed()? {
312 break; // EOF
313 }
314
315 // Process bytes from input buffer
316 while self.input_pos < self.input_filled
317 && write_pos < self.output_buffer.len()
318 {
319 let byte = self.input_buffer[self.input_pos];
320 self.input_pos += 1;
321
322 if let Some(transformed) = self.process_byte(byte) {
323 self.output_buffer[write_pos] = transformed;
324 write_pos += 1;
325 }
326 }
327 }
328
329 self.output_pos = 0;
330 self.output_filled = write_pos;
331 Ok(())
332 }
333}
334
335impl<R: Read> Read for JsonArrayToNdjsonReader<R> {

Callers 2

readMethod · 0.80
fill_bufMethod · 0.80

Calls 3

process_byteMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected