Add ListView support to arrow-row and arrow-ord#9176
Conversation
friendlymatthew
left a comment
There was a problem hiding this comment.
Hi, do you mind rebasing? I think CI is failing because this needs to be rebased on the latest master- the base branch is missing the encoded_len fn that was added recently
Otherwise, the implementation makes sense to me
cd2a465 to
29f13ef
Compare
|
Very confused because both this PR and #9175 are based off of latest main, and the tip of the other PR seems to work fine. |
|
Figured it out, I did actually need to change something after the rebase here, also refactored the use in both list-types. |
arrow-row/src/list.rs
Outdated
| _ => unreachable!(), | ||
| }; | ||
|
|
||
| let null_buffer = NullBuffer::new(BooleanBuffer::new(nulls.into(), 0, rows.len())); |
There was a problem hiding this comment.
Maybe use new_unchecked as you already have the null count and we want to avoid calculating it twice
| let null_buffer = NullBuffer::new(BooleanBuffer::new(nulls.into(), 0, rows.len())); | |
| let null_buffer = NullBuffer::new_unchecked(BooleanBuffer::new(nulls.into(), 0, rows.len()), null_count); |
|
|
||
| if size > 0 { | ||
| min_offset = min_offset.min(offset); | ||
| max_end = max_end.max(end); |
There was a problem hiding this comment.
Maybe you can break if you reached maximum bounds (0 and maximum value that can be)
There was a problem hiding this comment.
done (although I wonder how often this is better in practice while adding an additional branch for a case that might happen incredibly rarely)
| #[test] | ||
| fn test_list_view() { | ||
| test_single_list_view::<i32>(); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_large_list_view() { | ||
| test_single_list_view::<i64>(); | ||
| } |
There was a problem hiding this comment.
Please add nested tests like the regular list
| test_nested_list::<i64>(); | ||
| } | ||
|
|
||
| fn test_single_list_view<O: OffsetSizeTrait>() { |
There was a problem hiding this comment.
Please add more tests that take advantage of the fact that this is a view, namely
- both list point to the same value.
- unordered offsets (one item is from offset x and some item after that is from offset y and y is before x)
- list 1 items cover list 2 items and a little more (e.g. list 1 offset is 10 and size 5 and list 2 offset is 12 and size 2).
There was a problem hiding this comment.
done (added all cases in one test let me know if you prefer separate tests)
arrow-row/src/lib.rs
Outdated
There was a problem hiding this comment.
Please add the list view and large list view to here as well similar to how list and large list are here.
don't forget to increase the random range so it will cover the new values
There was a problem hiding this comment.
this was a great idea, it actually caught something
|
@rluvaton thoughts on the assertion vs. returning an error? I don't feel too strongly one way or another, but I do think we should be consistent for both List and ListView. |
alamb
left a comment
There was a problem hiding this comment.
Could we also please update the documentation here with how ListView works:
It would help to review it more carefully
|
Added! (it's not different from Lists, but one wouldn't know that without already knowing the implementation, so I agree this was important!) |
consistent |
arrow-row and arrow-ord
arrow-row and arrow-ordarrow-row
| /// └──── 2_u8 ────┘ └──── 3_u8 ────┘ | ||
| /// | ||
| ///``` | ||
| /// |
| Ok(f) | ||
| } | ||
|
|
||
| fn compare_list_view<O: OffsetSizeTrait>( |
There was a problem hiding this comment.
While useful, I didn't see any test coverage for this code
I think we should either break it into its own PR, or add tests. Here is a PR to do so:
(I am also happy to review a separate PR)
There was a problem hiding this comment.
Merged, thank you!
I can't remember now anymore why it was, but I needed to implement compare support for something I needed for tests or fuzzing. Sorry, I've been working on so much lately that I don't remember anymore what exactly it was but it was needed to address other review comments.
There was a problem hiding this comment.
Sorry, I've been working on so much lately that I don't remember anymore what exactly it was
I TOTALLY understand
Add arrow-row tests
alamb
left a comment
There was a problem hiding this comment.
Thank you @brancz @rluvaton and @friendlymatthew
arrow-rowarrow-row and arrow-ord
|
I merged up to resolve a conflict. |
|
Thanks again everyone |
Which issue does this PR close?
Closes #9174
What changes are included in this PR?
Implementation and tests. It's mostly copied from
List.Are these changes tested?
Yes, see unit tests.
Are there any user-facing changes?
No, purely additive.
@alamb @Jefffrey