7 unstable releases

0.4.1 Jun 13, 2022
0.4.0 Apr 7, 2021
0.3.0 Jan 16, 2021
0.2.2 Sep 23, 2020
0.1.0 Apr 16, 2020

#389 in Algorithms

Download history 1037/week @ 2024-03-13 864/week @ 2024-03-20 410/week @ 2024-03-27 759/week @ 2024-04-03 1185/week @ 2024-04-10 1121/week @ 2024-04-17 684/week @ 2024-04-24 918/week @ 2024-05-01 644/week @ 2024-05-08 700/week @ 2024-05-15 616/week @ 2024-05-22 534/week @ 2024-05-29 522/week @ 2024-06-05 1064/week @ 2024-06-12 742/week @ 2024-06-19 504/week @ 2024-06-26

2,989 downloads per month
Used in 3 crates

MIT license

185KB
6K SLoC

HyperLogLog

Build status Crates.io Documentation

HyperLogLog is a probabilistic algorithm for estimating the number of distinct elements (cardinality) of a multiset. Several variations of the original algorithm, described by P. Flajolet et al., have been proposed.

The following implementations are provided:

Usage

Add to Cargo.toml:

[dependencies]
hyperloglogplus = "*"

With Rust compiler version 1.45.0 or higher consider enabling the const-loop feature for better performance, see here for more details.

[dependencies]
hyperloglogplus = { version = "*", features = ["const-loop"] }

A simple example using HyperLogLog++ implementation:

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);

Evaluation

Here you can find figures and discussion on experimental evaluation.

Dependencies

~0.4–1MB
~23K SLoC