Skip to content

refactor: FsstEncodingEncoder reuses PTypeIO.set instead of reimplementing it - #274

Merged
dfa1 merged 1 commit into
mainfrom
refactor/fsst-reuse-ptypeio
Jul 17, 2026
Merged

refactor: FsstEncodingEncoder reuses PTypeIO.set instead of reimplementing it#274
dfa1 merged 1 commit into
mainfrom
refactor/fsst-reuse-ptypeio

Conversation

@dfa1

@dfa1 dfa1 commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • FsstEncodingEncoder.writeUnsigned duplicated core.io.PTypeIO.set, the canonical narrow-ptype write helper already used by every other encoder (RleEncodingEncoder, BitpackedEncodingEncoder, SparseEncodingEncoder, etc.) — flagged in review of Raincloud triage round 268 269 #271.
  • Deleted writeUnsigned; both call sites now pass idx * ptype.byteSize() as the byte offset to PTypeIO.set directly. Its default -> throw branch was dead code (PType.narrowestUnsigned only ever returns U8/U16/U32).

Test plan

  • ./mvnw test -pl writer -am -Dtest=FsstEncodingEncoderTest — passed
  • ./mvnw test -pl writer -am — full writer module, 1702 tests, 0 failures

🤖 Generated with Claude Code

…nting it

The private writeUnsigned helper duplicated core.io.PTypeIO.set, the
canonical narrow-ptype write helper (MethodHandle-based, byte-offset
addressed, already used by every other encoder). Its default branch
throwing VortexException was dead: narrowestUnsigned only ever returns
U8/U16/U32, all of which PTypeIO.set handles with identical
little-endian layout and truncation-on-narrowing. Deleted writeUnsigned
and the now-unused VortexException import; the two call sites now pass
idx * ptype.byteSize() as the byte offset, matching the established
PTypeIO.set idiom.

Also close a round-trip coverage gap this refactor's own risk surface
exposed: every stringArrays() case kept uncompLenPType/codesOffPType in
the U8 tier, so the U16 length/offset write path was only checked via
metadata assertions, never a full decode. Add a 301-row u16-tier case
(one 300-byte row plus 300 single-char rows) that goes through
encode_thenDecode_roundtripsAllStrings, so the U16 buffer bytes are read
back and verified per row -- a wrong U16 stride now corrupts many rows
and fails the assertion. A metadata test pins that both ptypes escalate.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dfa1
dfa1 force-pushed the refactor/fsst-reuse-ptypeio branch from b92abe1 to ea01579 Compare July 17, 2026 13:17
@dfa1
dfa1 merged commit 218c72f into main Jul 17, 2026
6 checks passed
@dfa1
dfa1 deleted the refactor/fsst-reuse-ptypeio 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