pub struct BooleanBuilder {
values_builder: BooleanBufferBuilder,
null_buffer_builder: NullBufferBuilder,
}
Expand description
Builder for BooleanArray
§Example
Create a BooleanArray
from a BooleanBuilder
let mut b = BooleanBuilder::new();
b.append_value(true);
b.append_null();
b.append_value(false);
b.append_value(true);
let arr = b.finish();
assert_eq!(4, arr.len());
assert_eq!(1, arr.null_count());
assert_eq!(true, arr.value(0));
assert!(arr.is_valid(0));
assert!(!arr.is_null(0));
assert!(!arr.is_valid(1));
assert!(arr.is_null(1));
assert_eq!(false, arr.value(2));
assert!(arr.is_valid(2));
assert!(!arr.is_null(2));
assert_eq!(true, arr.value(3));
assert!(arr.is_valid(3));
assert!(!arr.is_null(3));
Fields§
§values_builder: BooleanBufferBuilder
§null_buffer_builder: NullBufferBuilder
Implementations§
Source§impl BooleanBuilder
impl BooleanBuilder
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new boolean builder with space for capacity
elements without re-allocating
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the capacity of this builder measured in slots of type T
Sourcepub fn append_value(&mut self, v: bool)
pub fn append_value(&mut self, v: bool)
Appends a value of type T
into the builder
Sourcepub fn append_null(&mut self)
pub fn append_null(&mut self)
Appends a null slot into the builder
Sourcepub fn append_nulls(&mut self, n: usize)
pub fn append_nulls(&mut self, n: usize)
Appends n
null
s into the builder.
Sourcepub fn append_option(&mut self, v: Option<bool>)
pub fn append_option(&mut self, v: Option<bool>)
Appends an Option<T>
into the builder
Sourcepub fn append_slice(&mut self, v: &[bool])
pub fn append_slice(&mut self, v: &[bool])
Appends a slice of type T
into the builder
Sourcepub fn append_n(&mut self, additional: usize, v: bool)
pub fn append_n(&mut self, additional: usize, v: bool)
Appends n additional
bits of value v
into the buffer
Sourcepub fn append_values(
&mut self,
values: &[bool],
is_valid: &[bool],
) -> Result<(), ArrowError>
pub fn append_values( &mut self, values: &[bool], is_valid: &[bool], ) -> Result<(), ArrowError>
Appends values from a slice of type T
and a validity boolean slice.
Returns an error if the slices are of different lengths
Sourcepub fn finish(&mut self) -> BooleanArray
pub fn finish(&mut self) -> BooleanArray
Builds the BooleanArray and reset this builder.
Sourcepub fn finish_cloned(&self) -> BooleanArray
pub fn finish_cloned(&self) -> BooleanArray
Builds the BooleanArray without resetting the builder.
Sourcepub fn values_slice(&self) -> &[u8] ⓘ
pub fn values_slice(&self) -> &[u8] ⓘ
Returns the current values buffer as a slice
Boolean values are bit-packed into bytes. To extract the i-th boolean
from the bytes, you can use arrow_buffer::bit_util::get_bit()
.
Sourcepub fn validity_slice(&self) -> Option<&[u8]>
pub fn validity_slice(&self) -> Option<&[u8]>
Returns the current null buffer as a slice
Trait Implementations§
Source§impl ArrayBuilder for BooleanBuilder
impl ArrayBuilder for BooleanBuilder
Source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Returns the builder as a mutable Any
reference.
Source§fn finish_cloned(&self) -> ArrayRef
fn finish_cloned(&self) -> ArrayRef
Builds the array without resetting the builder.
Source§impl Debug for BooleanBuilder
impl Debug for BooleanBuilder
Source§impl Default for BooleanBuilder
impl Default for BooleanBuilder
Source§impl Extend<Option<bool>> for BooleanBuilder
impl Extend<Option<bool>> for BooleanBuilder
Source§fn extend<T: IntoIterator<Item = Option<bool>>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Option<bool>>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)