You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by ti...@apache.org on 2026/02/08 08:54:13 UTC
(datasketches-rust) 01/01: chore: check seed for CpcSketch and CountMinSketch
This is an automated email from the ASF dual-hosted git repository.
tison pushed a commit to branch check-seed
in repository https://gitbox.apache.org/repos/asf/datasketches-rust.git
commit dbf7f65612a5ac50ede239c7579d4fb6329f8b79
Author: tison <wa...@gmail.com>
AuthorDate: Sun Feb 8 16:53:56 2026 +0800
chore: check seed for CpcSketch and CountMinSketch
Signed-off-by: tison <wa...@gmail.com>
---
datasketches/src/hash/mod.rs | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/datasketches/src/hash/mod.rs b/datasketches/src/hash/mod.rs
index 492e45e..87eaf22 100644
--- a/datasketches/src/hash/mod.rs
+++ b/datasketches/src/hash/mod.rs
@@ -39,15 +39,21 @@ pub(crate) const DEFAULT_UPDATE_SEED: u64 = 9001;
/// Computes and checks the 16-bit seed hash from the given long seed.
///
-/// The seed hash may not be zero in order to maintain compatibility with older serialized
-/// versions that did not have this concept.
+/// The computed seed hash must not be zero in order to maintain compatibility with older
+/// serialized versions that did not have this concept.
+///
+/// # Panics
+///
+/// Panics if the computed seed hash is zero.
pub(crate) fn compute_seed_hash(seed: u64) -> u16 {
use std::hash::Hasher;
let mut hasher = MurmurHash3X64128::with_seed(0);
hasher.write(&seed.to_le_bytes());
let (h1, _) = hasher.finish128();
- (h1 & 0xffff) as u16
+ let seed_hash = (h1 & 0xffff) as u16;
+ assert_ne!(seed_hash, 0);
+ seed_hash
}
/// Reads an u64 from a byte slice in little-endian order.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org