Skip to content

feat: ZstdDictionaryId value type + ZSTD_getDictID_fromDict#29

Merged
dfa1 merged 1 commit into
mainfrom
feat/dict-id
Jun 27, 2026
Merged

feat: ZstdDictionaryId value type + ZSTD_getDictID_fromDict#29
dfa1 merged 1 commit into
mainfrom
feat/dict-id

Conversation

@dfa1

@dfa1 dfa1 commented Jun 27, 2026

Copy link
Copy Markdown
Owner

What

  • Binds ZSTD_getDictID_fromDict as Zstd.dictId(byte[]) / Zstd.dictId(MemorySegment) — reads the dictionary id stamped in raw dictionary bytes via the core libzstd reader, without wrapping them in a ZstdDictionary.
  • Introduces ZstdDictionaryId, a record wrapping the 32-bit id with an unsigned value(), isPresent(), and a NONE sentinel for "no id".

Why a value type

zstd's dict id is a C unsigned (can exceed Integer.MAX_VALUE) and 0 is the magic "no dictionary" sentinel. An int hid both facts. ZstdDictionaryId makes the unsigned read (value()) and the absent case (NONE / isPresent()) explicit.

Scope — the whole id family

Every dictionary-id accessor now returns ZstdDictionaryId instead of int: ZstdDictionary.id(), ZstdCompressDict.id(), ZstdDecompressDict.id(), ZstdFrame.dictId(...), and the ZstdFrameHeader.dictId() component.

Tests

ZstdDictionaryIdTest (value type: unsigned widening, NONE, equality) + ZstdTest.DictIdLookup (reads stamped id, NONE for non-dict/short input, segment parity, heap rejection, agrees with ZstdDictionary.id()). 212 unit + 81 integration green, javadoc + checkstyle clean.

Notes

  • docs/supported.md: ZSTD_getDictID_fromDict now bound (Dictionary 10 → 11/23).
  • CHANGELOG.md Unreleased updated.

🤖 Generated with Claude Code

Adds Zstd.dictId(byte[]) / Zstd.dictId(MemorySegment), the core-libzstd reader
for the dictionary id stamped in raw dictionary bytes — the counterpart to
ZstdFrame.dictId (which reads a frame) and the no-wrapper alternative to
ZstdDictionary.id() (which uses the equivalent ZDICT reader). Binds
ZSTD_getDictID_fromDict.

Introduces ZstdDictionaryId, a record wrapping the 32-bit id with an unsigned
value(), isPresent(), and a NONE sentinel for "no id" (0). Every dictionary-id
accessor now returns it instead of int: ZstdDictionary.id(),
ZstdCompressDict.id(), ZstdDecompressDict.id(), ZstdFrame.dictId(...), and the
ZstdFrameHeader.dictId() component. This makes the unsigned semantics and the
0-means-absent sentinel explicit at every call site.

docs/supported.md: ZSTD_getDictID_fromDict now bound (Dictionary 10 -> 11/23).
CHANGELOG Unreleased updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dfa1 dfa1 merged commit 4cf8559 into main Jun 27, 2026
1 check passed
@dfa1 dfa1 deleted the feat/dict-id branch June 27, 2026 15:24
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