Struct hyperlog_simd::plusplus::HyperLogLogPlusPlus
source · pub struct HyperLogLogPlusPlus {
pub registers: Box<[u8; 1048576]>,
}
Expand description
An enhanced HyperLogLog data structure, often termed HyperLogLog++, for estimating the cardinality of a dataset without storing individual elements.
Fields§
§registers: Box<[u8; 1048576]>
Registers used for maintaining the cardinality estimate.
The number of registers (M
) impacts precision and memory usage.
Implementations§
source§impl HyperLogLogPlusPlus
impl HyperLogLogPlusPlus
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a new instance of HyperLogLog++ with all registers initialized to zero.
Returns
A new HyperLogLogPlusPlus
instance.
sourcepub fn add<T: Hash>(&mut self, item: T)
pub fn add<T: Hash>(&mut self, item: T)
Adds an item to the HyperLogLog++. This will update the registers based on the hash of the item but won’t store the item itself.
Parameters
item
: The item to be added. It should implement theHash
trait.
sourcepub fn estimate(&self) -> f64
pub fn estimate(&self) -> f64
Estimates the cardinality or unique count of the items added to the HyperLogLog++.
Returns
An approximate count (as f64
) of unique items added.
sourcepub fn merge(&mut self, other: &HyperLogLogPlusPlus)
pub fn merge(&mut self, other: &HyperLogLogPlusPlus)
Merges the state of another HyperLogLog++ instance into this one. This is useful for combining the cardinality estimates of two separate datasets.
Parameters
other
: The otherHyperLogLogPlusPlus
instance whose state is to be merged into this one.
Trait Implementations§
source§impl Clone for HyperLogLogPlusPlus
impl Clone for HyperLogLogPlusPlus
source§fn clone(&self) -> HyperLogLogPlusPlus
fn clone(&self) -> HyperLogLogPlusPlus
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for HyperLogLogPlusPlus
impl Debug for HyperLogLogPlusPlus
source§impl Default for HyperLogLogPlusPlus
impl Default for HyperLogLogPlusPlus
source§impl<'de> Deserialize<'de> for HyperLogLogPlusPlus
impl<'de> Deserialize<'de> for HyperLogLogPlusPlus
source§fn deserialize<D>(deserializer: D) -> Result<HyperLogLogPlusPlus, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<HyperLogLogPlusPlus, D::Error>where D: Deserializer<'de>,
Deserializes data to construct a HyperLogLogPlusPlus
instance.
The data is expected to contain a registers
field in a specific
serialized format. The CompressedRegistersVisitor
is used to assist
in this deserialization process.