Skip to content

fix: align empty Theta and Tuple seed hash handling - #283

Merged
tisonkun merged 7 commits into
apache:mainfrom
tisonkun:codex/empty-sketch-seed-hash
Sep 29, 2026
Merged

tisonkun merged 7 commits into
apache:mainfrom
tisonkun:codex/empty-sketch-seed-hash

Conversation

@tisonkun

@tisonkun tisonkun commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Empty compact Theta and Tuple sketches currently serialize their configured seed hash, so the empty image depends on its seed. Reading an empty image also exposes the stored fingerprint instead of the caller's, and legacy Theta v2 rejects empty images with zero or mismatched seed hashes.

Use canonical 8-byte images with a zero seed hash for empty serialization, including Theta's compressed fallback. Empty deserialization associates the result with the supplied seed; for example, reading the same empty bytes with seed 123 or 456 gives the corresponding in-memory fingerprint. Non-empty sketches still require a matching seed, including sampled sketches with no retained entries.

This aligns the wire encoding with apache/datasketches-java#772 and empty-v2 acceptance with Java's legacy reader. Rust objects retain the caller's seed fingerprint rather than Java's zero-valued empty-object fingerprint.

Validation:

  • Compare custom-seed empty output against the pinned C++ snapshots and check caller-seed association for zero and mismatched stored hashes.
  • Port the three empty-v2 layouts from Java's ForwardCompatibilityTest.
  • Verify that sampled, non-empty sketches with no retained entries preserve theta and still reject seed mismatches.
  • cargo x check, cargo x test, and cargo x lint.

@tisonkun tisonkun changed the title fix: write zero seed hashes for empty Theta and Tuple sketches fix: align empty Theta and Tuple seed hash handling Sep 29, 2026
@tisonkun
tisonkun merged commit cf25bbe into apache:main Sep 29, 2026
10 checks passed
@tisonkun
tisonkun deleted the codex/empty-sketch-seed-hash branch September 29, 2026 15:23
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