#[repr(C)]pub struct FFI_ArrowSchema {
format: *const c_char,
name: *const c_char,
metadata: *const c_char,
flags: i64,
n_children: i64,
children: *mut *mut FFI_ArrowSchema,
dictionary: *mut FFI_ArrowSchema,
release: Option<unsafe extern "C" fn(arg1: *mut FFI_ArrowSchema)>,
private_data: *mut c_void,
}Expand description
ABI-compatible struct for ArrowSchema from C Data Interface
See https://arrow.apache.org/docs/format/CDataInterface.html#the-arrowschema-structure
fn array_schema(data_type: &DataType) -> FFI_ArrowSchema {
FFI_ArrowSchema::try_from(data_type).unwrap()
}Fields§
§format: *const c_charNull-terminated, UTF8-encoded string describing the data type
name: *const c_charNull-terminated, UTF8-encoded string of the field or array name
metadata: *const c_charBinary string describing the type’s metadata
flags: i64A bitfield of flags enriching the type description Refer to Arrow Flags
n_children: i64The number of children this type has
children: *mut *mut FFI_ArrowSchemaC array of pointers to each child type of this type
dictionary: *mut FFI_ArrowSchemaPointer to the type of dictionary values
release: Option<unsafe extern "C" fn(arg1: *mut FFI_ArrowSchema)>Producer-provided release callback.
private_data: *mut c_voidOpaque producer-provided private data, owned by the release callback.
Implementations§
Source§impl FFI_ArrowSchema
impl FFI_ArrowSchema
Sourcepub fn try_new(
format: &str,
children: Vec<FFI_ArrowSchema>,
dictionary: Option<FFI_ArrowSchema>,
) -> Result<Self, ArrowError>
pub fn try_new( format: &str, children: Vec<FFI_ArrowSchema>, dictionary: Option<FFI_ArrowSchema>, ) -> Result<Self, ArrowError>
create a new FFI_ArrowSchema. This fails if the fields’
DataType is not supported.
§Panics
Panics if format contains an interior nul byte
Sourcepub fn with_name(self, name: &str) -> Result<Self, ArrowError>
pub fn with_name(self, name: &str) -> Result<Self, ArrowError>
Set the name of the schema
Sourcepub fn with_flags(self, flags: Flags) -> Result<Self, ArrowError>
pub fn with_flags(self, flags: Flags) -> Result<Self, ArrowError>
Set the flags of the schema
Sourcepub fn with_metadata<I, S>(self, metadata: I) -> Result<Self, ArrowError>
pub fn with_metadata<I, S>(self, metadata: I) -> Result<Self, ArrowError>
Add metadata to the schema
Sourcepub unsafe fn from_raw(schema: *mut FFI_ArrowSchema) -> Self
pub unsafe fn from_raw(schema: *mut FFI_ArrowSchema) -> Self
Takes ownership of the pointed to FFI_ArrowSchema
This acts to move the data out of schema, setting the release callback to NULL
§Safety
schemamust be valid for reads and writesschemamust be properly alignedschemamust point to a properly initialized value ofFFI_ArrowSchema
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Create an empty FFI_ArrowSchema
Sourcepub fn release(
&self,
) -> Option<unsafe extern "C" fn(arg1: *mut FFI_ArrowSchema)>
pub fn release( &self, ) -> Option<unsafe extern "C" fn(arg1: *mut FFI_ArrowSchema)>
Returns the producer-provided release callback, if any.
Sourcepub fn private_data(&self) -> *mut c_void
pub fn private_data(&self) -> *mut c_void
Returns the opaque producer-provided private data pointer.
Sourcepub unsafe fn set_release(
&mut self,
release: Option<unsafe extern "C" fn(arg1: *mut FFI_ArrowSchema)>,
) -> Option<unsafe extern "C" fn(arg1: *mut FFI_ArrowSchema)>
pub unsafe fn set_release( &mut self, release: Option<unsafe extern "C" fn(arg1: *mut FFI_ArrowSchema)>, ) -> Option<unsafe extern "C" fn(arg1: *mut FFI_ArrowSchema)>
Replaces the release callback, returning the previous one.
Lets a consumer wrap release: save the old callback, install its own, and chain back on drop. See https://github.com/apache/arrow-rs/issues/9771.
§Safety
Drop calls this callback with a pointer to self. The new callback
must correctly release this schema (usually by chaining to the returned
one) and must match the FFI_ArrowSchema::private_data it reads. A
wrong callback is undefined behavior on drop.
Sourcepub unsafe fn set_private_data(
&mut self,
private_data: *mut c_void,
) -> *mut c_void
pub unsafe fn set_private_data( &mut self, private_data: *mut c_void, ) -> *mut c_void
Replaces the private data pointer, returning the previous one.
§Safety
The old pointer is returned without being freed; the caller owns it from
here. The new pointer must match what the current
FFI_ArrowSchema::release callback expects.
Sourcepub fn child(&self, index: usize) -> &Self
pub fn child(&self, index: usize) -> &Self
Returns the child of this schema at index.
§Panics
Panics if index is greater than or equal to the number of children.
This is to make sure that the unsafe acces to raw pointer is sound.
Sourcepub fn children(&self) -> impl Iterator<Item = &Self>
pub fn children(&self) -> impl Iterator<Item = &Self>
Returns an iterator to the schema’s children.
Sourcepub fn nullable(&self) -> bool
pub fn nullable(&self) -> bool
Returns if the field is semantically nullable, regardless of whether it actually has null values.
Sourcepub fn dictionary(&self) -> Option<&Self>
pub fn dictionary(&self) -> Option<&Self>
Returns the reference to the underlying dictionary of the schema. Check ArrowSchema.dictionary.
This must be Some if the schema represents a dictionary-encoded type, None otherwise.
Sourcepub fn map_keys_sorted(&self) -> bool
pub fn map_keys_sorted(&self) -> bool
For map types, returns whether the keys within each map value are sorted.
Refer to Arrow Flags
Sourcepub fn dictionary_ordered(&self) -> bool
pub fn dictionary_ordered(&self) -> bool
For dictionary-encoded types, returns whether the ordering of dictionary indices is semantically meaningful.