[−][src]Struct hyperloglogplus::HyperLogLogPlus
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<u64, RandomState> = HyperLogLogPlus::new(16, RandomState::new()).unwrap(); hllp.add(&12345); hllp.add(&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.
Methods
impl<H: ?Sized, B> HyperLogLogPlus<H, B> where
H: Hash,
B: BuildHasher,
[src]
H: Hash,
B: BuildHasher,
pub fn new(precision: u8, builder: B) -> Result<Self, HyperLogLogError>
[src]
Creates a new HyperLogLogPlus instance.
pub fn merge<S: ?Sized, T>(
&mut self,
other: &HyperLogLogPlus<S, T>
) -> Result<(), HyperLogLogError> where
S: Hash,
T: BuildHasher,
[src]
&mut self,
other: &HyperLogLogPlus<S, T>
) -> Result<(), HyperLogLogError> where
S: Hash,
T: BuildHasher,
Merges the other
HyperLogLogPlus instance into self
.
Both sketches must have the same precision. Merge can trigger the transition from sparse to normal representation.
Trait Implementations
impl<H: Debug + ?Sized, B: Debug> Debug for HyperLogLogPlus<H, B> where
H: Hash,
B: BuildHasher,
[src]
H: Hash,
B: BuildHasher,
impl<'de, H: ?Sized, B> Deserialize<'de> for HyperLogLogPlus<H, B> where
H: Hash,
B: BuildHasher,
B: Deserialize<'de>,
[src]
H: Hash,
B: BuildHasher,
B: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<H: ?Sized, B> HyperLogLog<H> for HyperLogLogPlus<H, B> where
H: Hash,
B: BuildHasher,
[src]
H: Hash,
B: BuildHasher,
fn add(&mut self, value: &H)
[src]
Adds a new value to the multiset.
fn count(&mut self) -> f64
[src]
Estimates the cardinality of the multiset.
impl<H: ?Sized, B> Serialize for HyperLogLogPlus<H, B> where
H: Hash,
B: BuildHasher,
B: Serialize,
[src]
H: Hash,
B: BuildHasher,
B: Serialize,
Auto Trait Implementations
impl<H: ?Sized, B> RefUnwindSafe for HyperLogLogPlus<H, B> where
B: RefUnwindSafe,
H: RefUnwindSafe,
B: RefUnwindSafe,
H: RefUnwindSafe,
impl<H: ?Sized, B> Send for HyperLogLogPlus<H, B> where
B: Send,
H: Send,
B: Send,
H: Send,
impl<H: ?Sized, B> Sync for HyperLogLogPlus<H, B> where
B: Sync,
H: Sync,
B: Sync,
H: Sync,
impl<H: ?Sized, B> Unpin for HyperLogLogPlus<H, B> where
B: Unpin,
H: Unpin,
B: Unpin,
H: Unpin,
impl<H: ?Sized, B> UnwindSafe for HyperLogLogPlus<H, B> where
B: UnwindSafe,
H: UnwindSafe,
B: UnwindSafe,
H: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,