pub struct UnionBuilder { /* private fields */ }
Expand description

Builder type for creating a new UnionArray.

Example: Dense Memory Layout


let mut builder = UnionBuilder::new_dense();
builder.append::<Int32Type>("a", 1).unwrap();
builder.append::<Float64Type>("b", 3.0).unwrap();
builder.append::<Int32Type>("a", 4).unwrap();
let union = builder.build().unwrap();

assert_eq!(union.type_id(0), 0_i8);
assert_eq!(union.type_id(1), 1_i8);
assert_eq!(union.type_id(2), 0_i8);

assert_eq!(union.value_offset(0), 0_i32);
assert_eq!(union.value_offset(1), 0_i32);
assert_eq!(union.value_offset(2), 1_i32);

Example: Sparse Memory Layout


let mut builder = UnionBuilder::new_sparse();
builder.append::<Int32Type>("a", 1).unwrap();
builder.append::<Float64Type>("b", 3.0).unwrap();
builder.append::<Int32Type>("a", 4).unwrap();
let union = builder.build().unwrap();

assert_eq!(union.type_id(0), 0_i8);
assert_eq!(union.type_id(1), 1_i8);
assert_eq!(union.type_id(2), 0_i8);

assert_eq!(union.value_offset(0), 0_i32);
assert_eq!(union.value_offset(1), 1_i32);
assert_eq!(union.value_offset(2), 2_i32);

Implementations§

Creates a new dense array builder.

Creates a new sparse array builder.

Creates a new dense array builder with capacity.

Creates a new sparse array builder with capacity.

Appends a null to this builder, encoding the null in the array of the type_name child / field.

Since UnionArray encodes nulls as an entry in its children (it doesn’t have a validity bitmap itself), and where the null is part of the final array, appending a NULL requires specifying which field (child) to use.

Appends a value to this builder.

Builds this builder creating a new UnionArray.

Trait Implementations§

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.