Visitar URL original
Tuple: add PreambleUtil documenting the serialized forms by leerho · Pull Request #784 · apache/datasketches-java · GitHub
Skip to content

Tuple: add PreambleUtil documenting the serialized forms - #784

Merged
leerho merged 2 commits into
mainfrom
tuple-preamble-util
Oct 30, 2026
Merged

leerho merged 2 commits into
mainfrom
tuple-preamble-util

Conversation

@leerho

@leerho leerho commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary

The tuple package had no single place that documents its serialized forms. This PR adds tuple/PreambleUtil.java, following the style of theta/PreambleUtil. It documents:

  • CompactTupleSketch, serial version 3 (current): the 1, 2 and 3 preamble-long cases. This form is binary compatible with C++ and Go.
  • CompactTupleSketch, serial versions 1 and 2 (legacy, read only).
  • QuickSelectSketch (updatable), serial version 2. This form is deprecated, has no seed hash, and only Java reads it.
  • The flags byte of each form.
  • How entries and Summaries are laid out. The image does not record the Summary type.
  • The encodings of the example Summaries (DoubleSummary, IntegerSummary and ArrayOfStringsSummary), which are specific to Java.

It also adds constants for the byte addresses and serial versions. The ArrayOfDoubles layouts are documented in their own classes and are out of scope.

A second commit switches CompactTupleSketch and QuickSelectSketch to the new constants, for the fixed preamble fields and the serial versions. The optional, packed fields of the legacy compact and updatable forms still use a running offset, starting at the address PreambleUtil documents. SerializerDeserializer.TYPE_BYTE_OFFSET now refers to PreambleUtil.SKETCH_TYPE_BYTE.

No behavior change: the serialized bytes are unchanged, and the current and historical (serial versions 1 and 2) cross-language images still deserialize.

Verification

mvn verify passes (2302 tests), including javadoc and style checks. TupleCrossLanguageTest passes for the Java, C++ and Go files and for the historical files.

🤖 Generated with Claude Code

Documents the compact (serial version 3 and legacy 1, 2) and updatable
(QuickSelectSketch) layouts, the flags byte of each form, and the encodings
of the example Summaries, in one place, following theta's PreambleUtil.
Adds the byte-address and serial-version constants. No behavior change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leerho
leerho requested review from proost and tisonkun October 29, 2026 20:37
CompactTupleSketch and QuickSelectSketch now read and write the fixed
preamble fields (preamble longs, serial version, family, sketch type,
flags, seed hash, retained entries, theta, lgNom, lgCur, lgRF) at the
PreambleUtil addresses, and use its serial-version constants instead of
their own private copies. The optional, packed fields of the legacy compact
form and of the updatable form still use a running offset, which starts at
the address PreambleUtil documents. SerializerDeserializer's type-byte
offset now refers to PreambleUtil.SKETCH_TYPE_BYTE.

No change to the serialized bytes. The current and historical
cross-language images still deserialize.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leerho
leerho merged commit c72159a into main Oct 30, 2026
6 checks passed
@leerho
leerho deleted the tuple-preamble-util branch October 30, 2026 17:39
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.

3 participants