{"id":15653206,"url":"https://github.com/lucacappelletti94/hyperloglog-rs","last_synced_at":"2025-09-05T11:32:42.541Z","repository":{"id":163070219,"uuid":"637535797","full_name":"LucaCappelletti94/hyperloglog-rs","owner":"LucaCappelletti94","description":"A Rust implementation of HyperLogLog trying to be parsimonious with memory. ","archived":false,"fork":false,"pushed_at":"2024-09-24T07:09:54.000Z","size":251735,"stargazers_count":31,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T00:28:20.543Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LucaCappelletti94.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-07T21:08:04.000Z","updated_at":"2025-02-22T15:49:59.000Z","dependencies_parsed_at":"2024-09-17T08:33:10.529Z","dependency_job_id":"fd988fde-2432-4c9c-b4f7-2b8814a187eb","html_url":"https://github.com/LucaCappelletti94/hyperloglog-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCappelletti94%2Fhyperloglog-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCappelletti94%2Fhyperloglog-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCappelletti94%2Fhyperloglog-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LucaCappelletti94%2Fhyperloglog-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LucaCappelletti94","download_url":"https://codeload.github.com/LucaCappelletti94/hyperloglog-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248198888,"owners_count":21063628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T12:44:57.890Z","updated_at":"2025-04-10T10:12:59.939Z","avatar_url":"https://github.com/LucaCappelletti94.png","language":"Rust","readme":"# 🧮 HyperLogLog-rs\n[![downloads](https://img.shields.io/crates/d/hyperloglog-rs)](https://crates.io/crates/hyperloglog-rs)\n[![dependents](https://img.shields.io/librariesio/dependents/cargo/hyperloglog-rs)](https://crates.io/crates/hyperloglog-rs/reverse_dependencies)\n[![CI](https://github.com/LucaCappelletti94/hyperloglog-rs/actions/workflows/rust.yml/badge.svg)](https://github.com/LucaCappelletti94/hyperloglog-rs/actions)\n![license](https://img.shields.io/crates/l/hyperloglog-rs)\n[![Latest version](https://img.shields.io/crates/v/hyperloglog-rs.svg)](https://crates.io/crates/hyperloglog-rs)\n[![Documentation](https://docs.rs/hyperloglog-rs/badge.svg)](https://docs.rs/hyperloglog-rs)\n\nThis is a Rust library that provides an implementation of the `HyperLogLog` (HLL) algorithm, trying to be parsimonious with memory.\nIt also provides an implementation based on the MLE algorithm, which is a more accurate version of the `HyperLogLog` algorithm but is slower.\n\nYou can use it to estimate the cardinality of large sets, and determine also the union and intersection of two sets.\n\n## Usage\n\nAdd this to your `Cargo.toml`:\n\n```toml\n[dependencies]\nhyperloglog = \"0.1\"\n```\n\n## Examples\n\n```rust\nuse hyperloglog_rs::prelude::*;\n\nlet mut hll = PlusPlus::\u003cPrecision6, Bits5, \u003cPrecision6 as PackedRegister\u003cBits5\u003e\u003e::Array, twox_hash::XxHash\u003e::default();\nhll.insert(\u00261);\nhll.insert(\u00262);\n\nlet mut hll2 = PlusPlus::\u003cPrecision6, Bits5, \u003cPrecision6 as PackedRegister\u003cBits5\u003e\u003e::Array, twox_hash::XxHash\u003e::default();\nhll2.insert(\u00262);\nhll2.insert(\u00263);\n\nlet union = hll | hll2;\n\nlet estimated_cardinality: f64 = union.estimate_cardinality();\nassert!(\nestimated_cardinality \u003e= 3.0_f64 * 0.9 \u0026\u0026\nestimated_cardinality \u003c= 3.0_f64 * 1.1,\n\"Expected cardinality to be around 3, got {}\",\nestimated_cardinality\n);\n\nlet intersection_cardinality: f64 = hll.estimate_intersection_cardinality(\u0026hll2);\n\nassert!(\n        intersection_cardinality \u003e= 1.0_f64 * 0.9 \u0026\u0026\n        intersection_cardinality \u003c= 1.0_f64 * 1.1,\n        \"Expected intersection cardinality to be around 1, got {}\",\n        intersection_cardinality\n);\n```\n\n### Using MLE estimation\nThe [MLE estimation for HyperLogLog counters by Otmar Ertl](https://oertl.github.io/hyperloglog-sketch-estimation-paper/paper/paper.pdf) provides a more accurate estimation of the cardinality of a set, but it is slower than the standard `HyperLogLog` algorithm. Here is an example of how to use it:\n\n```rust\n#[cfg(feature = \"mle\")]\n{\n        use hyperloglog_rs::prelude::*;\n\n        let mut hll1: MLE\u003cPlusPlus::\u003cPrecision6, Bits5, \u003cPrecision6 as PackedRegister\u003cBits5\u003e\u003e::Array, twox_hash::XxHash\u003e\u003e = MLE::default();\n        \n        hll1.insert(\u00261);\n        hll1.insert(\u00262);\n        hll1.insert(\u00263);\n\n        let mut hll2: MLE\u003cPlusPlus::\u003cPrecision6, Bits5, \u003cPrecision6 as PackedRegister\u003cBits5\u003e\u003e::Array, twox_hash::XxHash\u003e\u003e = MLE::default();\n\n        hll2.insert(\u00262);\n        hll2.insert(\u00263);\n        hll2.insert(\u00264);\n\n        let estimated_cardinality: f64 = hll1.estimate_cardinality();\n        assert!(\n                estimated_cardinality \u003e= 3.0_f64 * 0.9 \u0026\u0026\n                estimated_cardinality \u003c= 3.0_f64 * 1.1,\n                \"MLE: Expected cardinality to be around 3, got {}\",\n                estimated_cardinality\n        );\n\n        let estimate_intersection_cardinality: f64 = hll1.estimate_intersection_cardinality(\u0026hll2);\n\n        assert!(\n                estimate_intersection_cardinality \u003e= 2.0_f64 * 0.9 \u0026\u0026\n                estimate_intersection_cardinality \u003c= 2.0_f64 * 1.1,\n                \"MLE: Expected intersection cardinality to be around 2, got {}\",\n                estimate_intersection_cardinality\n        );\n}\n```\n\n## No STD\nThis crate is designed to be as lightweight as possible and does not require any dependencies from the Rust standard library (std). As a result, it can be used in a bare metal or embedded context, where std may not be available. The only feature that requires std is the MLE estimation, which is optional.\n\n## Fuzzing\nFuzzing is a technique for finding security vulnerabilities and bugs in software by providing random input to the code. We make sure that our fuzz targets are continuously updated and run against the latest versions of the library to ensure that any vulnerabilities or bugs are quickly identified and addressed.\n\n[Learn more about how we fuzz here](https://github.com/LucaCappelletti94/hyperloglog-rs/tree/main/fuzz)\n\n## Citations\nSome relevant citations to learn more:\n\n* Philippe Flajolet, Eric Fusy, Olivier Gandouet, Frédéric Meunier. \"[HyperLogLog: the analysis of a near-optimal cardinality estimation algorithm.](https://hal.science/file/index/docid/406166/filename/FlFuGaMe07.pdf)\" In Proceedings of the 2007 conference on analysis of algorithms, pp. 127-146. 2007.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucacappelletti94%2Fhyperloglog-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucacappelletti94%2Fhyperloglog-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucacappelletti94%2Fhyperloglog-rs/lists"}