MCPcopy Create free account
hub / github.com/cortexproject/cortex / tokenDistance

Function tokenDistance

pkg/ring/token_generator.go:282–288  ·  view source on GitHub ↗

tokenDistance returns the distance between the given tokens from and to. The distance between a token and itself is the whole ring, i.e., math.MaxUint32 + 1.

(from, to uint32)

Source from the content-addressed store, hash-verified

280// tokenDistance returns the distance between the given tokens from and to.
281// The distance between a token and itself is the whole ring, i.e., math.MaxUint32 + 1.
282func tokenDistance(from, to uint32) int64 {
283 if from < to {
284 return int64(to - from)
285 }
286 // the trailing +1 is needed to ensure that token 0 is counted
287 return maxTokenValue - int64(from) + int64(to) + 1
288}
289
290func findFirst(n int, f func(int) bool) int {
291 for i := range n {

Callers 4

countTokensByAzMethod · 0.85
countTokensMethod · 0.85
GenerateTokensMethod · 0.85

Calls

no outgoing calls

Tested by 1