pub struct IpcSchemaEncoder<'a> { /* private fields */ }
Expand description
Low level Arrow Schema to IPC bytes converter
See also fb_to_schema
for the reverse operation
§Example
// given an arrow schema to serialize
let schema = Schema::new(vec![
Field::new("a", DataType::Int32, false),
]);
// Use a dictionary tracker to track dictionary id if needed
let mut dictionary_tracker = DictionaryTracker::new(true);
// create a FlatBuffersBuilder that contains the encoded bytes
let fb = IpcSchemaEncoder::new()
.with_dictionary_tracker(&mut dictionary_tracker)
.schema_to_fb(&schema);
// the bytes are in `fb.finished_data()`
let ipc_bytes = fb.finished_data();
// convert the IPC bytes back to an Arrow schema
let ipc_schema = root_as_schema(ipc_bytes).unwrap();
let schema2 = fb_to_schema(ipc_schema);
assert_eq!(schema, schema2);
Implementations§
Source§impl<'a> IpcSchemaEncoder<'a>
impl<'a> IpcSchemaEncoder<'a>
Sourcepub fn new() -> IpcSchemaEncoder<'a>
pub fn new() -> IpcSchemaEncoder<'a>
Create a new schema encoder
Sourcepub fn with_dictionary_tracker(
self,
dictionary_tracker: &'a mut DictionaryTracker,
) -> Self
pub fn with_dictionary_tracker( self, dictionary_tracker: &'a mut DictionaryTracker, ) -> Self
Specify a dictionary tracker to use
Sourcepub fn schema_to_fb<'b>(&mut self, schema: &Schema) -> FlatBufferBuilder<'b>
pub fn schema_to_fb<'b>(&mut self, schema: &Schema) -> FlatBufferBuilder<'b>
Serialize a schema in IPC format, returning a completed FlatBufferBuilder
Note: Call FlatBufferBuilder::finished_data
to get the serialized bytes
Sourcepub fn schema_to_fb_offset<'b>(
&mut self,
fbb: &mut FlatBufferBuilder<'b>,
schema: &Schema,
) -> WIPOffset<Schema<'b>>
pub fn schema_to_fb_offset<'b>( &mut self, fbb: &mut FlatBufferBuilder<'b>, schema: &Schema, ) -> WIPOffset<Schema<'b>>
Serialize a schema to an in progress FlatBufferBuilder
, returning the in progress offset.
Trait Implementations§
Source§impl<'a> Debug for IpcSchemaEncoder<'a>
impl<'a> Debug for IpcSchemaEncoder<'a>
Auto Trait Implementations§
impl<'a> Freeze for IpcSchemaEncoder<'a>
impl<'a> RefUnwindSafe for IpcSchemaEncoder<'a>
impl<'a> Send for IpcSchemaEncoder<'a>
impl<'a> Sync for IpcSchemaEncoder<'a>
impl<'a> Unpin for IpcSchemaEncoder<'a>
impl<'a> !UnwindSafe for IpcSchemaEncoder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more