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

Method next

arrow-array/src/ffi_stream.rs:354–381  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

352 type Item = Result<RecordBatch>;
353
354 fn next(&mut self) -> Option<Self::Item> {
355 let mut array = FFI_ArrowArray::empty();
356
357 let ret_code = unsafe { self.stream.get_next.unwrap()(&mut self.stream, &mut array) };
358
359 if ret_code == 0 {
360 // The end of stream has been reached
361 if array.is_released() {
362 return None;
363 }
364
365 let result = unsafe {
366 from_ffi_and_data_type(array, DataType::Struct(self.schema().fields().clone()))
367 };
368 Some(result.and_then(|data| {
369 let len = data.len();
370 RecordBatch::try_new_with_options(
371 self.schema.clone(),
372 StructArray::from(data).into_parts().1,
373 &RecordBatchOptions::new().with_row_count(Some(len)),
374 )
375 }))
376 } else {
377 let last_error = self.get_stream_last_error();
378 let err = ArrowError::CDataInterface(last_error.unwrap());
379 Some(Err(err))
380 }
381 }
382}
383
384impl RecordBatchReader for ArrowArrayStreamReader {

Callers 1

get_nextMethod · 0.45

Calls 10

from_ffi_and_data_typeFunction · 0.85
is_releasedMethod · 0.80
and_thenMethod · 0.80
with_row_countMethod · 0.80
get_stream_last_errorMethod · 0.80
cloneMethod · 0.45
fieldsMethod · 0.45
schemaMethod · 0.45
lenMethod · 0.45
into_partsMethod · 0.45

Tested by

no test coverage detected