Source File
signature.go
Belonging Package
github.com/prometheus/common/model
package model
import (
)
const SeparatorByte byte = 255
emptyLabelSignature = hashNew()
)
func ( map[string]string) uint64 {
if len() == 0 {
return emptyLabelSignature
}
:= make([]string, 0, len())
for := range {
= append(, )
}
sort.Strings()
:= hashNew()
for , := range {
= hashAdd(, )
= hashAddByte(, SeparatorByte)
= hashAdd(, [])
= hashAddByte(, SeparatorByte)
}
return
}
func ( LabelSet) Fingerprint {
if len() == 0 {
return Fingerprint(emptyLabelSignature)
}
:= make(LabelNames, 0, len())
for := range {
= append(, )
}
sort.Sort()
:= hashNew()
for , := range {
= hashAdd(, string())
= hashAddByte(, SeparatorByte)
= hashAdd(, string([]))
= hashAddByte(, SeparatorByte)
}
return Fingerprint()
}
func ( LabelSet) Fingerprint {
if len() == 0 {
return Fingerprint(emptyLabelSignature)
}
var uint64
for , := range {
:= hashNew()
= hashAdd(, string())
= hashAddByte(, SeparatorByte)
= hashAdd(, string())
^=
}
return Fingerprint()
}
func ( Metric, ...LabelName) uint64 {
if len() == 0 {
return emptyLabelSignature
}
sort.Sort(LabelNames())
:= hashNew()
for , := range {
= hashAdd(, string())
= hashAddByte(, SeparatorByte)
= hashAdd(, string([]))
= hashAddByte(, SeparatorByte)
}
return
}
func ( Metric, map[LabelName]struct{}) uint64 {
if len() == 0 {
return emptyLabelSignature
}
:= make(LabelNames, 0, len())
for := range {
if , := []; ! {
= append(, )
}
}
if len() == 0 {
return emptyLabelSignature
}
sort.Sort()
:= hashNew()
for , := range {
= hashAdd(, string())
= hashAddByte(, SeparatorByte)
= hashAdd(, string([]))
= hashAddByte(, SeparatorByte)
}
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |