You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@datasketches.apache.org by "ZENOTME (via GitHub)" <gi...@apache.org> on 2026/07/19 03:43:01 UTC
[PR] WIP: encapsulate read-only Theta sketch views (datasketches-rust)
ZENOTME opened a new pull request, #151:
URL: https://github.com/apache/datasketches-rust/pull/151
## Summary
- keep RawThetaSketchView crate-private while preserving the raw algorithm abstraction
- add a transparent ThetaSketchView<V> that can only be created by supported sketches
- expose the six read-only view methods and accept views in Theta union/intersection
- add reference forwarding plus From conversions for mutable and compact Theta sketches
## Validation
- cargo test -p datasketches --features theta
- cargo clippy --workspace --all-features --all-targets -- -D warnings
- RUSTDOCFLAGS="-D warnings" cargo doc -p datasketches --features theta --no-deps
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For additional commands, e-mail: dev-help@datasketches.apache.org
Re: [PR] refactor: encapsulate read-only Theta sketch views (datasketches-rust)
Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on code in PR #151:
URL: https://github.com/apache/datasketches-rust/pull/151#discussion_r3615913118
##########
datasketches/src/theta/intersection.rs:
##########
@@ -61,7 +63,12 @@ impl ThetaIntersection {
/// The intersection can be viewed as starting from the "universe" set,
/// and every update can reduce the current set to leave the overlapping
/// subset only.
- pub fn update<S: ThetaSketchView>(&mut self, sketch: &S) -> Result<(), Error> {
+ #[allow(private_bounds)]
+ pub fn update<V>(&mut self, sketch: ThetaSketchView<V>) -> Result<(), Error>
+ where
+ V: RawThetaSketchView<ThetaEntry>,
+ {
Review Comment:
To avoid trait here, we can use enum to dispatch.🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For additional commands, e-mail: dev-help@datasketches.apache.org
Re: [PR] refactor: encapsulate read-only Theta sketch views (datasketches-rust)
Posted by "ZENOTME (via GitHub)" <gi...@apache.org>.
ZENOTME commented on code in PR #151:
URL: https://github.com/apache/datasketches-rust/pull/151#discussion_r3650418071
##########
datasketches/src/theta/intersection.rs:
##########
@@ -61,7 +63,12 @@ impl ThetaIntersection {
/// The intersection can be viewed as starting from the "universe" set,
/// and every update can reduce the current set to leave the overlapping
/// subset only.
- pub fn update<S: ThetaSketchView>(&mut self, sketch: &S) -> Result<(), Error> {
+ #[allow(private_bounds)]
+ pub fn update<V>(&mut self, sketch: ThetaSketchView<V>) -> Result<(), Error>
+ where
+ V: RawThetaSketchView<ThetaEntry>,
+ {
Review Comment:
Another way is to export using new trait like `TupleSketchView`. We don't need to test it, and it can be sealed::Sealed. And thetacommon can internal and not export to user.
```
pub trait TupleSketchView<S>: sealed::Sealed {
/// Return the 16-bit seed hash.
fn seed_hash(&self) -> u16;
/// Return theta as a `u64` threshold.
fn theta(&self) -> u64;
/// Return whether this sketch has not received any updates.
fn is_empty(&self) -> bool;
/// Return whether retained entries are ordered by ascending hash.
fn is_ordered(&self) -> bool;
/// Return an iterator over retained entries.
fn iter(&self) -> impl Iterator<Item = TupleEntry<S>> + '_;
/// Return the number of retained entries.
fn num_retained(&self) -> usize;
}
impl<S, T> RawThetaSketchView<TupleEntry<S>> for T
where
T: TupleSketchView<S> + ?Sized,
{
fn seed_hash(&self) -> u16 {
TupleSketchView::seed_hash(self)
}
fn theta(&self) -> u64 {
TupleSketchView::theta(self)
}
fn is_empty(&self) -> bool {
TupleSketchView::is_empty(self)
}
fn is_ordered(&self) -> bool {
TupleSketchView::is_ordered(self)
}
fn iter(&self) -> impl Iterator<Item = TupleEntry<S>> + '_ {
TupleSketchView::iter(self)
}
fn num_retained(&self) -> usize {
TupleSketchView::num_retained(self)
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For additional commands, e-mail: dev-help@datasketches.apache.org
Re: [PR] refactor: encapsulate read-only Theta sketch views (datasketches-rust)
Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun closed pull request #151: refactor: encapsulate read-only Theta sketch views
URL: https://github.com/apache/datasketches-rust/pull/151
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For additional commands, e-mail: dev-help@datasketches.apache.org
Re: [PR] refactor: encapsulate read-only Theta sketch views (datasketches-rust)
Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on code in PR #151:
URL: https://github.com/apache/datasketches-rust/pull/151#discussion_r3615806550
##########
datasketches/src/theta/intersection.rs:
##########
@@ -61,7 +63,12 @@ impl ThetaIntersection {
/// The intersection can be viewed as starting from the "universe" set,
/// and every update can reduce the current set to leave the overlapping
/// subset only.
- pub fn update<S: ThetaSketchView>(&mut self, sketch: &S) -> Result<(), Error> {
+ #[allow(private_bounds)]
+ pub fn update<V>(&mut self, sketch: ThetaSketchView<V>) -> Result<(), Error>
+ where
+ V: RawThetaSketchView<ThetaEntry>,
+ {
Review Comment:
This would make the document of `update` cannot linked to `RawThetaSketchView` and remain a dead link on docs.rs.
Let me think of how to expose the symbols here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For additional commands, e-mail: dev-help@datasketches.apache.org
Re: [PR] refactor: encapsulate read-only Theta sketch views (datasketches-rust)
Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on PR #151:
URL: https://github.com/apache/datasketches-rust/pull/151#issuecomment-5091083128
@ariesdevil You refactor the related interfaces in this PR in #166 .
I suggest you can discuss with @ZENOTME to see whether or not these `thetacommon` traits should be sealed and how to settle down a proper design.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For additional commands, e-mail: dev-help@datasketches.apache.org