Compact run buffer slice values - #10292
Conversation
| "the length + offset of the sliced RunEndBuffer cannot exceed the existing length" | ||
| ); | ||
| Self { | ||
| let logical_offset = self.logical_offset + logical_offset; |
There was a problem hiding this comment.
cc @Rich-T-kid this is what i was thinking on my previous comments on your PR
essentially we can still reduce how many physical values we hold on to, without needing to readjust all of the values (still keeping it zero-copy)
we'd need to extend it to runarray too since need to ensure the values array is similarly compacted (might need a bit of plumbing to make it work) and as noted in the issue callsites may need to be adjusted
lemme know your thoughts
|
will take a look this afternoon! |
| // [B, B, B, B, B, B, {B, B, C, C, C, C}] | ||
| let slice = buffer.slice(6, 6); | ||
| assert_eq!(slice.len(), 6); | ||
| assert_eq!(slice.offset(), 6); |
There was a problem hiding this comment.
i realized my initial version of the PR incorrectly adjusted the offset when that wasnt needed; by removing the first physical value its as if the first run was consumed by the following run since we always list run lengths; that is
[4, 8] -> AAAABBBB
[8] -> {BBBB}BBBB
- where
{BBBB}used to be a separate run but is now folded into the first run; this shouldnt matter as our logical offset points beyond it anyway
|
Going to review this PR this week 👍 |
Rich-T-kid
left a comment
There was a problem hiding this comment.
@Jefffrey I took a look an im a bit confused. Im going to go through RunEndbuffer to refresh my knowledge. If you get a chance could you add a test similar to what we found in #9959 (comment). This way we validate that the slice gives us what we expect.
will try to give a more insightful review tomorrow
ill look into this; i didnt touch |
Jefffrey
left a comment
There was a problem hiding this comment.
another thought i had is if we enforce this strictly (e.g. in all construction & validation methods) it can lead to simpler code; for example, values_slice() would become deprecated since it would be the same as values()
arrow-rs/arrow-array/src/array/run_array.rs
Lines 269 to 280 in 707872f
and get_start_physical_index()/get_end_physical_index() can be simplified to always getting 0/len - 1 if we know the run ends buffer strictly keeps only needed physical values, essentially skipping the binary search
arrow-rs/arrow-buffer/src/buffer/run.rs
Lines 242 to 267 in 707872f
| @@ -1364,33 +1397,32 @@ mod tests { | |||
|
|
|||
| #[test] | |||
| fn test_run_array_values_slice() { | |||
There was a problem hiding this comment.
can reference this test to see how the physical values change underneath as we slice
Which issue does this PR close?
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?