tisonkun opened a new issue, #365:
URL: https://github.com/apache/datasketches-rust/issues/365
## Summary
Inspector methods for stream counts/weights, retained entries, and observed
extrema currently use differing names across sketch families. Standardizing
these conventions before 1.0 reduces cognitive friction when switching between
sketches.
## Current State
| Metric | Sketch Family / Type
| Current Signature | Module
|
| --------------------- | -------------------------------------------------
| -------------------------------------------------------------------- |
-------------------------------------------------- |
| Stream count / weight | `KllSketch<T>`, `ReqSketch<T>`
| `n(&self) -> u64` |
`datasketches/src/{kll,req}/sketch.rs` |
| Stream count / weight | `kll::SortedView<T>`, `req::SortedView<T>`
| `total_weight(&self) -> u64` |
`datasketches/src/{kll,req}/sorted_view.rs` |
| Stream count / weight | `FrequentItemsSketch<T>`, `TDigestMut`, `TDigest`
| `total_weight(&self) -> u64` |
`datasketches/src/{frequencies,tdigest}/sketch.rs` |
| Stream count / weight | `CountMinSketch<T>`
| `total_weight(&self) -> T` |
`datasketches/src/countmin/sketch.rs` |
| Retained entries | `KllSketch<T>`, `ReqSketch<T>`
| `num_retained(&self) -> usize` |
`datasketches/src/{kll,req}/sketch.rs` |
| Retained entries | `Theta*` / `Tuple*` sketches and views
| `num_retained(&self) -> usize` |
`datasketches/src/thetafamily/` |
| Retained entries | `FrequentItemsSketch<T>`
| `num_active_items(&self) -> usize` |
`datasketches/src/frequencies/sketch.rs` |
| Retained entries | `TDigestMut`, `TDigest`
| None (`Debug` exposes `num_centroids` / buffered counts) |
`datasketches/src/tdigest/sketch.rs` |
| Retained entries | `kll::SortedView<T>`, `req::SortedView<T>`
| `len(&self) -> usize` |
`datasketches/src/{kll,req}/sorted_view.rs` |
| Extrema | `KllSketch<T>`, `ReqSketch<T>`
| `min_item(&self) -> Option<&T>`, `max_item(&self) -> Option<&T>` |
`datasketches/src/{kll,req}/sketch.rs` |
| Extrema | `TDigestMut`, `TDigest`
| `min_value(&self) -> Option<f64>`, `max_value(&self) -> Option<f64>` |
`datasketches/src/tdigest/sketch.rs` |
Note that `BloomFilter::bits_used(&self) -> u64` and
`BloomFilter::capacity(&self) -> u64` (`datasketches/src/bloom/filter.rs`)
reflect bitset-specific metrics rather than retained items.
## 0.8.0–1.0 Alignment Recommendation
1. **Retained entries (`num_retained(&self) -> usize`)**: Standardize
sketch-level retained-entry getters on `num_retained(&self) -> usize`:
- Rename `FrequentItemsSketch::num_active_items` to `num_retained`
(keeping a short deprecation window if appropriate for minor releases, or
changing cleanly in a 0.8.0 breaking release).
- Add `num_retained(&self) -> usize` (or evaluate whether
`TDigest`/`TDigestMut` should expose `num_centroids` vs `num_retained`) on
`TDigest` and `TDigestMut` so callers can inspect retained centroid counts
outside `fmt::Debug` (returning `self.buffer.len()` on `TDigestMut` and
`self.centroids.len()` on `TDigest`).
- Keep `SortedView::len(&self) -> usize` as idiomatic slice-like view
length.
2. **Stream count vs weight (`n()` vs `total_weight()`)**: Decide cleanly
between two paths before 1.0:
- **Recommended**: Converge on `total_weight(&self) -> u64` across
unweighted and weighted distribution/frequency sketches (aligning `KllSketch`
and `ReqSketch` with `kll::SortedView::total_weight`,
`req::SortedView::total_weight`, `FrequentItemsSketch::total_weight`, and
`TDigest`/`TDigestMut::total_weight`), while keeping
`CountMinSketch::<T>::total_weight(&self) -> T` returning `T` because
`CountMinSketch` supports signed weights and decay/halving scaling.
- **Alternative**: Keep `n(&self) -> u64` strictly for unweighted item
counts and `total_weight` strictly for weighted/scaled streams, and explicitly
document that distinction in `CONTRIBUTING.md` (note that `kll::SortedView` and
`req::SortedView` currently expose `total_weight()` even though their parent
sketches expose `n()`).
3. **Extrema (`min_item`/`max_item` vs `min_value`/`max_value`)**: Decide
whether to keep `min_item`/`max_item -> Option<&T>` on generic item sketches
(`KllSketch<T>`, `ReqSketch<T>`) and `min_value`/`max_value -> Option<f64>` on
`f64`-only `TDigest`/`TDigestMut` (matching `update(item: T)` vs `update(value:
f64)`), or unify both families on one pair before 1.0. Keeping generic `*_item`
for `T` sketches vs `*_value` for `f64` digests is idiomatic unless a shared
quantile abstraction favors identical method names.
4. **Documentation**: Record the finalized naming conventions in
`CONTRIBUTING.md` and document any breaking renames in `CHANGELOG.md`.
## Acceptance Criteria
- Consistent naming rules for count/weight, retained entries, and extrema
getters are agreed upon and documented in `CONTRIBUTING.md`.
- Target sketches are updated cleanly with unit/integration test coverage
and `CHANGELOG.md` entries for any breaking method renames or additions.
- `cargo x check`, `cargo x test`, and `cargo x lint` pass.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]