{"id":16701441,"url":"https://github.com/ferd/lrw","last_synced_at":"2025-03-17T00:33:56.608Z","repository":{"id":57518749,"uuid":"20700056","full_name":"ferd/lrw","owner":"ferd","description":"Lowest Random Weight hashing for neatly rebalancing hashes","archived":false,"fork":false,"pushed_at":"2018-02-02T01:11:20.000Z","size":7,"stargazers_count":45,"open_issues_count":0,"forks_count":5,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-02-27T15:37:57.633Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Erlang","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/ferd.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}},"created_at":"2014-06-10T20:14:17.000Z","updated_at":"2023-10-24T20:43:51.000Z","dependencies_parsed_at":"2022-09-26T18:01:45.428Z","dependency_job_id":null,"html_url":"https://github.com/ferd/lrw","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferd%2Flrw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferd%2Flrw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferd%2Flrw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferd%2Flrw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ferd","download_url":"https://codeload.github.com/ferd/lrw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243835942,"owners_count":20355611,"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-12T18:44:05.635Z","updated_at":"2025-03-17T00:33:56.304Z","avatar_url":"https://github.com/ferd.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rendezvous or Lowest Random Weight (LRW) hashing #\n\nThis is an Erlang implementation of LRW (equivalent to HRW), an algorithm that allows\nclients to achieve distributed agreement on which site (or proxy) a given\nobject is to be placed in. It accomplishes the same goal as consistent hashing,\nusing an entirely different method.\n\nThis hashing mechanism allows to consistently hash to specific IP addresses, without\nneeding to do bucketing at first, or ever keeping a fixed or ever-increasing amount\nof entries, while guaranteeing as little key redistribution as possible.\n\n- [http://en.wikipedia.org/wiki/Rendezvous\\_hashing](http://en.wikipedia.org/wiki/Rendezvous_hashing)\n- [\"A Name-Based Mapping Scheme for Rendezvous\" (PDF)](http://www.eecs.umich.edu/techreports/cse/96/CSE-TR-316-96.pdf)\n\n## Interface ##\n\nThe `all/2` function gives an ordering of all nodes:\n\n    1\u003e lrw:all(my_item, [{127,0,0,1},{255,0,0,1},{198,2,1,2},{192,198,2,1}]).\n    [{192,198,2,1},{127,0,0,1},{255,0,0,1},{198,2,1,2}]\n    2\u003e lrw:all(my_item, [{127,0,0,1},{198,2,1,2},{192,198,2,1},{10,10,100,10}]).\n    [{192,198,2,1},{127,0,0,1},{198,2,1,2},{10,10,100,10}]\n    3\u003e lrw:all(my_item, [{127,0,0,1},{192,198,2,1}]).\n    [{192,198,2,1},{127,0,0,1}]\n    4\u003e lrw:all(my_item, [{127,0,0,1},{192,18,211,12}, {23,66,77,88}, {252,11,11,11}]).\n    [{252,11,11,11},{127,0,0,1},{23,66,77,88},{192,18,211,12}]\n    5\u003e lrw:all(\"my other item\", [{127,0,0,1},{192,18,211,12}, {23,66,77,88}, {252,11,11,11}]).\n    [{23,66,77,88},{127,0,0,1},{252,11,11,11},{192,18,211,12}]\n    6\u003e lrw:all(\u003c\u003c\"my other item\"\u003e\u003e, [{127,0,0,1},{192,18,211,12}, {23,66,77,88}, {252,11,11,11}]).\n    [{252,11,11,11},{23,66,77,88},{127,0,0,1},{192,18,211,12}]\n\nThe `top/3` functions returns a subset. It is using `all/2` in its implementation:\n\n    1\u003e lrw:top(12123, [{127,0,0,1},{255,0,0,1},{198,2,1,2},{192,198,2,1}], 2).\n    [{192,198,2,1},{127,0,0,1}]\n\nThe list of nodes can be any data type; not just IPs. For IPv4s, optimized\nfunctions respecting the original algorithm from the paper is implemented in\n`lrw:all_ip/2` and `lrw:top_ip/3`.\n\nCustom hashing functions can be passed by calling `lrw:all/3` and\n`lrw:top/4`, where the last argument of each function must be\na fun of the form `fun(Key, Node) -\u003e Number end`.\n\n## Building ##\n\nPullit in your projects. Compile standalone using rebar (you should have this\ninstalled globally on your node already, it's been in use for years, come on!):\n\n    $ rebar compile\n\n## Running Tests ##\n\nVerify for type errors and discrepancies:\n\n    $ dialyzer --src src/*.erl\n\nThen run the property-based tests (10,000 each) with:\n\n    $ rebar get-deps compile eunit --config rebar.tests.config\n\n## Changelog ##\n\n- `2.0.1`: make hex-compatible and publish\n- `2.0.0`: `all/2-3` and `top/3-4` are generic, and `all_ip/2` and `top_ip/3`\n           are optimized for IPs and respect the original algorithm.\n- `1.1.0`: Adding `all_/2`, `top_/3`, `all/3`, and `top/4` to support\n  generic hashing.\n- `1.0.0`: Initial commit\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fferd%2Flrw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fferd%2Flrw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fferd%2Flrw/lists"}