{"id":18578972,"url":"https://github.com/patrickmn/go-bloom","last_synced_at":"2025-04-10T10:31:23.720Z","repository":{"id":3402846,"uuid":"4452725","full_name":"patrickmn/go-bloom","owner":"patrickmn","description":"Boolean, counting and layered bloom filters for Go","archived":false,"fork":false,"pushed_at":"2012-05-28T01:46:48.000Z","size":132,"stargazers_count":22,"open_issues_count":1,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-04T04:32:09.002Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://patrickmn.com/projects/go-bloom/","language":"Go","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/patrickmn.png","metadata":{"files":{"readme":"README","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}},"created_at":"2012-05-26T04:44:30.000Z","updated_at":"2021-06-24T12:55:02.000Z","dependencies_parsed_at":"2022-09-05T16:30:40.667Z","dependency_job_id":null,"html_url":"https://github.com/patrickmn/go-bloom","commit_stats":null,"previous_names":["pmylund/go-bloom"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickmn%2Fgo-bloom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickmn%2Fgo-bloom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickmn%2Fgo-bloom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickmn%2Fgo-bloom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patrickmn","download_url":"https://codeload.github.com/patrickmn/go-bloom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199136,"owners_count":21063641,"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-11-06T23:38:27.264Z","updated_at":"2025-04-10T10:31:23.284Z","avatar_url":"https://github.com/patrickmn.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"go-bloom is a collection of bloom filters for Go, including a standard bloom\nfilter, a counting bloom filter, and a layered bloom filter (for counting\noccurrences of the same item.) All of them use the 64-bit FNV-1 hash function\nand an efficient bitset.\n\nA bloom filter is a space-efficient probabilistic data structure that is used\nto test whether an element is a member of a set. False positives are possible,\nbut false negatives are not; i.e. a query returns either \"inside set (may be\nwrong)\" or \"definitely not in set\". Elements can be added to the set, but not\nremoved (though this can be addressed with a counting filter.)\n\n== Installation\n\ngo get github.com/pmylund/go-bloom\n\n== Documentation\n\ngo doc github.com/pmylund/go-bloom\nor http://go.pkgdoc.org/github.com/pmylund/go-bloom\n\n== Usage\n\nimport \"github.com/pmylund/go-bloom\"\n\n// Normal bloom filter\n\n// Create a bloom filter which will contain an expected 100,000 items, and which\n// allows a false positive rate of 1%.\nf := bloom.New(100000, 0.01)\n\n// Add an item to the filter\nf.Add([]byte(\"foo\"))\n\n// Check if an item has been added to the filter (if true, subject to the\n// false positive chance; if false, then the item definitely has not been\n// added to the filter.)\nf.Test([]byte(\"foo\"))\n\n\n// Counting bloom filter\n\n// Create a counting bloom filter which will contain an expected 100,000 items,\n// and which allows a false positive rate of 1%.\nf := bloom.NewCounting(100000, 0.01)\n\n// Add an item to the counting filter\nf.Add([]byte(\"foo\"))\n\n// Remove an item from the counting filter\nf.Remove([]byte(\"foo\"))\n\n\n// Layered bloom filter\n\n// Create a layered bloom filter which will contain an expected 100,000 items,\n// and which allows a false positive rate of 1%.\nf := bloom.NewLayered(100000, 0.01)\n\n// Add an item to the layered filter\nf.Add([]byte(\"foo\"))\n\n// Add an item to the layered filter again\nf.Add([]byte(\"foo\"))\n\n// Find out how many times an item appears in the layered filter\ncount := f.Test([]byte(\"foo\")\ncount == 2\n\nTo use go-bloom in multiple goroutines, use a sync.RWMutex, and surround test\ncalls with RLock()/RUnlock(), and set calls with Lock()/()Unlock.\n\n\ngo-bloom is based on bloom by Will Fitzgerald.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrickmn%2Fgo-bloom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrickmn%2Fgo-bloom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrickmn%2Fgo-bloom/lists"}