(
reader: *mut paimon_record_batch_reader,
)
| 432 | /// `reader` must be a valid pointer from `paimon_table_read_to_arrow`, or null (returns error). |
| 433 | #[no_mangle] |
| 434 | pub unsafe extern "C" fn paimon_record_batch_reader_next( |
| 435 | reader: *mut paimon_record_batch_reader, |
| 436 | ) -> paimon_result_next_batch { |
| 437 | if let Err(e) = check_non_null(reader, "reader") { |
| 438 | return paimon_result_next_batch { |
| 439 | batch: paimon_arrow_batch { |
| 440 | array: std::ptr::null_mut(), |
| 441 | schema: std::ptr::null_mut(), |
| 442 | }, |
| 443 | error: e, |
| 444 | }; |
| 445 | } |
| 446 | |
| 447 | let stream = &mut *((*reader).inner as *mut ArrowRecordBatchStream); |
| 448 | |
| 449 | match runtime().block_on(stream.next()) { |
| 450 | Some(Ok(batch)) => { |
| 451 | let schema = batch.schema(); |
| 452 | let struct_array = StructArray::from(batch); |
| 453 | let ffi_array = FFI_ArrowArray::new(&struct_array.to_data()); |
| 454 | let ffi_schema = match FFI_ArrowSchema::try_from(schema.as_ref()) { |
| 455 | Ok(s) => s, |
| 456 | Err(e) => { |
| 457 | return paimon_result_next_batch { |
| 458 | batch: paimon_arrow_batch { |
| 459 | array: std::ptr::null_mut(), |
| 460 | schema: std::ptr::null_mut(), |
| 461 | }, |
| 462 | error: paimon_error::from_paimon(paimon::Error::UnexpectedError { |
| 463 | message: format!("Failed to export Arrow schema: {e}"), |
| 464 | source: Some(Box::new(e)), |
| 465 | }), |
| 466 | }; |
| 467 | } |
| 468 | }; |
| 469 | |
| 470 | let array_ptr = Box::into_raw(Box::new(ffi_array)) as *mut c_void; |
| 471 | let schema_ptr = Box::into_raw(Box::new(ffi_schema)) as *mut c_void; |
| 472 | |
| 473 | paimon_result_next_batch { |
| 474 | batch: paimon_arrow_batch { |
| 475 | array: array_ptr, |
| 476 | schema: schema_ptr, |
| 477 | }, |
| 478 | error: std::ptr::null_mut(), |
| 479 | } |
| 480 | } |
| 481 | Some(Err(e)) => paimon_result_next_batch { |
| 482 | batch: paimon_arrow_batch { |
| 483 | array: std::ptr::null_mut(), |
| 484 | schema: std::ptr::null_mut(), |
| 485 | }, |
| 486 | error: paimon_error::from_paimon(e), |
| 487 | }, |
| 488 | None => paimon_result_next_batch { |
| 489 | batch: paimon_arrow_batch { |
| 490 | array: std::ptr::null_mut(), |
| 491 | schema: std::ptr::null_mut(), |
nothing calls this directly
no test coverage detected