Struct basichll::HLL [-] [+] [src]

pub struct HLL {
    // some fields omitted
}

The HLL struct stores the underlying registers of the HyperLogLog, with m many registers.

The value for m is derived from the desired error of the estimation. The error is considered to be 1.04 / sqrt(2 ^ bits). So, given a desired 1% error rate, we result in around 12 bits per register, producing an underlying M of 212 bits (i.e. 4kb).

Methods

impl HLL

fn one_hundred_twenty_eight() -> HLL

Convenience function to produce a HLL with one hundred and twenty eight registers.

fn new(error: f64) -> HLL

Create a new HLL with the desired standard error. Some examples might be:

bits    size    error
12      4096    0.0163
13      8192    0.0115
14      16384   0.0081

The error must be between 0.0 and 1.0. Beware using a stupidly small error size will grow beyond e.g. isize at less than 0.03 (if you need something that isn't an estimate probably don't use a hyperloglog).

fn insert<T: Hash>(&mut self, val: &T)

Add an element into the hyperloglog estimate. We require the type of value to be able to be hashed.

fn count(&self) -> f64

Return the estimated cardinality of the observed set of elements.

fn registers(&self) -> Vec<u8>

Access a copy of the underlying registers (this is mainly here just for debugging/testing... its unlikely you'll need this access typically).

fn clone(&self) -> HLL

Copies this instance into a new HLL. Doesn't do anything tricky (i.e. this will entirely re-allocate the underlying registers).

fn empty() -> HLL

A completely zeroed HLL. Not particularly useful except as an identity element in Add.

Trait Implementations

impl Display for HLL

fn fmt(&self, formatter: &mut Formatter) -> Result

impl Debug for HLL

fn fmt(&self, formatter: &mut Formatter) -> Result

impl Eq for HLL

A HLL is considered equal to another HLL when its configuration and registers are exactly identical.

impl PartialEq for HLL

fn eq(&self, other: &HLL) -> bool

fn ne(&self, other: &Rhs) -> bool

impl<'a> Add<&'a HLL> for &'a HLL

Adding together two HLLs produces a new HLL where the larger value of each register has been selected.

type Output = HLL

fn add(self, other: &'a HLL) -> HLL