{"id":13419197,"url":"https://github.com/mavam/libbf","last_synced_at":"2025-04-05T21:07:27.051Z","repository":{"id":1508239,"uuid":"1764600","full_name":"mavam/libbf","owner":"mavam","description":":dart: Bloom filters for C++11","archived":false,"fork":false,"pushed_at":"2021-12-19T05:33:04.000Z","size":2583,"stargazers_count":356,"open_issues_count":18,"forks_count":89,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-03-29T19:08:42.526Z","etag":null,"topics":["bloom-filter","synopsis"],"latest_commit_sha":null,"homepage":"http://mavam.github.io/libbf","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mavam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-05-18T05:36:26.000Z","updated_at":"2025-03-14T06:10:43.000Z","dependencies_parsed_at":"2022-08-16T13:31:06.097Z","dependency_job_id":null,"html_url":"https://github.com/mavam/libbf","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mavam%2Flibbf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mavam%2Flibbf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mavam%2Flibbf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mavam%2Flibbf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mavam","download_url":"https://codeload.github.com/mavam/libbf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399877,"owners_count":20932876,"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":["bloom-filter","synopsis"],"created_at":"2024-07-30T22:01:12.635Z","updated_at":"2025-04-05T21:07:27.029Z","avatar_url":"https://github.com/mavam.png","language":"C++","funding_links":[],"categories":["TODO scan for Android support in followings","C++"],"sub_categories":[],"readme":"⚠️  **Maintainer needed**: unfortunately I lack the cycles to maintain this\nproject. I would gladly support anyone who is willing to step in.\n\n**libbf** is a C++11 library which implements [various Bloom\nfilters][blog-post], including:\n\n- Basic\n- Counting\n- Spectral MI\n- Spectral RM\n- Bitwise\n- A^2\n- Stable\n\n[blog-post]: http://matthias.vallentin.net/blog/2011/06/a-garden-variety-of-bloom-filters/\n\nSynopsis\n========\n\n    #include \u003ciostream\u003e\n    #include \u003cbf.h\u003e\n\n    int main()\n    {\n      bf::basic_bloom_filter b(0.8, 100);\n\n      // Add two elements.\n      b.add(\"foo\");\n      b.add(42);\n\n      // Test set membership\n      std::cout \u003c\u003c b.lookup(\"foo\") \u003c\u003c std::endl;  // 1\n      std::cout \u003c\u003c b.lookup(\"bar\") \u003c\u003c std::endl;  // 0\n      std::cout \u003c\u003c b.lookup(42) \u003c\u003c std::endl;     // 1\n\n      // Remove all elements.\n      b.clear();\n      std::cout \u003c\u003c b.lookup(\"foo\") \u003c\u003c std::endl;  // 0\n      std::cout \u003c\u003c b.lookup(42) \u003c\u003c std::endl;     // 0\n\n      return 0;\n    }\n\nRequirements\n============\n\n- A C++11 compiler (GCC \u003e= 4.7 or Clang \u003e= 3.2)\n- CMake (\u003e= 2.8)\n\nInstallation\n============\n\nThe build process uses CMake, wrapped in autotools-like scripts. The configure\nscript honors the `CXX` environment variable to select a specific C++compiler.\nFor example, the following steps compile libbf with Clang and install it under\n`PREFIX`:\n\n    CXX=clang++ ./configure --prefix=PREFIX\n    make\n    make test\n    make install\n\nDocumentation\n=============\n\nThe most recent version of the Doxygen API documentation exists at\n\u003chttp://mavam.github.io/libbf/api\u003e. Alternatively, you can build the\ndocumentation locally via `make doc` and then browse to\n`doc/gh-pages/api/index.html`.\n\nUsage\n=====\n\nAfter having installed libbf, you can use it in your application by including\nthe header file `bf.h` and linking against the library. All data structures\nreside in the namespace `bf` and the following examples assume:\n\n    using namespace bf;\n\nEach Bloom filter inherits from the abstract base class `bloom_filter`, which\nprovides addition and lookup via the virtual functions `add` and `lookup`.\nThese functions take an *object* as argument, which serves a light-weight view\nover sequential data for hashing.\n\nFor example, if you can create a basic Bloom filter with a desired\nfalse-positive probability and capacity as follows:\n\n    // Construction.\n    bloom_filter* bf = new basic_bloom_filter(0.8, 100);\n\n    // Addition.\n    bf-\u003eadd(\"foo\");\n    bf-\u003eadd(42);\n\n    // Lookup.\n    assert(bf-\u003elookup(\"foo\") == 1);\n    assert(bf-\u003elookup(42) == 1);\n\n    // Remove all elements from the Bloom filter.\n    bf-\u003eclear();\n\nIn this case, libbf computes the optimal number of hash functions needed to\nachieve the desired false-positive rate which holds until the capacity has been\nreached (80% and 100 distinct elements, in the above example). Alternatively,\nyou can construct a basic Bloom filter by specifying the number of hash\nfunctions and the number of cells in the underlying bit vector:\n\n    bloom_filter* bf = new basic_bloom_filter(make_hasher(3), 1024);\n\nSince not all Bloom filter implementations come with closed-form solutions\nbased on false-positive probabilities, most constructors use this latter form\nof explicit resource provisioning.\n\nIn the above example, the free function `make_hasher` constructs a *hasher*-an\nabstraction for hashing objects *k* times. There exist currently two different\nhasher, a `default_hasher` and a\n[`double_hasher`](http://www.eecs.harvard.edu/~kirsch/pubs/bbbf/rsa.pdf). The\nlatter uses a linear combination of two pairwise-independent, universal hash\nfunctions to produce the *k* digests, whereas the former merely hashes the\nobject *k* times.\n\nEvaluation\n----------\n\nlibbf also ships with a small Bloom filter tool `bf` in the test directory.\nThis program supports evaluation the accuracy of the different Bloom filter\nflavors with respect to their false-positive and false-negative rates. Have a\nlook at the console help (`-h` or `--help`) for detailed usage instructions.\n\nThe tool operates in two phases:\n\n1. Read input from a file and insert it into a Bloom filter\n2. Query the Bloom filter and compare the result to the ground truth\n\nFor example, consider the following input file:\n\n    foo\n    bar\n    baz\n    baz\n    foo\n\nFrom this input file, you can generate the real ground truth file as follows:\n\n    sort input.txt | uniq -c | tee query.txt\n       1 bar\n       2 baz\n       2 foo\n\nThe tool `bf` will compute false-positive and false-negative counts for each\nelement, based on the ground truth given. In the case of a simple counting\nBloom filter, an invocation may look like this:\n\n    bf -t counting -m 2 -k 3 -i input.txt -q query.txt | column -t\n\nYielding the following output:\n\n    TN  TP  FP  FN  G  C  E\n    0   1   0   0   1  1  bar\n    0   1   0   1   2  1  baz\n    0   1   0   2   2  1  foo\n\nThe column headings denote true negatives (`TN`), true positives (`TP`), false\npositives (`FP`), false negatives (`FN`), ground truth count (`G`), actual\ncount (`C`), and the queried element. The counts are cumulative to support\nincremental evaluation.\n\nVersioning\n==========\nWe follow [Semantic Versioning](http://semver.org/spec/v1.0.0.html). The version X.Y.Z indicates:\n\n* X is the major version (backward-incompatible),\n* Y is the minor version (backward-compatible), and\n* Z is the patch version (backward-compatible bug fix).\n\nLicense\n========\n\nlibbf comes with a BSD-style license (see [COPYING](COPYING) for details).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmavam%2Flibbf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmavam%2Flibbf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmavam%2Flibbf/lists"}