{"id":25585838,"url":"https://github.com/pawandubey/cuckoo_filter","last_synced_at":"2025-04-12T20:42:26.649Z","repository":{"id":55127427,"uuid":"79346895","full_name":"pawandubey/cuckoo_filter","owner":"pawandubey","description":"Pure Ruby Cuckoo Filter Implementation","archived":false,"fork":false,"pushed_at":"2021-01-08T04:24:04.000Z","size":25,"stargazers_count":119,"open_issues_count":0,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T15:23:34.428Z","etag":null,"topics":["cuckoo-filter","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/pawandubey.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}},"created_at":"2017-01-18T14:18:56.000Z","updated_at":"2024-10-04T07:03:25.000Z","dependencies_parsed_at":"2022-08-14T12:50:32.056Z","dependency_job_id":null,"html_url":"https://github.com/pawandubey/cuckoo_filter","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawandubey%2Fcuckoo_filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawandubey%2Fcuckoo_filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawandubey%2Fcuckoo_filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawandubey%2Fcuckoo_filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pawandubey","download_url":"https://codeload.github.com/pawandubey/cuckoo_filter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631669,"owners_count":21136554,"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":["cuckoo-filter","ruby"],"created_at":"2025-02-21T07:26:26.525Z","updated_at":"2025-04-12T20:42:26.626Z","avatar_url":"https://github.com/pawandubey.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.com/pawandubey/cuckoo_filter.svg?token=3cAzkSrcDxPpHpxsqQyX\u0026branch=master)](https://travis-ci.com/pawandubey/cuckoo_filter) [![codecov](https://codecov.io/gh/pawandubey/cuckoo_filter/branch/master/graph/badge.svg)](https://codecov.io/gh/pawandubey/cuckoo_filter)\n\n\n# CuckooFilter\n\nPure Ruby implementation of the [Cuckoo Filter](https://www.cs.cmu.edu/~dga/papers/cuckoo-conext2014.pdf) - a probabilistic datastructure which is objectively better than Bloom Filters for set-membership queries.\n\n## What the heck is a Cuckoo Filter?\n\nIt is a probabilistic data structure which is used to determine set-membership, i.e. finding out if a given element exists in a given set.\n\nFor practical uses think - checking if an item is present in a cache, if it is present in a database or YouTube trying to figure out if you have already watched some video before it is recommended to you.\n\nIt is closely related to Bloom Filters - but outshines them in performance and space efficiency. You can read more from the [original paper](https://www.cs.cmu.edu/~dga/papers/cuckoo-conext2014.pdf) that introduced it in 2014. Yes, it is that young!\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'cuckoo_filter'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install cuckoo_filter\n\n## Usage\n\n```ruby\n# Create a filter with 1024 (next power of 2) slots with each bucket holding 4\ncf = CuckooFilter.make(size: 1000, kicks: 500, bucket_size: 4)\n# =\u003e returns a CuckooFilter::CuckooFilter instance\n\n# Insert an element into the filter\ncf.insert(\"foo\")\n# =\u003e true\n\n# Lookup the existence of an element\ncf.lookup(\"foo\")\n# =\u003e true\n\ncf.lookup(\"bar\")\n# =\u003e false\n\n# Delete an existing element\ncf.delete(\"foo\")\n# =\u003e true\n```\n\n## Frequenty Anticipated Questions\n\n- Q: *Is this useful?* \u003c/br\u003e\n  A: Yes, but have a look at the benchmarks below to see if it satisfies your performance requirements before using it in a real world app.\n  \n- Q: *Why did you make this?*\u003c/br\u003e\n  A: For fun and education, of course! Although that is not stopping it from having any real world usage!\n  \n- Q: *But why Ruby? Why not Go/Rust/Elixir/FooBar*\u003c/br\u003e\n  A: Because why not? I like Ruby and I couldn't find a full blown implementation in it.\n  \n- Q: *Can I use it in a real project?*\u003c/br\u003e\n  A: If it satisfies your criteria, then why not? Have a look at the benchmarks for performance stats. Let me know if you do!\n  \n## Benchmarks\n\nYou can run the benchmark script to see the iterations per second performance of different methods on an initially half full filter.\n\n```\n$ ruby test/benchmark.rb\n\nSetting up for benchmarking...\nDone.\nWarming up --------------------------------------\n# warmup stats -\u003e can be ignored\n\nCalculating -------------------------------------\nIterations per second - Insertions\n                        214.863M (±47.1%) i/s -      1.214B in   9.859735s\nIterations per second - Lookups\n                        355.392M (±10.9%) i/s -      3.371B in   9.697599s\nIterations per second - Deletions\n                        343.890M (± 9.6%) i/s -      3.286B\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/pawandubey/cuckoo_filter.\n\n## License\n\nCopyright 2017 Pawan Dubey\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpawandubey%2Fcuckoo_filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpawandubey%2Fcuckoo_filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpawandubey%2Fcuckoo_filter/lists"}