pub fn builder_with_capacity(
dtype: &DType,
capacity: usize,
) -> Box<dyn ArrayBuilder>Expand description
Construct a new canonical builder for the given DType.
ยงExample
use vortex_array::builders::{builder_with_capacity, ArrayBuilder};
use vortex_array::dtype::{DType, Nullability};
use vortex_array::{LEGACY_SESSION, VortexSessionExecute};
// Create a new builder for string data.
let mut builder = builder_with_capacity(&DType::Utf8(Nullability::NonNullable), 4);
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 = LEGACY_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());