refactor: use raw view access in do_append_val_inner and consolidate duplicated logic#22907
Open
EeshanBembi wants to merge 1 commit into
Open
refactor: use raw view access in do_append_val_inner and consolidate duplicated logic#22907EeshanBembi wants to merge 1 commit into
EeshanBembi wants to merge 1 commit into
Conversation
…duplicated logic Refactor `ByteViewGroupValueBuilder::do_append_val_inner` to read raw u128 views via `get_unchecked` instead of decoding through `array.value(row)` and re-encoding via `make_view()`. For inline strings (len <= 12) the view is pushed as-is; for non-inline strings the source prefix is reused directly. This also removes the duplicated slow-path logic in `vectorized_append_inner`, which now delegates to `do_append_val_inner` after pre-reserving capacity. The unused `make_view` import is removed.
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?
Follow-up to #21794, addressing review feedback from @alamb and @Dandandan.
Rationale for this change
In the review of #21794, several optimizations were suggested:
get_uncheckedhere if it makes any difference" — referring to the slow-patharr.views()[row]access.extend+ reuse input view (instead of make_view) + avoidarray.value(row)"What changes are included in this PR?
1. Refactored
do_append_val_innerto use raw view accessReplaced
array.value(row)+make_view()with raw view access viaget_unchecked(row):ByteView::from(view), copy buffer data, reuse source prefix directly (avoids re-reading first 4 bytes)2. Simplified the vectorized slow path
Replaced the duplicated 28-line loop body in
vectorized_append_innerwithtry_reserve+ a loop callingdo_append_val_inner, eliminating code duplication.3. Removed unused
make_viewimportSafety notes
get_uncheckedusage: Consistent withdo_equal_to_inner(same file) andPrimitiveGroupValueBuilderinprimitive.rs, both of which use the same pattern. All callers derive row indices from enumeration over the input array length, guaranteeing validity.data_buffers()is empty, all views must have len <= 12 (Arrow invariant), so the non-inline branch is never entered.Are these changes tested?
Covered by 6 existing unit tests in the
bytes_viewmodule plus 3 integration tests in themulti_group_bymodule. All 111 tests in the aggregates suite pass.Are there any user-facing changes?
No. This is an internal refactor with no API changes.