Skip to content

Add suport for wrapped_compact_tuple_sketch - #520

Open
SavicStefan wants to merge 1 commit into
apache:masterfrom
SavicStefan:wrapped_tuple
Open

Add suport for wrapped_compact_tuple_sketch#520
SavicStefan wants to merge 1 commit into
apache:masterfrom
SavicStefan:wrapped_tuple

Conversation

@SavicStefan

@SavicStefan SavicStefan commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds wrapped_compact_tuple_sketch, a non-owning view over a
serialized compact tuple sketch. It follows the same model as
wrapped_compact_theta_sketch: callers can use a serialized sketch without
materializing all retained entries in an owning vector.

How it works

  • wrap() validates the header, sketch type, family, seed hash, metadata,
    and complete serialized payload.
  • The wrapper stores parsed metadata and pointers to the entry range. The
    caller must keep the serialized buffer alive.
  • Its input iterator deserializes one {hash, summary} entry at a time into
    aligned in-place storage.
  • A common base_tuple_sketch provides APIs shared by materialized and
    wrapped_compact_tuple_sketch.
  • Compact sketch construction and tuple set operations can consume the
    wrapped representation.

This avoids memory use proportional to the retained-entry count. Fixed-
width summaries require no heap storage for entries. Variable-width
summaries, such as strings, may still allocate internally, but the wrapper
materializes only one entry at a time.

Tests

Tests cover:

  • Empty, exact-mode, and estimation-mode sketches
  • Variable-width summaries
  • Malformed, truncated, and trailing input
  • Tuple set operations
  • Allocation-free iteration for fixed-width summaries

Signed-off-by: Stefan Savić <stefan.savic@databricks.com>
@SavicStefan

Copy link
Copy Markdown
Contributor Author

@apache/datasketches-committers
Hi guys, what do you think about this API change for the tuple sketch, this is match theta sketch impl? Thank you.

P.S Sorry for not doing this properly via mailing list, but I saw in last PR that no one responded via it.

@SavicStefan
SavicStefan marked this pull request as ready for review September 2, 2026 18: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.

1 participant