chore: use new OffsetBuffer::subtract helper#23424
Open
rluvaton wants to merge 3 commits into
Open
Conversation
rluvaton
commented
Jul 9, 2026
Comment on lines
-1239
to
-1248
| if let (Some(first), Some(last)) = (offsets.first(), offsets.last()) | ||
| && (!first.is_zero() || last.as_usize() != list.values().len()) | ||
| { | ||
| let offsets = offsets.iter().map(|offset| *offset - *first).collect(); | ||
|
|
||
| //todo: use unsafe Offset::new_unchecked? | ||
| return OffsetBuffer::new(offsets); | ||
| } | ||
|
|
||
| offsets.clone() |
Member
Author
There was a problem hiding this comment.
Even though this code has last != list.values().len() and the subtract doesn't have that check, that check is not needed as we don't use the last values at all
xudong963
reviewed
Jul 10, 2026
| } | ||
|
|
||
| offsets.clone() | ||
| offsets.clone().subtract(offsets[0]) |
Member
There was a problem hiding this comment.
For a prefix slice where the first offset is zero but the last visible offset is before the end of the original child values, subtract(0) returns a clone sharing the original allocation. The previous
Implementation created a compact offset buffer in this case.
Member
Author
There was a problem hiding this comment.
Yes, I'm willing to sacrifice that in favor of avoiding copy and because this was not guaranteed
xudong963
reviewed
Jul 10, 2026
xudong963
left a comment
Member
There was a problem hiding this comment.
Other places look good to me
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
N/A
Rationale for this change
Replace manually written code with the newly added helper I added to arrow-rs in:
OffsetBuffer::subtractto allow to shift offsets by value arrow-rs#10120What changes are included in this PR?
use
OffsetBuffer::subtractAre these changes tested?
Existing tests
Are there any user-facing changes?
No