Skip to content

refactor: dedupe narrowest-unsigned-ptype selection into one helper#273

Merged
dfa1 merged 1 commit into
mainfrom
refactor/dedupe-narrowest-ptype
Jul 17, 2026
Merged

refactor: dedupe narrowest-unsigned-ptype selection into one helper#273
dfa1 merged 1 commit into
mainfrom
refactor/dedupe-narrowest-ptype

Conversation

@dfa1

@dfa1 dfa1 commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Three writer-side encoders (BitpackedEncodingEncoder, SparseEncodingEncoder, FsstEncodingEncoder) each hand-rolled byte-for-byte identical logic to pick the narrowest unsigned PType (U8/U16/U32) fitting a value — flagged in review of Raincloud triage round 268 269 #271.
  • Extracted to PType.narrowestUnsigned(long), matching the enum's existing static-factory/classification idiom (fromOrdinal, isUnsigned). All 5 call sites now delegate; the three private duplicates are deleted.

Test plan

  • ./mvnw test -pl core,writer -am — BUILD SUCCESS, 1702 tests, 0 failures
  • ./mvnw verify -pl core,writer -am -DskipITs — BUILD SUCCESS (checkstyle-bound run)
  • ./mvnw javadoc:javadoc -pl core — zero warnings on the new method
  • Boundary tests added to PTypeTest (0, 0xFF, 0x100, 0xFFFF, 0x10000, 0xFFFFFFFF)

🤖 Generated with Claude Code

Three writer-side encoders each hand-rolled byte-for-byte identical logic
to pick the narrowest unsigned PType (U8/U16/U32) that fits a non-negative
value: BitpackedEncodingEncoder.chooseIdxPtype, SparseEncodingEncoder.
chooseIdxPtype, and FsstEncodingEncoder.narrowestUnsignedPType. A future
tiering change (e.g. a U64 tier) would have to touch three sites and could
silently drift.

Extract once as PType.narrowestUnsigned(long), matching the enum's existing
static-factory/classification idiom (fromOrdinal, isUnsigned). The long
parameter accepts all current int call sites unchanged and leaves room for
a wider tier. Delete the three private duplicates; all five call sites now
delegate. Boundary tests (0, 0xFF, 0x100, 0xFFFF, 0x10000, 0xFFFFFFFF) added
to PTypeTest.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dfa1
dfa1 merged commit 7af2a78 into main Jul 17, 2026
6 checks passed
@dfa1
dfa1 deleted the refactor/dedupe-narrowest-ptype branch July 18, 2026 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant