Skip to content

Fix theta preamble count for legacy single-item images - #774

Merged
leerho merged 1 commit into
apache:mainfrom
jaideeppyne:fix/theta-preamble-legacy-single-item
Oct 1, 2026
Merged

leerho merged 1 commit into
apache:mainfrom
jaideeppyne:fix/theta-preamble-legacy-single-item

Conversation

@jaideeppyne

Copy link
Copy Markdown
Contributor

Closes #773.

Historical C++ theta single-item images may omit the optional single-item flag. Java accepts these images, but PreambleUtil.preambleToString() previously derived the implied count from that flag and displayed CurrentCount: 0.

This change derives the one-preamble-long count from the authoritative empty flag while continuing to display the serialized single-item flag unchanged.

The regression test clears only the flag on a valid single-item image and verifies:

  • SINGLE_ITEM: false accurately reflects the historical bytes
  • CurrentCount: 1 accurately reflects the retained item

Validation:

  • mvn -t /private/tmp/jdk25-toolchains.xml -Dtest=org.apache.datasketches.theta.PreambleUtilTest test (8 tests)
  • mvn -t /private/tmp/jdk25-toolchains.xml test (2,287 tests)
  • git diff --check

@leerho leerho left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This correctly fixes the preambleToString() single-item/empty count logic from issue #460—the one-line change is sound, CI passes, and the test properly validates the bug fix,

@leerho
leerho merged commit 059b5a9 into apache:main Oct 1, 2026
6 checks passed
tisonkun pushed a commit to apache/datasketches-tck that referenced this pull request Oct 4, 2026
* Track .sk snapshots even when a global gitignore excludes them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: update Java snapshots to datasketches-java main (059b5a9)

Move the Java snapshot pin from 3a1bf7f to 059b5a9, the merge of
apache/datasketches-java#774, and regenerate the Java snapshots.

Deterministic changes:
- HLL_6 and HLL_8 compact images set the compact flag (java#761).
- Empty tuple and AoS compact images write a zero seed hash.
- Adds frequent_long_purged and frequent_string_purged (java#770).

All other modifications are probabilistic snapshots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: update C++ snapshots to datasketches-cpp master (16d4ea6)

Move the C++ snapshot pin from fe0261a to 16d4ea6 and regenerate the
C++ snapshots.

Deterministic changes:
- Single-item compact theta images set the single-item flag (cpp#526).
- Adds frequent_long_purged and frequent_string_purged (cpp#529).
- Removes the 27 aos_*_cpp.sk snapshots: the C++ array-of-strings tuple
  sketch was reverted (cpp#537) because its key hashing is incompatible
  with Java (cpp#533).

All other modifications are probabilistic snapshots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

Theta preamble diagnostic misreports historical single-item images

2 participants