This is an automated email from the ASF dual-hosted git repository. tisonkun pushed a commit to branch codex/kll-api-and-performance in repository https://gitbox.apache.org/repos/asf/datasketches-rust.git
commit 28a74d275070b619a2d8843f61afd7cb910b6679 Author: tison <[email protected]> AuthorDate: Wed Sep 2 12:06:12 2026 +0800 refactor(kll): minimize public configuration API --- datasketches/src/kll/mod.rs | 17 ++++------------- datasketches/src/kll/sketch.rs | 4 ++-- tests-integration/tests/kll_test/sketch.rs | 6 +++--- tests-integration/tests/serde_tests/kll.rs | 3 ++- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/datasketches/src/kll/mod.rs b/datasketches/src/kll/mod.rs index d87da0e..c98a931 100644 --- a/datasketches/src/kll/mod.rs +++ b/datasketches/src/kll/mod.rs @@ -46,20 +46,11 @@ pub use self::sketch::KllItem; pub use self::sketch::KllSketch; pub use self::sketch::NaturalOrder; -/// KLL sketch specialized for `f64`. -pub type KllSketchF64<C = NaturalOrder> = KllSketch<f64, C>; -/// KLL sketch specialized for `f32`. -pub type KllSketchF32<C = NaturalOrder> = KllSketch<f32, C>; -/// KLL sketch specialized for `i64`. -pub type KllSketchI64<C = NaturalOrder> = KllSketch<i64, C>; -/// KLL sketch specialized for `String`. -pub type KllSketchString<C = NaturalOrder> = KllSketch<String, C>; - /// Default value of parameter k. -pub const DEFAULT_K: u16 = 200; +const DEFAULT_K: u16 = 200; /// Default value of parameter m. -pub const DEFAULT_M: u8 = 8; +const DEFAULT_M: u8 = 8; /// Minimum value of parameter k. -pub const MIN_K: u16 = DEFAULT_M as u16; +const MIN_K: u16 = DEFAULT_M as u16; /// Maximum value of parameter k. -pub const MAX_K: u16 = u16::MAX; +const MAX_K: u16 = u16::MAX; diff --git a/datasketches/src/kll/sketch.rs b/datasketches/src/kll/sketch.rs index ec61190..f1cf175 100644 --- a/datasketches/src/kll/sketch.rs +++ b/datasketches/src/kll/sketch.rs @@ -125,7 +125,7 @@ impl<T: KllItem> KllSketch<T> { /// /// # Errors /// - /// Returns an error if `k` is outside [`MIN_K`, `MAX_K`]. + /// Returns an error if `k` is outside `8..=65535`. /// /// # Examples /// @@ -144,7 +144,7 @@ impl<T: KllItem, C: KllComparator<T>> KllSketch<T, C> { /// /// # Errors /// - /// Returns an error if `k` is outside [`MIN_K`, `MAX_K`]. + /// Returns an error if `k` is outside `8..=65535`. pub fn new_with_comparator(k: u16, comparator: C) -> Result<Self, Error> { if !(MIN_K..=MAX_K).contains(&k) { return Err(Error::invalid_argument(format!( diff --git a/tests-integration/tests/kll_test/sketch.rs b/tests-integration/tests/kll_test/sketch.rs index d9acaaa..18e68c4 100644 --- a/tests-integration/tests/kll_test/sketch.rs +++ b/tests-integration/tests/kll_test/sketch.rs @@ -18,12 +18,12 @@ use std::cmp::Ordering; use datasketches::error::ErrorKind; -use datasketches::kll::DEFAULT_K; use datasketches::kll::KllComparator; use datasketches::kll::KllSketch; -use datasketches::kll::MAX_K; -use datasketches::kll::MIN_K; +const DEFAULT_K: u16 = 200; +const MIN_K: u16 = 8; +const MAX_K: u16 = u16::MAX; const NUMERIC_NOISE_TOLERANCE: f64 = 1e-6; fn assert_approx_eq(actual: f64, expected: f64, tolerance: f64) { diff --git a/tests-integration/tests/serde_tests/kll.rs b/tests-integration/tests/serde_tests/kll.rs index 70d9249..fad3eb3 100644 --- a/tests-integration/tests/serde_tests/kll.rs +++ b/tests-integration/tests/serde_tests/kll.rs @@ -28,12 +28,13 @@ use std::cmp::Ordering; use std::fs; use std::path::PathBuf; -use datasketches::kll::DEFAULT_K; use datasketches::kll::KllComparator; use datasketches::kll::KllSketch; use crate::serialization_test_data; +const DEFAULT_K: u16 = 200; + #[derive(Clone, Copy)] struct NumericStringOrder; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
