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

Method labelSetExists

pkg/util/labelset/tracker.go:84–97  ·  view source on GitHub ↗

labelSetExists is used for testing only to check the existence of a label set.

(userId string, hash uint64, labelSet labels.Labels)

Source from the content-addressed store, hash-verified

82
83// labelSetExists is used for testing only to check the existence of a label set.
84func (m *LabelSetTracker) labelSetExists(userId string, hash uint64, labelSet labels.Labels) bool {
85 s := m.shards[util.HashFP(model.Fingerprint(hash))%numMetricShards]
86 s.RLock()
87 defer s.RUnlock()
88 userEntry, ok := s.userLabelSets[userId]
89 if !ok {
90 return false
91 }
92 set, ok := userEntry[hash]
93 if !ok {
94 return false
95 }
96 return labels.Compare(set, labelSet) == 0
97}
98
99// userExists is used for testing only to check the existence of a user.
100func (m *LabelSetTracker) userExists(userId string) bool {

Callers 1

TestLabelSetTrackerFunction · 0.95

Calls 2

HashFPFunction · 0.92
CompareMethod · 0.65

Tested by 1

TestLabelSetTrackerFunction · 0.76