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

Function FastFingerprint

pkg/ingester/client/compat.go:290–304  ·  view source on GitHub ↗

FastFingerprint runs the same algorithm as Prometheus labelSetToFastFingerprint()

(ls []cortexpb.LabelAdapter)

Source from the content-addressed store, hash-verified

288
289// FastFingerprint runs the same algorithm as Prometheus labelSetToFastFingerprint()
290func FastFingerprint(ls []cortexpb.LabelAdapter) model.Fingerprint {
291 if len(ls) == 0 {
292 return model.Metric(nil).FastFingerprint()
293 }
294
295 var result uint64
296 for _, l := range ls {
297 sum := hashNew()
298 sum = hashAdd(sum, l.Name)
299 sum = hashAddByte(sum, model.SeparatorByte)
300 sum = hashAdd(sum, l.Value)
301 result ^= sum
302 }
303 return model.Fingerprint(result)
304}
305
306// LabelsToKeyString is used to form a string to be used as
307// the hashKey. Don't print, use l.String() for printing.

Callers 1

AddSeriesMethod · 0.92

Calls 4

hashNewFunction · 0.70
hashAddFunction · 0.70
hashAddByteFunction · 0.70
MetricMethod · 0.45

Tested by

no test coverage detected