Skip to content
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

feat: add GenericListViewBuilder #6552

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

Kikkon
Copy link
Contributor

@Kikkon Kikkon commented Oct 12, 2024

Which issue does this PR close?

A part of #5501

Rationale for this change

What changes are included in this PR?

Add GenericListViewBuilder implement

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Oct 12, 2024
@Kikkon Kikkon marked this pull request as draft October 12, 2024 13:24
arrow-array/src/builder/generic_list_view_builder.rs Outdated Show resolved Hide resolved
impl<OffsetSize: OffsetSizeTrait, T: ArrayBuilder> ArrayBuilder
for GenericListViewBuilder<OffsetSize, T>
where
T: 'static,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is static lifespan constraint avoidable?

arrow-array/src/builder/generic_list_view_builder.rs Outdated Show resolved Hide resolved
@Kikkon
Copy link
Contributor Author

Kikkon commented Oct 15, 2024

These two failed unit tests seem unrelated to this pr?

@Kikkon Kikkon requested a review from findepi October 15, 2024 15:11
Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skimmed, LGTM

Comment on lines +205 to +207
let offsets = Buffer::from_slice_ref(self.offsets_builder.as_slice());
// Safety: safe by construction
let offsets = ScalarBuffer::from(offsets);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does offsets_builder have finish_clonsed function?

Copy link
Contributor Author

@Kikkon Kikkon Oct 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like other builders, it is completed with a finish function.

Comment on lines +89 to +91
offsets_builder,
null_buffer_builder: NullBufferBuilder::new(capacity),
values_builder,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: for consistency inline all, or define all above struct constructor (uless there is a reason to treat null buffer builder differently)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for writing it this way is to maintain consistency with the GenericListBuilder API. I think aligning with it makes the API easier to use.

Comment on lines +123 to +126
/// Returns the child array builder as an immutable reference
pub fn values_ref(&self) -> &T {
&self.values_builder
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also to maintain API consistency with GenericListBuilder API , so it hasn’t been removed.

Comment on lines 698 to 703
#[should_panic(expected = "ListViewArray expected data type Int64 got Int32")]
fn test_checks_data_type() {
let field = Arc::new(Field::new("item", DataType::Int64, false));
let mut builder = ListViewBuilder::new(Int32Builder::new()).with_field(field.clone());
builder.append_value([Some(1)]);
builder.finish();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this panic on ListViewBuilder::new, append_value or finish?

Generally annotaiton-driven "should fail" tests are best if they are ~one-liners.
For longer code it might actually be important to asset which line, which operation fails, because that's the guarantee we want to provide to API users.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I added some comments on the should fail test.

@findepi
Copy link
Member

findepi commented Oct 26, 2024

@tustvold please take a look

@Kikkon
Copy link
Contributor Author

Kikkon commented Oct 30, 2024

I think he's phasing out of this part of the work; perhaps @alamb help review or assign it to someone.

@Kikkon
Copy link
Contributor Author

Kikkon commented Nov 12, 2024

@alamb I think we can proceed with this PR now. 🤠

@alamb
Copy link
Contributor

alamb commented Nov 13, 2024

Thanks @Kikkon -- looks like a cool PR. I have put it on my list for review, but given all the other things that are ahead of it I do not know when I will be able to get to this. Perhaps you have some time to help review some of the other PRs in this repository which could free up some time from the other maintainers?

@Kikkon
Copy link
Contributor Author

Kikkon commented Nov 13, 2024

Thanks @Kikkon -- looks like a cool PR. I have put it on my list for review, but given all the other things that are ahead of it I do not know when I will be able to get to this. Perhaps you have some time to help review some of the other PRs in this repository which could free up some time from the other maintainers?

Sounds good, I will choose some PRs that are within my capability to review.

Copy link
Contributor

@crepererum crepererum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks straight-forward and is well tested. Would merge w/ the test names fixed.

use crate::{Array, Int32Array};
use arrow_schema::DataType;

fn _test_generic_list_view_array_builder<O: OffsetSizeTrait>() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's mostly a style nitpick: I would prefer if we don't start with an underscore because the rust naming usually suggests that this is unused (at least that's how variable/member naming works). So a good name would be test_generic_list_view_array_builder_impl.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crepererum Great advice! I’ve already made the modifications and committed them. Ready to merge.

_test_generic_list_view_array_builder::<i64>()
}

fn _test_generic_list_view_array_builder_nulls<O: OffsetSizeTrait>() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

arrow-array/src/builder/generic_list_view_builder.rs Outdated Show resolved Hide resolved
arrow-array/src/builder/generic_list_view_builder.rs Outdated Show resolved Hide resolved
Kikkon and others added 3 commits December 28, 2024 21:04
Co-authored-by: Marco Neumann <marco@crepererum.net>
Co-authored-by: Marco Neumann <marco@crepererum.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants