partitionByToken returns a map where they key is a registered token and the value is ID of the partition that registered that token.
()
| 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. |
| 85 | func (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. |
| 98 | func (m *PartitionRingDesc) countTokens() map[int32]int64 { |