v8.run/go/exp@v0.0.26-0.20230226010534-afcdbd3f782d/hash/jump/jump.go (about)

     1  package jump
     2  
     3  //go:nosplit
     4  //JumpConsistentHash: https://arxiv.org/abs/1406.2294
     5  func JumpConsistentHash(key uint64, num_buckets int32) int32 {
     6  	var b, j int64 = -1, 0
     7  	for j < int64(num_buckets) {
     8  		b = j
     9  		key = key*2862933555777941757 + 1
    10  		j = int64(float64(b+1) * (float64(1<<31) / float64((key>>33)+1)))
    11  	}
    12  	return int32(b)
    13  }