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

#248 in Algorithms

Download history 3959/week @ 2024-10-30 4285/week @ 2024-11-06 4540/week @ 2024-11-13 4984/week @ 2024-11-20 5502/week @ 2024-11-27 5214/week @ 2024-12-04 5178/week @ 2024-12-11 4664/week @ 2024-12-18 3615/week @ 2024-12-25 4301/week @ 2025-01-01 6572/week @ 2025-01-08 5358/week @ 2025-01-15 4535/week @ 2025-01-22 5512/week @ 2025-01-29 6287/week @ 2025-02-05 5497/week @ 2025-02-12

22,595 downloads per month
Used in 24 crates (10 directly)

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.3–0.9MB
~21K SLoC