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>
impl<'m> ReadOnlyMetadataBuilder<'m>
Sourcepub fn new(metadata: VariantMetadata<'m>) -> Self
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>
impl<'m> Debug for ReadOnlyMetadataBuilder<'m>
Source§impl MetadataBuilder for ReadOnlyMetadataBuilder<'_>
impl MetadataBuilder for ReadOnlyMetadataBuilder<'_>
Source§fn try_upsert_field_name(&mut self, field_name: &str) -> Result<u32, ArrowError>
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
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
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)
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.
Auto Trait Implementations§
impl<'m> Freeze for ReadOnlyMetadataBuilder<'m>
impl<'m> RefUnwindSafe for ReadOnlyMetadataBuilder<'m>
impl<'m> Send for ReadOnlyMetadataBuilder<'m>
impl<'m> Sync for ReadOnlyMetadataBuilder<'m>
impl<'m> Unpin for ReadOnlyMetadataBuilder<'m>
impl<'m> UnwindSafe for ReadOnlyMetadataBuilder<'m>
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