MCPcopy
hub / github.com/grafana/dskit / partitionByToken

Method partitionByToken

ring/partition_ring_model.go:85–95  ·  view source on GitHub ↗

partitionByToken returns a map where they key is a registered token and the value is ID of the partition that registered that token.

()

Source from the content-addressed store, hash-verified

83// partitionByToken returns a map where they key is a registered token and the value is ID of the partition
84// that registered that token.
85func (m *PartitionRingDesc) partitionByToken() map[Token]int32 {
86 out := make(map[Token]int32, len(m.Partitions)*optimalTokensPerInstance)
87
88 for partitionID, partition := range m.Partitions {
89 for _, token := range partition.Tokens {
90 out[Token(token)] = partitionID
91 }
92 }
93
94 return out
95}
96
97// CountTokens returns the summed token distance of all tokens in each partition.
98func (m *PartitionRingDesc) countTokens() map[int32]int64 {

Callers 3

countTokensMethod · 0.95

Calls 1

TokenTypeAlias · 0.85

Tested by 1