Import [ArrayData] from the C Data Interface # Safety This struct assumes that the incoming data agrees with the C data interface.
(array: FFI_ArrowArray, schema: &FFI_ArrowSchema)
| 280 | /// |
| 281 | /// This struct assumes that the incoming data agrees with the C data interface. |
| 282 | pub unsafe fn from_ffi(array: FFI_ArrowArray, schema: &FFI_ArrowSchema) -> Result<ArrayData> { |
| 283 | let dt = DataType::try_from(schema)?; |
| 284 | let array = Arc::new(array); |
| 285 | let tmp = ImportedArrowArray { |
| 286 | array: &array, |
| 287 | data_type: dt, |
| 288 | owner: &array, |
| 289 | }; |
| 290 | let mut data = tmp.consume()?; |
| 291 | // arrow-rs has stricter alignment requirements than the C Data Interface spec; |
| 292 | // a no-op when buffers are already aligned. Unreachable under |
| 293 | // `cfg(feature = "force_validate")`; tracked in #10034. |
| 294 | // See https://github.com/apache/arrow/issues/43552 and |
| 295 | // https://github.com/apache/arrow-rs/issues/10028 for context. |
| 296 | data.align_buffers(); |
| 297 | Ok(data) |
| 298 | } |
| 299 | |
| 300 | /// Import [ArrayData] from the C Data Interface |
| 301 | /// |