Skip to content

Commit

Permalink
refactor: Remove Growable in favor of ArrayBuilder (#21500)
Browse files Browse the repository at this point in the history
  • Loading branch information
orlp authored Feb 27, 2025
1 parent b416cbc commit 471d97e
Show file tree
Hide file tree
Showing 33 changed files with 192 additions and 2,585 deletions.
47 changes: 47 additions & 0 deletions crates/polars-arrow/src/array/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ pub trait StaticArrayBuilder {
share: ShareStrategy,
);

/// The same as subslice_extend, but repeats the extension `repeats` times.
fn subslice_extend_repeated(
&mut self,
other: &Self::Array,
start: usize,
length: usize,
repeats: usize,
share: ShareStrategy,
) {
for _ in 0..repeats {
self.subslice_extend(other, start, length, share)
}
}

/// Extends this builder with the contents of the given array at the given
/// indices. That is, other[idxs[i]] is appended to this array in order,
/// for each i=0..idxs.len(). May panic if other does not match the
Expand Down Expand Up @@ -82,6 +96,18 @@ impl<T: StaticArrayBuilder> ArrayBuilder for T {
StaticArrayBuilder::subslice_extend(self, other, start, length, share);
}

fn subslice_extend_repeated(
&mut self,
other: &dyn Array,
start: usize,
length: usize,
repeats: usize,
share: ShareStrategy,
) {
let other: &T::Array = other.as_any().downcast_ref().unwrap();
StaticArrayBuilder::subslice_extend_repeated(self, other, start, length, repeats, share);
}

#[inline(always)]
unsafe fn gather_extend(&mut self, other: &dyn Array, idxs: &[IdxSize], share: ShareStrategy) {
let other: &T::Array = other.as_any().downcast_ref().unwrap();
Expand Down Expand Up @@ -113,6 +139,16 @@ pub trait ArrayBuilder: ArrayBuilderBoxedHelper {
share: ShareStrategy,
);

/// The same as subslice_extend, but repeats the extension `repeats` times.
fn subslice_extend_repeated(
&mut self,
other: &dyn Array,
start: usize,
length: usize,
repeats: usize,
share: ShareStrategy,
);

/// Extends this builder with the contents of the given array at the given
/// indices. That is, other[idxs[i]] is appended to this array in order,
/// for each i=0..idxs.len(). May panic if other does not match the
Expand Down Expand Up @@ -157,6 +193,17 @@ impl ArrayBuilder for Box<dyn ArrayBuilder> {
(**self).subslice_extend(other, start, length, share);
}

fn subslice_extend_repeated(
&mut self,
other: &dyn Array,
start: usize,
length: usize,
repeats: usize,
share: ShareStrategy,
) {
(**self).subslice_extend_repeated(other, start, length, repeats, share);
}

unsafe fn gather_extend(&mut self, other: &dyn Array, idxs: &[IdxSize], share: ShareStrategy) {
(**self).gather_extend(other, idxs, share);
}
Expand Down
103 changes: 0 additions & 103 deletions crates/polars-arrow/src/array/growable/binary.rs

This file was deleted.

169 changes: 0 additions & 169 deletions crates/polars-arrow/src/array/growable/binview.rs

This file was deleted.

Loading

0 comments on commit 471d97e

Please sign in to comment.