This is an automated email from the ASF dual-hosted git repository. tisonkun pushed a commit to branch codex/theta-view-coupon-naming in repository https://gitbox.apache.org/repos/asf/datasketches-rust.git
commit 5baab5e8008bba1ffb5a398b4de572e7d21f625d Author: tison <[email protected]> AuthorDate: Sat Jul 25 23:30:22 2026 +0800 refactor(hll): rename coupon constructor to from_value --- datasketches/src/hll/array4.rs | 2 +- datasketches/src/hll/array6.rs | 2 +- datasketches/src/hll/array8.rs | 2 +- datasketches/src/hll/mod.rs | 8 ++++---- datasketches/src/hll/sketch.rs | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/datasketches/src/hll/array4.rs b/datasketches/src/hll/array4.rs index 268db40..2ed8888 100644 --- a/datasketches/src/hll/array4.rs +++ b/datasketches/src/hll/array4.rs @@ -473,7 +473,7 @@ mod tests { // Add some unique values to different slots for i in 0..10_000u32 { - arr.update(Coupon::from_hash(i)); + arr.update(Coupon::from_value(i)); } // Estimate should be positive and roughly in the ballpark diff --git a/datasketches/src/hll/array6.rs b/datasketches/src/hll/array6.rs index 42646d3..2fc756c 100644 --- a/datasketches/src/hll/array6.rs +++ b/datasketches/src/hll/array6.rs @@ -361,7 +361,7 @@ mod tests { // Add some unique values using real coupon hashing for i in 0..10_000u32 { - arr.update(Coupon::from_hash(i)); + arr.update(Coupon::from_value(i)); } let estimate = arr.estimate(); diff --git a/datasketches/src/hll/array8.rs b/datasketches/src/hll/array8.rs index 55cf384..b06e5ed 100644 --- a/datasketches/src/hll/array8.rs +++ b/datasketches/src/hll/array8.rs @@ -420,7 +420,7 @@ mod tests { // Add some unique values using real coupon hashing for i in 0..10_000u32 { - arr.update(Coupon::from_hash(i)); + arr.update(Coupon::from_value(i)); } let estimate = arr.estimate(); diff --git a/datasketches/src/hll/mod.rs b/datasketches/src/hll/mod.rs index 626a4e1..ec300a8 100644 --- a/datasketches/src/hll/mod.rs +++ b/datasketches/src/hll/mod.rs @@ -175,7 +175,7 @@ const RESIZE_DENOMINATOR: u32 = 4; /// /// ``` /// # use datasketches::hll::{HllSketch, HllType, Coupon}; -/// let c = Coupon::from_hash("hello"); +/// let c = Coupon::from_value("hello"); /// /// let mut sketch1 = HllSketch::new(10, HllType::Hll8); /// let mut sketch2 = HllSketch::new(12, HllType::Hll8); @@ -209,14 +209,14 @@ impl Coupon { /// You may use [`hash_value`](crate::hash_value) wrappers when matching other datasketches /// implementations require a specific value hashing strategy. /// - /// Hashes `v` using MurmurHash3 128-bit and packs the result into a coupon: + /// Hashes `value` using MurmurHash3 128-bit and packs the result into a coupon: /// the low 26 bits of the low hash word become the slot index, and the /// leading-zero count of the high hash word (capped at 62, then plus one) /// becomes the 6-bit register value. #[inline(always)] - pub fn from_hash<T: Hash>(v: T) -> Self { + pub fn from_value<T: Hash>(value: T) -> Self { let mut hasher = MurmurHash3X64128::default(); - v.hash(&mut hasher); + value.hash(&mut hasher); let (lo, hi) = hasher.finish128(); let addr26 = lo as u32 & KEY_MASK_26; diff --git a/datasketches/src/hll/sketch.rs b/datasketches/src/hll/sketch.rs index 25ba047..41e838e 100644 --- a/datasketches/src/hll/sketch.rs +++ b/datasketches/src/hll/sketch.rs @@ -165,7 +165,7 @@ impl HllSketch { /// implementations require a specific value hashing strategy. /// /// If you need to insert the same logical value into multiple sketches, consider - /// pre-computing the coupon with [`Coupon::from_hash`] and calling + /// pre-computing the coupon with [`Coupon::from_value`] and calling /// [`update_with_coupon`](Self::update_with_coupon) on each sketch to avoid /// redundant hashing. /// @@ -184,7 +184,7 @@ impl HllSketch { /// assert!(sketch.estimate() >= 1.0); /// ``` pub fn update<T: Hash>(&mut self, value: T) { - self.update_with_coupon(Coupon::from_hash(value)); + self.update_with_coupon(Coupon::from_value(value)); } /// Update the sketch with a pre-computed [`Coupon`]. @@ -201,7 +201,7 @@ impl HllSketch { /// /// ``` /// # use datasketches::hll::{HllSketch, HllType, Coupon}; - /// let c = Coupon::from_hash("apple"); + /// let c = Coupon::from_value("apple"); /// let mut sketch = HllSketch::new(10, HllType::Hll8); /// sketch.update_with_coupon(c); /// assert!(sketch.estimate() >= 1.0); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
