refactor(decode): extract shared FastLanes unpack schedule in BitpackedEncodingDecoder#140
Merged
Merged
Conversation
The arena parameter is contractual: this base method implements Array#materialize(SegmentAllocator) for the leaf Materialized* classes, which implement the sealed Array interface directly. Sonar cannot see the override because the base class is not itself declared to implement Array, so it flagged arena as an unused parameter. The parameter must stay to satisfy the interface; suppress with an explanatory reason instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…edEncodingDecoder The four unpackLoop8/16/32/64 methods each rebuilt an identical per-row schedule (shifts, remaining/current bits, lo/hi masks, current/next word byte bases, transposed output offsets), differing only by typeBits and element width. Sonar flagged the four ~24-line setup blocks as duplication. Hoist that cold, run-once precompute into an UnpackSchedule record built by schedule(typeBits, bitWidth), which derives lanes (1024/typeBits) and elemBytes (typeBits/8) internally. Each loop now calls schedule(N, bitWidth) and aliases the arrays. The per-element inner unpack loops stay specialised per width on purpose: a generic ValueLayout/accessor would stop C2 from constant-folding the typed access and block superword vectorisation (hot-loop rule). Only the cold setup is shared, so there is no hot-path change. Verified: 120 round-trip decode tests (all widths + patches) and 107 encoder tests pass; reactor build + build-enforced javadoc clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What
The four
unpackLoop8/16/32/64methods each rebuilt an identical per-row schedule (shifts, remaining/current bits, lo/hi masks, current/next word byte bases, transposed output offsets), differing only bytypeBitsand element width. Sonar flagged the four ~24-line setup blocks as duplication.Hoisted that cold, run-once precompute into an
UnpackSchedulerecord built byschedule(typeBits, bitWidth), which deriveslanes = 1024/typeBitsandelemBytes = typeBits/8internally. Each loop now callsschedule(N, bitWidth)and aliases the arrays. ~80 duplicated lines collapse to one method.What is deliberately NOT collapsed
The per-element inner unpack loops stay specialised per width. A generic
ValueLayout/accessor would stop C2 from constant-folding the typed access and block superword vectorisation (hot-loop rule). Only the cold, run-once setup is shared — no hot-path change.Verification
@params) — clean🤖 Generated with Claude Code