Expand description
Hashable value wrappers for sketches.
Sketch update APIs accept any value that implements Hash. For most Rust values,
passing the value directly is sufficient. This module provides value wrappers for
cases where the default implementation does not match a sketch’s compatibility rules.
§Floating-point Numbers
canonical_float::CanonicalFloat maps f32 and f64 values through a canonical f64 bit
pattern before hashing. Signed zero values hash the same, all NaN values use one canonical NaN
bit pattern, and equal f32/f64 values hash the same.
This strategy is the same as how other datasketches implementations hash floating-point numbers.
Read the docs of concrete value wrapper for more details and examples.
§Integers
sign_extend::SignExtend first sign-extends values to 64-bits, and then hashes the resulting
integers. This strategy is the same as how datasketches-cpp hashes short integers for
HllSketch and CpcSketch.
Read the docs of concrete value wrapper for more details and examples.
sign_extend::from_i8,sign_extend::from_u8sign_extend::from_i16,sign_extend::from_u16sign_extend::from_i32,sign_extend::from_u32
natural_extend::NaturalExtend first widens signed values to i64 and unsigned values to
u64, and then hashes the resulting integers. This strategy is the same as how datasketches-cpp
hashes short integers for BloomFilter.
Read the docs of concrete value wrapper for more details and examples.
natural_extend::from_i8,natural_extend::from_u8natural_extend::from_i16,natural_extend::from_u16natural_extend::from_i32,natural_extend::from_u32
§Raw Bytes
raw_bytes::RawBytes hashes byte and string inputs as raw bytes without Rust’s slice or
string length prefix.
Empty byte and string inputs have zero bytes to hash. Other datasketches implementations skip
empty strings before hashing, so check is_empty before updating a sketch when that behavior
matters.
Read the docs of concrete value wrapper for more details and examples.
Modules§
- canonical_
float - Canonical floating-point hash value wrappers.
- natural_
extend - Naturally extended integer hash value wrappers.
- raw_
bytes - Raw byte and string hash value wrappers.
- sign_
extend - Sign-extended integer hash value wrappers.
- value
- Shared value wrapper and hashing strategy support.