pub struct MapBuilder<K: ArrayBuilder, V: ArrayBuilder> { /* private fields */ }
Expand description

Creates a new MapBuilder


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(), Int32Array::from(vec![1, 2, 4]));
assert_eq!(*array.keys(), StringArray::from(vec!["joe", "blogs", "foo"]));

Implementations§

Creates a new MapBuilder

Creates a new MapBuilder with capacity

Returns the key array builder of the map

Returns the value array builder of the map

Finish the current map array slot

Returns an error if the key and values builders are in an inconsistent state.

Builds the MapArray

Builds the MapArray without resetting the builder.

Trait Implementations§

Builds the array without resetting the builder.

Returns the number of array slots in the builder
Returns whether number of array slots is zero
Builds the array
Returns the builder as a non-mutable Any reference. Read more
Returns the builder as a mutable Any reference. Read more
Returns the boxed builder as a box of Any.
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.