Expand description
Contains declarations to bind to the C Stream Interface.
This module has two main interfaces: One interface maps C ABI to native Rust types, i.e. convert c-pointers, c_char, to native rust. This is handled by FFI_ArrowArrayStream.
The second interface is used to import FFI_ArrowArrayStream as a Rust reader. A stream
whose top-level type is Struct can be read as RecordBatch by RecordBatchStreamReader;
a stream of any type can be read as ArrayRef by ArrayStreamReader.
β
// create an record batch reader natively
let file = File::open("arrow_file").unwrap();
let reader = Box::new(FileReader::try_new(file).unwrap());
// export it
let mut stream = FFI_ArrowArrayStream::empty();
unsafe { export_reader_into_raw(reader, &mut stream) };
// consumed and used by something else...
// import it
let stream_reader = unsafe { RecordBatchStreamReader::from_raw(&mut stream).unwrap() };
let imported_schema = stream_reader.schema();
let mut produced_batches = vec![];
for batch in stream_reader {
produced_batches.push(batch.unwrap());
}
Ok(())
}Re-exportsΒ§
use arrow_schema::DataType;πuse std::ffi::CStr;πuse std::ptr::addr_of;πuse std::ffi::CString;πuse std::os::raw::c_char;πuse std::os::raw::c_int;πuse std::os::raw::c_void;πuse std::sync::Arc;πuse arrow_data::ffi::FFI_ArrowArray;πuse arrow_schema::ArrowError;πuse arrow_schema::Field;πuse arrow_schema::FieldRef;πuse arrow_schema::Schema;πuse arrow_schema::SchemaRef;πuse arrow_schema::ffi::FFI_ArrowSchema;πuse crate::RecordBatchOptions;πuse crate::array::Array;πuse crate::array::StructArray;πuse crate::array::ArrayRef;πuse crate::array::make_array;πuse crate::array_reader::ArrayReader;πuse crate::ffi::from_ffi_and_data_type;πuse crate::record_batch::RecordBatch;πuse crate::record_batch::RecordBatchReader;πuse libc::EINVAL;πuse libc::EIO;πuse libc::ENOMEM;πuse libc::ENOSYS;π
StructsΒ§
- Array
Stream Reader - An
ArrayReaderwhich imports arrays from anFFI_ArrowArrayStream. - Exported
Array πStream - FFI_
Arrow Array Stream - ABI-compatible struct for
ArrayStreamfrom C Stream Interface See https://arrow.apache.org/docs/format/CStreamInterface.html#structure-definitions This was created by bindgen - Record
Batch Stream Reader - A
RecordBatchReaderwhich imports Arrays fromFFI_ArrowArrayStream. - Stream
Private πData
FunctionsΒ§
- get_
error_ πcode - get_
last_ π βerror - get_
next π β - get_
schema π β - get_
stream_ πfield - Gets the field from a raw pointer of
FFI_ArrowArrayStream. This is used when constructingArrayStreamReaderto cache the field. - get_
stream_ πschema - Gets schema from a raw pointer of
FFI_ArrowArrayStream. This is used when constructingRecordBatchStreamReaderto cache schema. - producer_
error π β - Returns the producerβs message for the last failed call on a
FFI_ArrowArrayStream. - release_
stream π β
Type AliasesΒ§
- Arrow
Array Stream Reader Deprecated - Renamed to
RecordBatchStreamReader, to distinguish it fromArrayStreamReader. - Result π