Module ffi_stream

Source
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 Rust implementation RecordBatch reader. This is handled by ArrowArrayStreamReader.

โ“˜
// 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 { ArrowArrayStreamReader::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(())
}

Structsยง

ArrowArrayStreamReader
A RecordBatchReader which imports Arrays from FFI_ArrowArrayStream.
ExportedArrayStream ๐Ÿ”’
FFI_ArrowArrayStream
ABI-compatible struct for ArrayStream from C Stream Interface See https://arrow.apache.org/docs/format/CStreamInterface.html#structure-definitions This was created by bindgen
StreamPrivateData ๐Ÿ”’

Constantsยง

EINVAL ๐Ÿ”’
EIO ๐Ÿ”’
ENOMEM ๐Ÿ”’
ENOSYS ๐Ÿ”’

Functionsยง

get_error_code ๐Ÿ”’
get_last_error ๐Ÿ”’ โš 
get_next ๐Ÿ”’ โš 
get_schema ๐Ÿ”’ โš 
get_stream_schema ๐Ÿ”’
Gets schema from a raw pointer of FFI_ArrowArrayStream. This is used when constructing ArrowArrayStreamReader to cache schema.
release_stream ๐Ÿ”’ โš 

Type Aliasesยง

Result ๐Ÿ”’