{"id":19032489,"url":"https://github.com/creadone/guava","last_synced_at":"2025-02-21T20:28:01.302Z","repository":{"id":157563137,"uuid":"633551470","full_name":"creadone/guava","owner":"creadone","description":"Jump Consistent Hash","archived":false,"fork":false,"pushed_at":"2023-05-01T23:08:31.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-02T04:26:39.394Z","etag":null,"topics":["consistent-hashing","crystal"],"latest_commit_sha":null,"homepage":"","language":"C","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/creadone.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":"2023-04-27T18:47:53.000Z","updated_at":"2024-08-25T16:41:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"90141887-d43c-4d1a-9d04-44386d233cf8","html_url":"https://github.com/creadone/guava","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creadone%2Fguava","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creadone%2Fguava/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creadone%2Fguava/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/creadone%2Fguava/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/creadone","download_url":"https://codeload.github.com/creadone/guava/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240082640,"owners_count":19745257,"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":["consistent-hashing","crystal"],"created_at":"2024-11-08T21:28:55.692Z","updated_at":"2025-02-21T20:28:01.281Z","avatar_url":"https://github.com/creadone.png","language":"C","readme":"# Guava\n\nThis is a library with a fast and minimal memory-consuming hashing function also known as Jump [Consistent Hash](https://en.wikipedia.org/wiki/Consistent_hashing) from the original work \"A Fast, Minimal Memory, Consistent Hash Algorithm\" by Google (see [1406.2294v1.pdf](https://arxiv.org/pdf/1406.2294v1.pdf)).\n\n\u003e In comparison to the algorithm of Karger et al., jump consistent hash requires no storage, is faster, and does a better job of evenly dividing the key\nspace among the buckets and of evenly dividing the workload when the number of buckets changes.\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n  guava:\n    github: creadone/guava\n```\n\nThen run `shards install`.\n\n## Usage\n\n```crystal\nrequire \"guava\"\n\nGuava.jump(7234672323_u64, 12_i32) # =\u003e 9\n```\n\n## Tests\n\n### Data distribution\n\n```crystal\nrequire \"guava\"\n\nary = Array.new(10){ Array.new(1){ 0 } }\nvalues = (0_u64..1_000_000_u64).to_a\n\nvalues.each do |i|\n  num = Guava.jump(i, 10_i32)\n  ary[num].push 0\nend\n\nary.each_with_index do |cell, idx|\n  puts [idx, cell.size]\nend\n```\n\n**Result**\n\n| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |\n| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n| 100001 | 100001 | 100022 | 100004 | 99960 | 100058 | 99945 | 100070 | 99957 | 99992 |\n\n### CPU time to call\n\n\u003e 3,6 GHz Quad-Core Intel Core i3, Mac Mini 2018\n\n```crystal\nvalues = (0_u64..1_000_000_u64).to_a\n\nputs Benchmark.measure {\n  values.each do |i|\n    Guava.jump(i, 10_i32)\n  end\n}\n```\n**Result**\n\n| User CPU | System CPU | Sum of previous | Elapsed real time |\n| --------- | --------- | --------- | --------- |\n| 0.027966  | 0.000021  | 0.027987  | 0.028015 |\n\n## Contributing\n\n1. Fork it (https://github.com/creadone/guava/fork)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [creadone](https://github.com/creadone) - creator and maintainer\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreadone%2Fguava","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcreadone%2Fguava","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreadone%2Fguava/lists"}