ReadOnlyMetadataBuilder

Struct ReadOnlyMetadataBuilder 

Source
pub struct ReadOnlyMetadataBuilder<'m> {
    metadata: VariantMetadata<'m>,
    known_field_names: HashMap<&'m str, u32>,
}
Expand description

A metadata builder that cannot register new field names, and merely returns the field id associated with a known field name. This is useful for variant unshredding operations, where the metadata column is fixed and – per variant shredding spec – already contains all field names from the typed_value column. It is also useful when projecting a subset of fields from a variant object value, since the bytes can be copied across directly without re-encoding their field ids.

NOTE: Self::finish is a no-op. If the intent is to make a copy of the underlying bytes each time finish is called, a different trait impl will be needed.

Fields§

§metadata: VariantMetadata<'m>§known_field_names: HashMap<&'m str, u32>

Implementations§

Source§

impl<'m> ReadOnlyMetadataBuilder<'m>

Source

pub fn new(metadata: VariantMetadata<'m>) -> Self

Creates a new read-only metadata builder from the given metadata dictionary.

Trait Implementations§

Source§

impl<'m> Debug for ReadOnlyMetadataBuilder<'m>

Source§

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

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

impl MetadataBuilder for ReadOnlyMetadataBuilder<'_>

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.