This is an automated email from the ASF dual-hosted git repository.

tisonkun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datasketches-rust.git


The following commit(s) were added to refs/heads/main by this push:
     new 0b8ec82  refactor: align theta view and coupon naming (#165)
0b8ec82 is described below

commit 0b8ec82d7725f50b0ecc885e223ec95e616deb82
Author: tison <[email protected]>
AuthorDate: Mon Jul 27 20:06:23 2026 +0800

    refactor: align theta view and coupon naming (#165)
---
 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 +++---
 datasketches/src/theta/sketch.rs             | 4 ++--
 datasketches/src/thetacommon/a_not_b.rs      | 4 ++--
 datasketches/src/thetacommon/intersection.rs | 4 ++--
 datasketches/src/thetacommon/mod.rs          | 2 +-
 datasketches/src/thetacommon/union.rs        | 4 ++--
 datasketches/src/tuple/sketch.rs             | 4 ++--
 11 files changed, 21 insertions(+), 21 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);
diff --git a/datasketches/src/theta/sketch.rs b/datasketches/src/theta/sketch.rs
index cbf7885..9ced2b4 100644
--- a/datasketches/src/theta/sketch.rs
+++ b/datasketches/src/theta/sketch.rs
@@ -69,7 +69,7 @@ impl ThetaFamilySketchView for ThetaSketch {
         ThetaSketch::seed_hash(self)
     }
 
-    fn theta(&self) -> u64 {
+    fn theta64(&self) -> u64 {
         ThetaSketch::theta64(self)
     }
 
@@ -871,7 +871,7 @@ impl ThetaFamilySketchView for CompactThetaSketch {
         CompactThetaSketch::seed_hash(self)
     }
 
-    fn theta(&self) -> u64 {
+    fn theta64(&self) -> u64 {
         CompactThetaSketch::theta64(self)
     }
 
diff --git a/datasketches/src/thetacommon/a_not_b.rs 
b/datasketches/src/thetacommon/a_not_b.rs
index a6ab089..71ad941 100644
--- a/datasketches/src/thetacommon/a_not_b.rs
+++ b/datasketches/src/thetacommon/a_not_b.rs
@@ -93,7 +93,7 @@ impl ANotBOperator {
             )));
         }
 
-        let theta = a.theta().min(b.theta());
+        let theta = a.theta64().min(b.theta64());
         // A is non-empty here; the result only becomes empty if everything is 
subtracted in exact
         // mode (handled below).
         let mut is_empty = false;
@@ -179,7 +179,7 @@ impl ANotBOperator {
         }
         CompactSketchParts {
             entries,
-            theta: a.theta(),
+            theta: a.theta64(),
             seed_hash: a.seed_hash(),
             ordered: out_ordered,
             empty: a.is_empty(),
diff --git a/datasketches/src/thetacommon/intersection.rs 
b/datasketches/src/thetacommon/intersection.rs
index d131369..77ae398 100644
--- a/datasketches/src/thetacommon/intersection.rs
+++ b/datasketches/src/thetacommon/intersection.rs
@@ -105,7 +105,7 @@ where
         self.table.set_theta(if self.table.is_empty() {
             MAX_THETA
         } else {
-            self.table.theta().min(sketch.theta())
+            self.table.theta().min(sketch.theta64())
         });
 
         if self.has_result && self.table.num_retained() == 0 {
@@ -287,7 +287,7 @@ mod tests {
             crate::hash::compute_seed_hash(DEFAULT_UPDATE_SEED)
         }
 
-        fn theta(&self) -> u64 {
+        fn theta64(&self) -> u64 {
             MAX_THETA
         }
 
diff --git a/datasketches/src/thetacommon/mod.rs 
b/datasketches/src/thetacommon/mod.rs
index 62e791b..eb8db95 100644
--- a/datasketches/src/thetacommon/mod.rs
+++ b/datasketches/src/thetacommon/mod.rs
@@ -42,7 +42,7 @@ pub trait ThetaFamilySketchView {
     fn seed_hash(&self) -> u16;
 
     /// Return theta as a `u64` threshold.
-    fn theta(&self) -> u64;
+    fn theta64(&self) -> u64;
 
     /// Return whether this sketch has not received any updates.
     fn is_empty(&self) -> bool;
diff --git a/datasketches/src/thetacommon/union.rs 
b/datasketches/src/thetacommon/union.rs
index 500d80e..3e89189 100644
--- a/datasketches/src/thetacommon/union.rs
+++ b/datasketches/src/thetacommon/union.rs
@@ -77,7 +77,7 @@ where
         }
 
         self.table.set_empty(false);
-        self.union_theta = self.union_theta.min(sketch.theta());
+        self.union_theta = self.union_theta.min(sketch.theta64());
 
         for entry in sketch.iter() {
             let hash = entry.hash();
@@ -182,7 +182,7 @@ mod tests {
             crate::hash::compute_seed_hash(DEFAULT_UPDATE_SEED)
         }
 
-        fn theta(&self) -> u64 {
+        fn theta64(&self) -> u64 {
             MAX_THETA
         }
 
diff --git a/datasketches/src/tuple/sketch.rs b/datasketches/src/tuple/sketch.rs
index ac45ee0..b43adeb 100644
--- a/datasketches/src/tuple/sketch.rs
+++ b/datasketches/src/tuple/sketch.rs
@@ -259,7 +259,7 @@ where
         self.table.seed_hash()
     }
 
-    fn theta(&self) -> u64 {
+    fn theta64(&self) -> u64 {
         self.table.theta()
     }
 
@@ -575,7 +575,7 @@ impl<S: Clone> ThetaFamilySketchView for 
CompactTupleSketch<S> {
         self.seed_hash
     }
 
-    fn theta(&self) -> u64 {
+    fn theta64(&self) -> u64 {
         self.theta
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to