-
Notifications
You must be signed in to change notification settings - Fork 823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Specific builder for typed builder trait and easier to use for lists #6863
base: main
Are you sure you want to change the base?
Changes from all commits
3947bbe
d0e5c32
c6e88cd
a8cb7d0
878ec3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,8 @@ | |
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
use crate::builder::{ArrayBuilder, BooleanBufferBuilder}; | ||
use crate::{ArrayRef, BooleanArray}; | ||
use crate::builder::{SpecificArrayBuilder, ArrayBuilder, BooleanBufferBuilder}; | ||
use crate::{Array, ArrayRef, BooleanArray}; | ||
use arrow_buffer::Buffer; | ||
use arrow_buffer::NullBufferBuilder; | ||
use arrow_data::ArrayData; | ||
|
@@ -219,6 +219,49 @@ impl ArrayBuilder for BooleanBuilder { | |
} | ||
} | ||
|
||
|
||
impl SpecificArrayBuilder for BooleanBuilder { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The functionality of this trait seems to overlap with the existing extend functionality, I'm not sure what it is adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nothing, the only thing it add is for the list builder to use those functions as it expect a SpecificArrayBuilder trait |
||
type Output = BooleanArray; | ||
type Item<'a> = bool; | ||
|
||
/// Builds the array and reset this builder. | ||
fn finish(&mut self) -> Arc<BooleanArray> { | ||
Arc::new(self.finish()) | ||
} | ||
|
||
/// Builds the array without resetting the builder. | ||
fn finish_cloned(&self) -> Arc<BooleanArray> { | ||
Arc::new(self.finish_cloned()) | ||
} | ||
|
||
fn append_value(&mut self, value: bool) { | ||
self.append_value(value) | ||
} | ||
|
||
fn append_value_ref<'a>(&'a mut self, value: &'a Self::Item<'a>) { | ||
self.append_value(*value) | ||
} | ||
|
||
fn append_null(&mut self) { | ||
self.append_null() | ||
} | ||
|
||
fn append_nulls(&mut self, n: usize) { | ||
self.append_nulls(n) | ||
} | ||
|
||
fn append_output<'a>(&'a mut self, output: &'a Self::Output) { | ||
// TODO - if iterator exists try it? | ||
for i in 0..output.len() { | ||
if output.is_null(i) { | ||
self.append_null(); | ||
} else { | ||
self.append_value(output.value(i)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl Extend<Option<bool>> for BooleanBuilder { | ||
#[inline] | ||
fn extend<T: IntoIterator<Item = Option<bool>>>(&mut self, iter: T) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be necessary as this is already implemented for &BooleanArray