Skip to content

feat(theta): add theta union#145

Open
ZENOTME wants to merge 5 commits into
apache:mainfrom
ZENOTME:codex/union
Open

feat(theta): add theta union#145
ZENOTME wants to merge 5 commits into
apache:mainfrom
ZENOTME:codex/union

Conversation

@ZENOTME

@ZENOTME ZENOTME commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add stateful ThetaUnion and builder
  • export ThetaUnion from the theta module
  • add union coverage for exact, estimation, compact, seed mismatch, ordering, reset, and edge states

Tests

  • cargo test -p datasketches --features theta

Comment thread datasketches/src/theta/union.rs Outdated

let ordered = ordered || (entries.len() == 1 && theta == MAX_THETA);

if ordered && entries.len() > 1 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

seems no need check with entries.len() > 1, sort_unstable() no-op on single element array.

@ariesdevil ariesdevil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rest LGTM.

@tisonkun tisonkun 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.

Generally LGTM. Some follow-up suggestions inline, and:

I may prefer to name result/result_with_order to to_sketch as we do for the CpcSketch and HllSketch. Also, we may not need to have two methods but only one with a ordered param.

This is a breaking change since we already use the result_with_order API in ThetaIntersection, but it should be worthy to do the refactor.

ThetaUnionBuilder::default()
}

/// Update this union with a given sketch.

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.

Later we may review all seed_hash != seed_hash checks and add # Errors document.

@tisonkun

Copy link
Copy Markdown
Member

Now that #146 is merged. We may merge this as well.

Is there any logical conflict that should be resolved beforehand?

@ZENOTME

ZENOTME commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Now that #146 is merged. We may merge this as well.

Is there any logical conflict that should be resolved beforehand?

Yes. Let me covert it as a generic version.

@ZENOTME
ZENOTME requested review from ariesdevil and tisonkun July 10, 2026 17:05

@tisonkun tisonkun 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.

Thanks for your updates!

I'll go through all these changes and perhaps push a few commits to handle visibility issues.

Hopefully in days, but may be delay to next weekend.

use crate::theta_common::hash_table::RawHashTableEntry;

pub(crate) mod private {
pub(crate) trait Sealed {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BTW: As @tisonkun mentioned on X, pub impl(crate) trait Foo {} just landed in nightly version; maybe we can use this feature?

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 crate is a library and we should stay on stable toolchain. And we have an MSRV of 1.86.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Make sense.

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