{"id":17795318,"url":"https://github.com/jbapple/libfilter","last_synced_at":"2025-03-16T22:32:04.959Z","repository":{"id":37639252,"uuid":"266427422","full_name":"jbapple/libfilter","owner":"jbapple","description":"High-speed Bloom filters and taffy filters for C, C++, and Java","archived":false,"fork":false,"pushed_at":"2023-08-09T23:57:38.000Z","size":2222,"stargazers_count":25,"open_issues_count":18,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2023-08-10T00:44:37.832Z","etag":null,"topics":["bloom-filter","bloom-filters","bloomfilter","c","cpp","data-structures","java","library"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jbapple.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-23T22:07:45.000Z","updated_at":"2023-02-08T01:47:42.000Z","dependencies_parsed_at":"2022-07-12T16:35:06.169Z","dependency_job_id":null,"html_url":"https://github.com/jbapple/libfilter","commit_stats":null,"previous_names":[],"tags_count":4,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbapple%2Flibfilter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbapple%2Flibfilter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbapple%2Flibfilter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbapple%2Flibfilter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jbapple","download_url":"https://codeload.github.com/jbapple/libfilter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221668881,"owners_count":16860747,"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","bloom-filters","bloomfilter","c","cpp","data-structures","java","library"],"created_at":"2024-10-27T11:29:49.444Z","updated_at":"2024-10-27T11:29:50.006Z","avatar_url":"https://github.com/jbapple.png","language":"C++","readme":"![](https://github.com/jbapple/libfilter/workflows/unit-tests/badge.svg?branch=master)\n\nThis repository provides implementations of various Bloom filters and\ntaffy filters for C, C++, Java, Python, and Go.\n\nIf you need a basic filter and you know ahead of time which keys will be in it, use a static filter.\n\nIf you don't know what the keys will be, but you know approximately how many there are, use a block filter.\n\nOtherwise, use a taffy filter, which can grow as you add more keys to it.\n\nExample usage of block filter in C:\n\n```C\n#include \u003cfilter/block.h\u003e\n\nunsigned ndv = 1000000;\ndouble fpp = 0.0065;\nuint64_t hash = 0xfeedbadbee52b055;\n\nlibfilter_block filter;\n\nunsigned bytes = libfilter_block_bytes_needed(ndv, fpp);\nlibfilter_block_init(bytes, \u0026filter);\nlibfilter_block_add_hash(hash, \u0026filter);\nassert(libfilter_block_find_hash(hash, \u0026filter));\nlibfilter_block_destruct(\u0026filter);\n```\n\nin C++:\n\n```C++\n#include \u003cfilter/block.hpp\u003e\n\nunsigned ndv = 1000000;\ndouble fpp = 0.0065;\nuint64_t hash = 0xfeedbadbee52b055;\n\nauto filter = filter::BlockFilter::CreateWithNdvFpp(ndv, fpp);\nfilter.InsertHash(hash);\nassert(filter.FindHash(hash));\n```\n\nin Java\n\n```Java\nimport com.github.jbapple.libfilter.BlockFilter;\n\nint ndv = 1000000;\ndouble fpp = 0.0065;\nlong hash = (((long) 0xfeedbadb) \u003c\u003c 32) | (long) 0xee52b055;\n\nBlockFilter = BlockFilter.CreateWithNdvFpp(ndv, fpp);\nfilter.AddHash64(hash);\nassert filter.FindHash64(hash)\n```\n\nin Go\n\n```Go\nimport (\"github.com/jbapple/libfilter\")\n\nb := NewBlockFilter(BlockBytesNeeded(1000000, 0.0065))\nvar hash uint64\nhash = 0xfeedbadbee52b055\nb.AddHash(hash)\nif !b.FindHash(hash) {\n    panic(\"uhoh!\")\n}\n```\n\nin Python\n\n```Python\nimport block\n\nb = block.Block(1000000, 0.0065)\nhash = 0xfeedbadbee52b055\nb += hash\nassert (hash in b)\n```\n\nTo install:\n\n```shell\nmake\n# probably needs a sudo:\nmake install\nmake java-world\nmvn -f ./java/ install -Dmaven.test.skip=true\n[optional: copy java/target/libfilter-*.jar to your classpath]\nmake python-world\nmake go-world\n```\n\nThe C and C++ libraries can also be installed with CMake:\n```shell\ncmake -B build -S . -DCMAKE_INSTALL_PATH=\u003cwhere/to/install\u003e\ncmake --build build\n# probably needs a sudo:\ncmake --install build\n```\n\nThe library targets are exported and can be used in `CMakeLists.txt`:\n```cmake\nfind_package(libfilter)\n# The C API:\ntarget_link_libraries(mylib PRIVATE libfilter::c)\n# The C++ API:\ntarget_link_libraries(mylib PRIVATE libfilter::cxx)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbapple%2Flibfilter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjbapple%2Flibfilter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbapple%2Flibfilter/lists"}