https://github.com/mtchavez/jumpconshash
Jump Consistent Hash in Go
https://github.com/mtchavez/jumpconshash
go hashes jump-consistent-hash
Last synced: about 2 months ago
JSON representation
Jump Consistent Hash in Go
- Host: GitHub
- URL: https://github.com/mtchavez/jumpconshash
- Owner: mtchavez
- License: mit
- Created: 2014-11-03T02:04:18.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-04-13T19:26:31.000Z (about 6 years ago)
- Last Synced: 2025-02-04T15:32:32.100Z (4 months ago)
- Topics: go, hashes, jump-consistent-hash
- Language: Go
- Homepage: http://godoc.org/github.com/mtchavez/jumpconshash
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Jump Consistent Hash
[](https://travis-ci.org/mtchavez/jumpconshash)
[](http://godoc.org/github.com/mtchavez/jumpconshash)
[](https://goreportcard.com/report/github.com/mtchavez/jumpconshash)
[](https://codeclimate.com/github/mtchavez/jumpconshash/maintainability)
[](https://codeclimate.com/github/mtchavez/jumpconshash/test_coverage)Jump consistent hash implementation in Go.
## Background
Based on [this whitepaper](http://www.smallake.kr/wp-content/uploads/2014/08/1406.2294.pdf) from Google. Jump consistent hash takes an integer key and a total number of buckets to consider and hashes the key into one of the buckets. The algorithm achieves minimal memory consumption and fast hashing that has a small change in hashing as total buckets change.
## Docs
Docs are on [GoDoc](http://godoc.org/github.com/mtchavez/jumpconshash)
## Tests
Tests can be ran with `go test --cover`
## Usage
[Example usage](http://godoc.org/github.com/mtchavez/jumpconshash#example-Hash)
```go
// Hash takes the integer key you want
// to find the bucket it is hashed to
// and the total number of buckets to consider
totalBuckets := 100
bucket := Hash(123456789, totalBuckets)// The bucket for the key is returned
fmt.Printf("Hash(123456789, 100) is bucket %+v", bucket)
```