github.com/whiteboxio/flow@v0.0.3-0.20190918184116-508d75d68a2c/pkg/util/hash/jump_hash.go (about) 1 package hash 2 3 // <3 Damian 4 // https://medium.com/@dgryski/consistent-hashing-algorithmic-tradeoffs-ef6b8e2fcae8 5 6 func JumpHash(key uint64, numBuckets int) int32 { 7 var b int64 = -1 8 var j int64 9 10 for j < int64(numBuckets) { 11 b = j 12 key = key*2862933555777941757 + 1 13 j = int64(float64(b+1) * (float64(int64(1)<<31) / float64((key>>33)+1))) 14 } 15 16 return int32(b) 17 }