pub fn builder_with_capacity_in(
dtype: &DType,
capacity: usize,
allocator: &BufferAllocatorRef,
) -> Box<dyn ArrayBuilder>Expand description
Construct a new canonical builder using allocator.
ยงExample
use vortex_array::builders::{ArrayBuilder, builder_with_capacity_in};
use vortex_array::dtype::{DType, Nullability};
use vortex_array::memory::BufferAllocatorRef;
use vortex_array::{VortexSessionExecute, array_session};
// Create a new builder for string data.
let mut builder = builder_with_capacity_in(&DType::Utf8(Nullability::NonNullable), 4, BufferAllocatorRef::static_ref());
builder.append_scalar(&"a".into()).unwrap();
builder.append_scalar(&"b".into()).unwrap();
builder.append_scalar(&"c".into()).unwrap();
builder.append_scalar(&"d".into()).unwrap();
let strings = builder.finish();
let mut ctx = array_session().create_execution_ctx();
assert_eq!(strings.execute_scalar(0, &mut ctx).unwrap(), "a".into());
assert_eq!(strings.execute_scalar(1, &mut ctx).unwrap(), "b".into());
assert_eq!(strings.execute_scalar(2, &mut ctx).unwrap(), "c".into());
assert_eq!(strings.execute_scalar(3, &mut ctx).unwrap(), "d".into());