{"id":29151233,"url":"https://github.com/karpeleslab/elastichash","last_synced_at":"2025-07-01T00:08:57.805Z","repository":{"id":283394240,"uuid":"951534982","full_name":"KarpelesLab/elastichash","owner":"KarpelesLab","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-20T01:44:37.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T02:40:11.131Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/KarpelesLab.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-19T20:44:49.000Z","updated_at":"2025-03-20T01:44:41.000Z","dependencies_parsed_at":"2025-03-20T04:00:46.272Z","dependency_job_id":null,"html_url":"https://github.com/KarpelesLab/elastichash","commit_stats":null,"previous_names":["karpeleslab/elastichash"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/KarpelesLab/elastichash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarpelesLab%2Felastichash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarpelesLab%2Felastichash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarpelesLab%2Felastichash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarpelesLab%2Felastichash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KarpelesLab","download_url":"https://codeload.github.com/KarpelesLab/elastichash/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarpelesLab%2Felastichash/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262870877,"owners_count":23377314,"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":"2025-07-01T00:08:55.091Z","updated_at":"2025-07-01T00:08:57.792Z","avatar_url":"https://github.com/KarpelesLab.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ElasticHash\n\nThis project provides a Go implementation of two novel open-addressing hash table algorithms described in the paper [Optimal Bounds for Open Addressing Without Reordering](https://arxiv.org/abs/2501.02305) by Martin Farach-Colton, Shalev Ben-David, and Meng-Tsung Tsai.\n\n## About the Algorithms\n\nThe paper introduces two innovative hash table strategies that achieve better expected probe complexities than classical methods without moving elements after insertion (no reordering):\n\n1. **Elastic Hashing** (Non-greedy): Uses a multi-level table and a two-dimensional probe sequence, achieving O(1) amortized expected search cost and O(log(1/δ)) worst-case expected search cost (for a table load factor of 1-δ).\n\n2. **Funnel Hashing** (Greedy): A simpler greedy strategy that partitions the hash table into geometrically decreasing levels with fixed-size buckets, achieving O((log(1/δ))²) worst-case expected probes.\n\nBoth methods cleverly structure the table into multiple segments to break the traditional coupon-collector bottleneck in hash table probing.\n\n## Implementation\n\nThis repository contains:\n\n- `elastic_hash.go`: Implementation of Elastic Hashing\n- `funnel_hash.go`: Implementation of Funnel Hashing\n- `hash_test.go`: Tests and benchmarks for both implementations\n- `example/example.go`: Example usage of both hash tables\n\n## Usage\n\n```go\nimport \"elastichash\"\n\n// Create an Elastic Hash Table\nN := 100         // Total size of the table\ndelta := 0.25    // Fraction of slots to leave empty\neht := elastichash.NewElasticHashTable(N, delta)\n\n// Insert keys\neht.Insert(42)\n\n// Check if key exists\nexists := eht.Contains(42)\n\n// Create a Funnel Hash Table\nbucketSize := 4  // Number of slots per bucket\nfht := elastichash.NewFunnelHashTable(N, bucketSize, delta)\n\n// Insert and lookup operations are the same\nfht.Insert(42)\nexists = fht.Contains(42)\n```\n\n## Performance\n\nBoth hash tables are designed to offer better theoretical guarantees than traditional open addressing at high load factors. In general:\n\n- Elastic Hashing provides O(1) amortized expected search cost\n- Funnel Hashing is simpler and may have better practical performance in some cases\n\nRun the benchmarks to compare their performance on your machine:\n\n```\ngo test -bench=.\n```\n\nSee [BENCHMARKS.md](BENCHMARKS.md) for detailed performance comparisons between the ElasticHash, FunnelHash, and Go's built-in map implementation. Our benchmark results show that:\n\n1. FunnelHash performs competitively with Go's built-in map for insertions\n2. Go's built-in map generally outperforms both custom implementations for lookups\n3. Performance characteristics vary based on load factor and table size\n\n## Paper Abstract\n\n\u003e Farach-Colton et al. paper \"Optimal Bounds for Open Addressing Without Reordering\" introduces two novel open-address hash table strategies that achieve much better expected probe complexities than classical methods. Both methods avoid reordering (once an item is placed, it never moves), yet they cleverly structure the table into multiple segments (or \"levels\") to break the traditional coupon-collector bottleneck in hash table probing.\n\n## License\n\nThis implementation is provided under the MIT License. Copyright (c) 2025 Karpeles Lab Inc.\n\n## Reference\n\nFarach-Colton, M., Ben-David, S., \u0026 Tsai, M. (2024). Optimal Bounds for Open Addressing Without Reordering. arXiv:2501.02305. [https://arxiv.org/abs/2501.02305](https://arxiv.org/abs/2501.02305)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarpeleslab%2Felastichash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarpeleslab%2Felastichash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarpeleslab%2Felastichash/lists"}