pub struct HyperLogLogPlus<H, B>{ /* private fields */ }Expand description
Implements the HyperLogLog++ algorithm for cardinality estimation.
This implementation is based on the paper:
HyperLogLog in Practice: Algorithmic Engineering of a State of The Art Cardinality Estimation Algorithm.
- Uses 6-bit registers, packed in a 32-bit unsigned integer. Thus, every five registers 2 bits are not used.
- In small cardinalities, a sparse representation is used which allows for higher precision in estimations.
- Performs bias correction using the empirical data provided by Google (can be found here).
- Supports serialization/deserialization through
serde.
§Examples
use std::collections::hash_map::RandomState;
use hyperloglogplus::{HyperLogLog, HyperLogLogPlus};
let mut hllp: HyperLogLogPlus<u32, _> =
HyperLogLogPlus::new(16, RandomState::new()).unwrap();
hllp.insert(&12345);
hllp.insert(&23456);
assert_eq!(hllp.count().trunc() as u32, 2);§References
- “HyperLogLog: the analysis of a near-optimal cardinality estimation algorithm”, Philippe Flajolet, Éric Fusy, Olivier Gandouet and Frédéric Meunier.
- “HyperLogLog in Practice: Algorithmic Engineering of a State of The Art Cardinality Estimation Algorithm”, Stefan Heule, Marc Nunkesser and Alexander Hall.
- “Appendix to HyperLogLog in Practice: Algorithmic Engineering of a State of the Art Cardinality Estimation Algorithm”, Stefan Heule, Marc Nunkesser and Alexander Hall.
Implementations§
Source§impl<H, B> HyperLogLogPlus<H, B>
impl<H, B> HyperLogLogPlus<H, B>
Sourcepub fn new(precision: u8, builder: B) -> Result<Self, HyperLogLogError>
pub fn new(precision: u8, builder: B) -> Result<Self, HyperLogLogError>
Creates a new HyperLogLogPlus instance.
Sourcepub fn merge<S, T>(
&mut self,
other: &HyperLogLogPlus<S, T>,
) -> Result<(), HyperLogLogError>
pub fn merge<S, T>( &mut self, other: &HyperLogLogPlus<S, T>, ) -> Result<(), HyperLogLogError>
Merges the other HyperLogLogPlus instance into self.
Both sketches must have the same precision. Merge can trigger the transition from sparse to normal representation.
Sourcepub fn insert_any<R>(&mut self, value: &R)
pub fn insert_any<R>(&mut self, value: &R)
Inserts a new value, of any type, to the multiset.
Trait Implementations§
Source§impl<H, B> Clone for HyperLogLogPlus<H, B>
impl<H, B> Clone for HyperLogLogPlus<H, B>
Source§fn clone(&self) -> HyperLogLogPlus<H, B>
fn clone(&self) -> HyperLogLogPlus<H, B>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<H, B> Debug for HyperLogLogPlus<H, B>
impl<H, B> Debug for HyperLogLogPlus<H, B>
Source§impl<'de, H, B> Deserialize<'de> for HyperLogLogPlus<H, B>
impl<'de, H, B> Deserialize<'de> for HyperLogLogPlus<H, B>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<H, B> Freeze for HyperLogLogPlus<H, B>
impl<H, B> RefUnwindSafe for HyperLogLogPlus<H, B>
impl<H, B> Send for HyperLogLogPlus<H, B>
impl<H, B> Sync for HyperLogLogPlus<H, B>
impl<H, B> Unpin for HyperLogLogPlus<H, B>
impl<H, B> UnwindSafe for HyperLogLogPlus<H, B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more