{"id":16092267,"url":"https://github.com/alecthomas/mph","last_synced_at":"2025-04-09T05:12:15.297Z","repository":{"id":8967163,"uuid":"10708570","full_name":"alecthomas/mph","owner":"alecthomas","description":"Minimal Perfect Hashing for Go","archived":false,"fork":false,"pushed_at":"2024-09-04T18:52:14.000Z","size":773,"stargazers_count":181,"open_issues_count":6,"forks_count":23,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-02T04:04:58.793Z","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":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alecthomas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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":"2013-06-15T16:07:37.000Z","updated_at":"2025-03-08T03:20:38.000Z","dependencies_parsed_at":"2024-06-18T14:07:48.634Z","dependency_job_id":"851abdfa-e7a5-4855-8691-2f2df88b0914","html_url":"https://github.com/alecthomas/mph","commit_stats":{"total_commits":32,"total_committers":6,"mean_commits":5.333333333333333,"dds":0.25,"last_synced_commit":"2a0c46a2ff469eebf5abd5f3da3205c74b7da8a2"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Fmph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Fmph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Fmph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alecthomas%2Fmph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alecthomas","download_url":"https://codeload.github.com/alecthomas/mph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247980844,"owners_count":21027808,"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-10-09T16:06:28.268Z","updated_at":"2025-04-09T05:12:15.261Z","avatar_url":"https://github.com/alecthomas.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Minimal Perfect Hashing for Go\n\nThis library provides [Minimal Perfect Hashing](http://en.wikipedia.org/wiki/Perfect_hash_function) (MPH) using the [Compress, Hash and Displace](http://cmph.sourceforge.net/papers/esa09.pdf) (CHD) algorithm.\n\n## What is this useful for?\n\nPrimarily, extremely efficient access to potentially very large static datasets, such as geographical data, NLP data sets, etc.\n\nOn my 2012 vintage MacBook Air, a benchmark against a wikipedia index with 300K keys against a 2GB TSV dump takes about ~200ns per lookup.\n\n## How would it be used?\n\nTypically, the table would be used as a fast index into a (much) larger data set, with values in the table being file offsets or similar.\n\nThe tables can be serialized. Numeric values are written in little endian form.\n\n## Example code\n\nBuilding and serializing an MPH hash table (error checking omitted for clarity):\n\n```go\nb := mph.Builder()\nfor k, v := range data {\n    b.Add(k, v)\n}\nh, _ := b.Build()\nw, _ := os.Create(\"data.idx\")\n_ := h.Write(w)\n```\n\nDeserializing the hash table and performing lookups:\n\n```go\nr, _ := os.Open(\"data.idx\")\nh, _ := mph.Read(r)\n\nv := h.Get([]byte(\"some key\"))\nif v == nil {\n    // Key not found\n}\n```\n\nMMAP is also indirectly supported, by deserializing from a byte slice and slicing the keys and values.\n\nThe [API documentation](http://godoc.org/github.com/alecthomas/mph) has more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falecthomas%2Fmph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falecthomas%2Fmph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falecthomas%2Fmph/lists"}