hypeerlog

Crates.iohypeerlog
lib.rshypeerlog
version0.2.6
created_at2025-07-22 22:23:04.053811+00
updated_at2025-09-23 04:29:12.094289+00
descriptionA fast, distributable, and lightweight HyperLogLog implementation with bias correction
homepage
repositoryhttps://github.com/Albassel/hypeerlog
max_upload_size
id1764135
size48,407
Basel (Albassel)

documentation

https://docs.rs/hypeerlog/latest/hypeerlog/

README

hypeerlog

A fast, distributable, and lightweight HyperLogLog implementation with bias correction

Usage

Estimating cardinality

use hypeerlog::Hypeerlog;

let elems = vec![1, 2, 3, 4, 5, 6, 7, 1, 1, 2];

let mut hll = Hypeerlog::new();
hll.insert_many(&elems);

// Should be within 1% of the real cardinality
hll.cardinality();

Distributing the work

You can divide the dataset onto multiple computers, dump the hll when you finish adding the data, load the dump into another computer, merge all the hll, and then calculate the cardinality of the merged hll to get the cardinality for the whole dataset:

use hypeerlog::Hypeerlog;

let elems = vec![1, 2, 3, 4, 5, 6, 7, 1, 1, 2];

let mut hll_one = Hypeerlog::new();
hll_one.insert_many(&elems[0..5]);

let mut hll_two = Hypeerlog::new();
hll_two.insert_many(&elems[5..]);

hll_one.merge(hll_two).unwrap().cardinality();

Contribution

Feel free to fork or do a pull request, but it is highly advised to read the Google paper before looking into the code in order to understand the internals

Commit count: 20

cargo fmt