Thanks to visit codestin.com
Credit goes to docs.rs

Skip to main content

Module hash_value

Module hash_value 

Source
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.

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.

§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.