Struct google_cloud_bigquery::storage::array::MapBuilder
pub struct MapBuilder<K, V>where
K: ArrayBuilder,
V: ArrayBuilder,{ /* private fields */ }Expand description
Builder for MapArray
let string_builder = StringBuilder::new();
let int_builder = Int32Builder::with_capacity(4);
// Construct `[{"joe": 1}, {"blogs": 2, "foo": 4}, {}, null]`
let mut builder = MapBuilder::new(None, string_builder, int_builder);
builder.keys().append_value("joe");
builder.values().append_value(1);
builder.append(true).unwrap();
builder.keys().append_value("blogs");
builder.values().append_value(2);
builder.keys().append_value("foo");
builder.values().append_value(4);
builder.append(true).unwrap();
builder.append(true).unwrap();
builder.append(false).unwrap();
let array = builder.finish();
assert_eq!(array.value_offsets(), &[0, 1, 3, 3, 3]);
assert_eq!(array.values().as_ref(), &Int32Array::from(vec![1, 2, 4]));
assert_eq!(array.keys().as_ref(), &StringArray::from(vec!["joe", "blogs", "foo"]));
Implementations§
§impl<K, V> MapBuilder<K, V>where
K: ArrayBuilder,
V: ArrayBuilder,
impl<K, V> MapBuilder<K, V>where K: ArrayBuilder, V: ArrayBuilder,
pub fn new(
field_names: Option<MapFieldNames>,
key_builder: K,
value_builder: V
) -> MapBuilder<K, V>
pub fn new( field_names: Option<MapFieldNames>, key_builder: K, value_builder: V ) -> MapBuilder<K, V>
Creates a new MapBuilder
pub fn with_capacity(
field_names: Option<MapFieldNames>,
key_builder: K,
value_builder: V,
capacity: usize
) -> MapBuilder<K, V>
pub fn with_capacity( field_names: Option<MapFieldNames>, key_builder: K, value_builder: V, capacity: usize ) -> MapBuilder<K, V>
Creates a new MapBuilder with capacity
pub fn append(&mut self, is_valid: bool) -> Result<(), ArrowError>
pub fn append(&mut self, is_valid: bool) -> Result<(), ArrowError>
Finish the current map array slot
Returns an error if the key and values builders are in an inconsistent state.
pub fn finish_cloned(&self) -> MapArray
pub fn finish_cloned(&self) -> MapArray
Builds the MapArray without resetting the builder.
Trait Implementations§
§impl<K, V> ArrayBuilder for MapBuilder<K, V>where
K: ArrayBuilder,
V: ArrayBuilder,
impl<K, V> ArrayBuilder for MapBuilder<K, V>where K: ArrayBuilder, V: ArrayBuilder,
§fn finish_cloned(&self) -> Arc<dyn Array, Global>
fn finish_cloned(&self) -> Arc<dyn Array, Global>
Builds the array without resetting the builder.
§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Returns the builder as a non-mutable
Any reference. Read more§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Returns the builder as a mutable
Any reference. Read more§fn into_box_any(self: Box<MapBuilder<K, V>, Global>) -> Box<dyn Any, Global>
fn into_box_any(self: Box<MapBuilder<K, V>, Global>) -> Box<dyn Any, Global>
Returns the boxed builder as a box of
Any.§impl<K, V> Debug for MapBuilder<K, V>where
K: Debug + ArrayBuilder,
V: Debug + ArrayBuilder,
impl<K, V> Debug for MapBuilder<K, V>where K: Debug + ArrayBuilder, V: Debug + ArrayBuilder,
Auto Trait Implementations§
impl<K, V> RefUnwindSafe for MapBuilder<K, V>where K: RefUnwindSafe, V: RefUnwindSafe,
impl<K, V> Send for MapBuilder<K, V>
impl<K, V> Sync for MapBuilder<K, V>where K: Sync, V: Sync,
impl<K, V> Unpin for MapBuilder<K, V>where K: Unpin, V: Unpin,
impl<K, V> UnwindSafe for MapBuilder<K, V>where K: UnwindSafe, V: UnwindSafe,
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request