From d0afcf0acd692e25ab9949dea2815dbfe9393e6c Mon Sep 17 00:00:00 2001 From: zyc <18611145971@163.com> Date: Thu, 5 Mar 2026 13:55:11 +0800 Subject: [PATCH 1/2] Fix inconsistency --- datasketches/src/cpc/sketch.rs | 4 ++-- datasketches/src/cpc/union.rs | 4 ++-- datasketches/src/theta/bit_pack.rs | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/datasketches/src/cpc/sketch.rs b/datasketches/src/cpc/sketch.rs index d11d59b..534f0a0 100644 --- a/datasketches/src/cpc/sketch.rs +++ b/datasketches/src/cpc/sketch.rs @@ -97,7 +97,7 @@ impl CpcSketch { /// /// # Panics /// - /// Panics if `lg_k` is not in the range `[4, 16]`. + /// Panics if `lg_k` is not in the range `[4, 26]`. pub fn new(lg_k: u8) -> Self { Self::with_seed(lg_k, DEFAULT_UPDATE_SEED) } @@ -106,7 +106,7 @@ impl CpcSketch { /// /// # Panics /// - /// Panics if `lg_k` is not in the range `[4, 16]`, or the computed seed hash is zero. + /// Panics if `lg_k` is not in the range `[4, 26]`, or the computed seed hash is zero. pub fn with_seed(lg_k: u8, seed: u64) -> Self { assert!( (MIN_LG_K..=MAX_LG_K).contains(&lg_k), diff --git a/datasketches/src/cpc/union.rs b/datasketches/src/cpc/union.rs index 4c68f5a..a983630 100644 --- a/datasketches/src/cpc/union.rs +++ b/datasketches/src/cpc/union.rs @@ -91,7 +91,7 @@ impl CpcUnion { /// /// # Panics /// - /// Panics if `lg_k` is not in the range `[4, 16]`. + /// Panics if `lg_k` is not in the range `[4, 26]`. pub fn new(lg_k: u8) -> Self { Self::with_seed(lg_k, DEFAULT_UPDATE_SEED) } @@ -100,7 +100,7 @@ impl CpcUnion { /// /// # Panics /// - /// Panics if `lg_k` is not in the range `[4, 16]`. + /// Panics if `lg_k` is not in the range `[4, 26]`. pub fn with_seed(lg_k: u8, seed: u64) -> Self { // We begin with the accumulator holding an EMPTY_MERGED sketch object. let sketch = CpcSketch::with_seed(lg_k, seed); diff --git a/datasketches/src/theta/bit_pack.rs b/datasketches/src/theta/bit_pack.rs index 2a59351..526cc1d 100644 --- a/datasketches/src/theta/bit_pack.rs +++ b/datasketches/src/theta/bit_pack.rs @@ -4974,7 +4974,7 @@ fn unpack_bits_63(values: &mut [u64], bytes: &[u8]) { /// /// * Panics if `values.len()` is not equal to `BLOCK_WIDTH`. /// * Panics if `bits` is not in the range `1..=63`. -/// * Panics if `bytes.len()` is less than `bits * BLOCK_WIDTH`. +/// * Panics if `bytes.len()` is less than `bits`. pub(crate) fn pack_bits_block(values: &[u64], bytes: &mut [u8], bits: u8) { assert_eq!(values.len(), BLOCK_WIDTH, "values length must be 8"); assert!( @@ -4982,7 +4982,7 @@ pub(crate) fn pack_bits_block(values: &[u64], bytes: &mut [u8], bits: u8) { "wrong number of bits in pack_bits_block8: {bits}" ); assert!( - bytes.len() < bits as usize * BLOCK_WIDTH, + bytes.len() >= bits as usize, "output buffer too small" ); @@ -5060,7 +5060,7 @@ pub(crate) fn pack_bits_block(values: &[u64], bytes: &mut [u8], bits: u8) { /// /// * Panics if `values.len()` is not equal to `BLOCK_WIDTH`. /// * Panics if `bits` is not in the range `1..=63`. -/// * Panics if `bytes.len()` is less than `bits * BLOCK_WIDTH`. +/// * Panics if `bytes.len()` is less than `bits`. pub(crate) fn unpack_bits_block(values: &mut [u64], bytes: &[u8], bits: u8) { assert_eq!(values.len(), BLOCK_WIDTH, "values length must be 8"); assert!( @@ -5068,7 +5068,7 @@ pub(crate) fn unpack_bits_block(values: &mut [u64], bytes: &[u8], bits: u8) { "wrong number of bits in unpack_bits_block8: {bits}" ); assert!( - bytes.len() < bits as usize * BLOCK_WIDTH, + bytes.len() >= bits as usize, "input buffer too small" ); From 58bf439f3f955652f7ac95cdc49b2da717ae5ffb Mon Sep 17 00:00:00 2001 From: zyc <18611145971@163.com> Date: Thu, 5 Mar 2026 15:56:04 +0800 Subject: [PATCH 2/2] Format --- datasketches/src/theta/bit_pack.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/datasketches/src/theta/bit_pack.rs b/datasketches/src/theta/bit_pack.rs index 526cc1d..013899b 100644 --- a/datasketches/src/theta/bit_pack.rs +++ b/datasketches/src/theta/bit_pack.rs @@ -4981,10 +4981,7 @@ pub(crate) fn pack_bits_block(values: &[u64], bytes: &mut [u8], bits: u8) { (1..=63).contains(&bits), "wrong number of bits in pack_bits_block8: {bits}" ); - assert!( - bytes.len() >= bits as usize, - "output buffer too small" - ); + assert!(bytes.len() >= bits as usize, "output buffer too small"); match bits { 1 => pack_bits_1(values, bytes), @@ -5067,10 +5064,7 @@ pub(crate) fn unpack_bits_block(values: &mut [u64], bytes: &[u8], bits: u8) { (1..=63).contains(&bits), "wrong number of bits in unpack_bits_block8: {bits}" ); - assert!( - bytes.len() >= bits as usize, - "input buffer too small" - ); + assert!(bytes.len() >= bits as usize, "output buffer too small"); match bits { 1 => unpack_bits_1(values, bytes),