MCPcopy Create free account
hub / github.com/apache/arrow-rs / flush

Method flush

arrow-json/src/reader/mod.rs:677–704  ·  view source on GitHub ↗

Flushes the currently buffered data to a [`RecordBatch`] Returns `Ok(None)` if no buffered data, i.e. [`Self::is_empty`] is true. Note: This will return an error if called part way through decoding a record, i.e. [`Self::has_partial_record`] is true.

(&mut self)

Source from the content-addressed store, hash-verified

675 /// Note: This will return an error if called part way through decoding a record,
676 /// i.e. [`Self::has_partial_record`] is true.
677 pub fn flush(&mut self) -> Result<Option<RecordBatch>, ArrowError> {
678 let tape = self.tape_decoder.finish()?;
679
680 if tape.num_rows() == 0 {
681 return Ok(None);
682 }
683
684 // First offset is null sentinel
685 let mut next_object = 1;
686 let pos: Vec<_> = (0..tape.num_rows())
687 .map(|_| {
688 let next = tape.next(next_object, "row").unwrap();
689 std::mem::replace(&mut next_object, next)
690 })
691 .collect();
692
693 let decoded = self.decoder.decode(&tape, &pos)?;
694 self.tape_decoder.clear();
695
696 let batch = match self.is_field {
697 true => RecordBatch::try_new(self.schema.clone(), vec![decoded])?,
698 false => {
699 RecordBatch::from(decoded.as_struct().clone()).with_schema(self.schema.clone())?
700 }
701 };
702
703 Ok(Some(batch))
704 }
705}
706
707trait ArrayDecoder: Send {

Callers 15

decode_and_flushFunction · 0.45
bench_serialize_valuesFunction · 0.45
readMethod · 0.45
test_basicFunction · 0.45
test_decoder_errorFunction · 0.45
test_serialize_timestampFunction · 0.45
test_serialize_decimalFunction · 0.45
test_serde_fieldFunction · 0.45
test_serde_large_numbersFunction · 0.45

Calls 10

try_newFunction · 0.85
collectMethod · 0.80
as_structMethod · 0.80
finishMethod · 0.45
num_rowsMethod · 0.45
nextMethod · 0.45
decodeMethod · 0.45
clearMethod · 0.45
cloneMethod · 0.45
with_schemaMethod · 0.45