{"id":20122888,"url":"https://github.com/freaky/blooming-ruby","last_synced_at":"2026-06-05T06:31:33.645Z","repository":{"id":142942494,"uuid":"144338605","full_name":"Freaky/blooming-ruby","owner":"Freaky","description":"Ruby BitArray and BloomFilter library","archived":false,"fork":false,"pushed_at":"2018-08-10T22:47:20.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-02T20:30:56.116Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/Freaky.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-10T22:47:09.000Z","updated_at":"2018-11-07T07:34:51.000Z","dependencies_parsed_at":"2023-05-01T10:16:06.074Z","dependency_job_id":null,"html_url":"https://github.com/Freaky/blooming-ruby","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Freaky/blooming-ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freaky%2Fblooming-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freaky%2Fblooming-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freaky%2Fblooming-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freaky%2Fblooming-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Freaky","download_url":"https://codeload.github.com/Freaky/blooming-ruby/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freaky%2Fblooming-ruby/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33932048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-05T02:00:06.157Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-13T19:41:41.001Z","updated_at":"2026-06-05T06:31:33.613Z","avatar_url":"https://github.com/Freaky.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blooming Ruby\n\nYet another Ruby [bloom filter](https://en.wikipedia.org/wiki/Bloom_filter),\nand a new bit array implementation, including a speedy JRuby-specific version.\n\nThis was extracted from an experiment in leaked password list processing,\nbefore I moved on to Golomb Compressed Sets, and might be worth extracting\ninto a proper gem at some point.\n\n## Synopsis\n\n### BitArray\n\nThere's also a `bit_array_jruby` which uses `java.util.BitSet` under the hood.\n\n```ruby\nrequire 'blooming/bit_array'\n\n# Array of 128 bits\nba = Blooming::BitArray.new(128)\nba.set!(1).set!(2).flip!(1).flip!(2).none? # true\nba.set!(1).set!(2).cardinality # =\u003e 2\nba.set?(1) # =\u003e true\nba.to_s # =\u003e raw bits\nba.each.to_a # =\u003e [false, true, true, false, false, ...]\n\nba2 = BitArray.new(ba.to_s) # a second BitArray identical to the first\nba2.clear! # and now it's empty\n```\n\n### BloomFilter\n\nSplit into two classes - a flexible calculator for parameters, and the\nfilter itself.\n\n```ruby\nrequire 'blooming/bloom_filter_params'\nrequire 'blooming/bloom_filter' # Implied by above\n\n# Size a filter for 1,000 items with a 0.0001 false-positive rate\nbfp = Blooming::BloomFilterParams.new(n: 1000, p: 0.0001)\nbf = bf.to_filter\n\nbf.add \"foo\"\nbf \u003c\u003c \"bar\"\nbf.include? \"foo\" # =\u003e true\nbf.add? \"foo\" # =\u003e false\nbf.add? \"baz\" # =\u003e true\nbf.add? \"baz\" # =\u003e false\nbf.estimate_count # =\u003e 3-ish\nbf.count # =\u003e alias for above\nbf.empty? # =\u003e false\nbf.clear!\nbf.empty? # =\u003e true\n1000.times { |i| bf \u003c\u003c i }\nbf.saturated?  # =\u003e true (adding more items violates desired false-positive rate)\nbf.full? # =\u003e true (alias)\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreaky%2Fblooming-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreaky%2Fblooming-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreaky%2Fblooming-ruby/lists"}