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

Function MergeTokens

ring/model.go:730–745  ·  view source on GitHub ↗

MergeTokens takes in input multiple lists of tokens and returns a single list containing all tokens merged and sorted. Each input single list is required to have tokens already sorted.

(instances [][]uint32)

Source from the content-addressed store, hash-verified

728// containing all tokens merged and sorted. Each input single list is required
729// to have tokens already sorted.
730func MergeTokens(instances [][]uint32) []uint32 {
731 numTokens := 0
732
733 for _, tokens := range instances {
734 numTokens += len(tokens)
735 }
736
737 tree := loser.New(instances, math.MaxUint32)
738 out := make([]uint32, 0, numTokens)
739
740 for tree.Next() {
741 out = append(out, tree.Winner())
742 }
743
744 return out
745}
746
747// MergeTokensByZone is like MergeTokens but does it for each input zone.
748func MergeTokensByZone(zones map[string][][]uint32) map[string][]uint32 {

Callers 3

GetTokensMethod · 0.85
MergeTokensByZoneFunction · 0.85
TestMergeTokensFunction · 0.85

Calls 3

NewFunction · 0.92
WinnerMethod · 0.80
NextMethod · 0.65

Tested by 1

TestMergeTokensFunction · 0.68