MCPcopy
hub / github.com/grafana/tempo / jumpHash

Function jumpHash

pkg/cache/memcached_client_selector.go:90–101  ·  view source on GitHub ↗

jumpHash consistently chooses a hash bucket number in the range [0, numBuckets) for the given key. numBuckets must be >= 1. Copied from github.com/dgryski/go-jump/blob/master/jump.go

(key uint64, numBuckets int)

Source from the content-addressed store, hash-verified

88//
89// Copied from github.com/dgryski/go-jump/blob/master/jump.go
90func jumpHash(key uint64, numBuckets int) int32 {
91 var b int64 = -1
92 var j int64
93
94 for j < int64(numBuckets) {
95 b = j
96 key = key*2862933555777941757 + 1
97 j = int64(float64(b+1) * (float64(int64(1)<<31) / float64((key>>33)+1)))
98 }
99
100 return int32(b)
101}
102
103// PickServer returns the server address that a given item
104// should be shared onto.

Callers 1

PickServerMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected