WritableMetadataBuilder

Struct WritableMetadataBuilder 

Source
pub struct WritableMetadataBuilder {
    field_names: IndexSet<String>,
    is_sorted: bool,
    metadata_buffer: Vec<u8>,
}
Expand description

Builder for constructing metadata for Variant values.

This is used internally by the VariantBuilder to construct the metadata

You can use an existing Vec<u8> as the metadata buffer by using the from impl.

Fields§

§field_names: IndexSet<String>§is_sorted: bool§metadata_buffer: Vec<u8>

Output buffer. Metadata is written to the end of this buffer

Implementations§

Source§

impl WritableMetadataBuilder

Source

fn upsert_field_name(&mut self, field_name: &str) -> u32

Upsert field name to dictionary, return its ID

Source

pub fn offset(&self) -> usize

The current length of the underlying metadata buffer

Source

fn num_field_names(&self) -> usize

Returns the number of field names stored in the metadata builder. Note: this method should be the only place to call self.field_names.len()

§Panics

If the number of field names exceeds the maximum allowed value for u32.

Source

fn field_name(&self, i: usize) -> &str

Source

fn metadata_size(&self) -> usize

Source

pub fn finish(&mut self) -> usize

Finalizes the metadata dictionary and appends its serialized bytes to the underlying buffer, returning the resulting Self::offset. The builder state is reset and ready to start building a new metadata dictionary.

Source

pub fn into_inner(self) -> Vec<u8>

Returns the inner buffer, consuming self without finalizing any in progress metadata.

Trait Implementations§

Source§

impl Debug for WritableMetadataBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for WritableMetadataBuilder

Source§

fn default() -> WritableMetadataBuilder

Returns the “default value” for a type. Read more
Source§

impl<S: AsRef<str>> Extend<S> for WritableMetadataBuilder

Source§

fn extend<T: IntoIterator<Item = S>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<S: AsRef<str>> FromIterator<S> for WritableMetadataBuilder

Source§

fn from_iter<T: IntoIterator<Item = S>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl MetadataBuilder for WritableMetadataBuilder

Source§

fn try_upsert_field_name(&mut self, field_name: &str) -> Result<u32, ArrowError>

Attempts to register a field name, returning the corresponding (possibly newly-created) field id on success. Attempting to register the same field name twice will generally produce the same field id both times, but the variant spec does not actually require it.
Source§

fn field_name(&self, field_id: usize) -> &str

Retrieves the field name for a given field id, which must be less than Self::num_field_names. Panics if the field id is out of bounds.
Source§

fn num_field_names(&self) -> usize

Returns the number of field names stored in this metadata builder. Any number less than this is a valid field id. The builder can be reverted back to this size later on (discarding any newer/higher field ids) by calling Self::truncate_field_names.
Source§

fn truncate_field_names(&mut self, new_size: usize)

Reverts the field names to a previous size, discarding any newly out of bounds field ids.
Source§

fn finish(&mut self) -> usize

Finishes the current metadata dictionary, returning the new size of the underlying buffer.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.