mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-20 07:19:17 +01:00
lib/storage: inline marshalTags function and remove the code for handling duplicate tags from here
This is a follow-up commit after c8ea697db8
This commit is contained in:
parent
c8ea697db8
commit
31ec79eaf6
@ -375,7 +375,11 @@ func (mn *MetricName) Marshal(dst []byte) []byte {
|
||||
dst = marshalTagValue(dst, mn.MetricGroup)
|
||||
|
||||
// Marshal tags.
|
||||
dst = marshalTags(dst, mn.Tags)
|
||||
tags := mn.Tags
|
||||
for i := range tags {
|
||||
t := &tags[i]
|
||||
dst = t.Marshal(dst)
|
||||
}
|
||||
return dst
|
||||
}
|
||||
|
||||
@ -635,20 +639,6 @@ func (ts *canonicalTagsSort) Swap(i, j int) {
|
||||
x[i], x[j] = x[j], x[i]
|
||||
}
|
||||
|
||||
func marshalTags(dst []byte, tags []Tag) []byte {
|
||||
var prevKey []byte
|
||||
for i := range tags {
|
||||
t := &tags[i]
|
||||
if string(prevKey) == string(t.Key) {
|
||||
// Skip duplicate keys, since they aren't allowed in Prometheus data model.
|
||||
continue
|
||||
}
|
||||
prevKey = t.Key
|
||||
dst = t.Marshal(dst)
|
||||
}
|
||||
return dst
|
||||
}
|
||||
|
||||
func copyTags(dst, src []Tag) []Tag {
|
||||
dstLen := len(dst)
|
||||
if n := dstLen + len(src) - cap(dst); n > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user