diff --git a/benches/growable.rs b/benches/growable.rs index ca7ac8a9045..ea6d2ed9a51 100644 --- a/benches/growable.rs +++ b/benches/growable.rs @@ -19,6 +19,16 @@ fn add_benchmark(c: &mut Criterion) { }) }); + c.bench_function("growable::dyn_primitive::non_null::non_null", |b| { + b.iter(|| { + let mut a: Box = + Box::new(GrowablePrimitive::new(vec![&i32_array], false, 1026 * 10)); + + let iter = values.clone().into_iter().map(|start| (0, start, 10)); + a.extend_from_iter(Box::new(iter)); + }) + }); + let i32_array = create_primitive_array::(1026 * 10, 0.0); c.bench_function("growable::primitive::non_null::null", |b| { b.iter(|| { diff --git a/src/array/growable/mod.rs b/src/array/growable/mod.rs index c6d45356237..ef190ec3ca3 100644 --- a/src/array/growable/mod.rs +++ b/src/array/growable/mod.rs @@ -40,6 +40,13 @@ pub trait Growable<'a> { /// Extends this [`Growable`] with null elements, disregarding the bound arrays fn extend_validity(&mut self, additional: usize); + /// Extends this [`Growable`] by iterator. + fn extend_from_iter(&mut self, iter: Box>) { + for (index, start, len) in iter { + self.extend(index, start, len); + } + } + /// Converts this [`Growable`] to an [`Arc`], thereby finishing the mutation. /// Self will be empty after such operation. fn as_arc(&mut self) -> std::sync::Arc {