mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-09 15:27:11 +00:00
lib/storage: properly skip composite tag entries when searching for tag names or tag values
This is a follow-up for b71be42d90
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2200
This commit is contained in:
parent
3107224306
commit
2ebc3d21c3
1 changed files with 28 additions and 6 deletions
|
@ -810,7 +810,12 @@ func (is *indexSearch) searchTagKeysOnDate(tks map[string]struct{}, date uint64,
|
|||
// Just increment it in order to jump to the next tag key.
|
||||
kb.B = is.marshalCommonPrefix(kb.B[:0], nsPrefixDateTagToMetricIDs)
|
||||
kb.B = encoding.MarshalUint64(kb.B, date)
|
||||
kb.B = marshalTagValue(kb.B, key)
|
||||
if len(key) > 0 && key[0] == compositeTagKeyPrefix {
|
||||
// skip composite tag entries
|
||||
kb.B = append(kb.B, compositeTagKeyPrefix)
|
||||
} else {
|
||||
kb.B = marshalTagValue(kb.B, key)
|
||||
}
|
||||
kb.B[len(kb.B)-1]++
|
||||
ts.Seek(kb.B)
|
||||
}
|
||||
|
@ -885,7 +890,12 @@ func (is *indexSearch) searchTagKeys(tks map[string]struct{}, maxTagKeys int) er
|
|||
// The last char in kb.B must be tagSeparatorChar.
|
||||
// Just increment it in order to jump to the next tag key.
|
||||
kb.B = is.marshalCommonPrefix(kb.B[:0], nsPrefixTagToMetricIDs)
|
||||
kb.B = marshalTagValue(kb.B, key)
|
||||
if len(key) > 0 && key[0] == compositeTagKeyPrefix {
|
||||
// skip composite tag entries
|
||||
kb.B = append(kb.B, compositeTagKeyPrefix)
|
||||
} else {
|
||||
kb.B = marshalTagValue(kb.B, key)
|
||||
}
|
||||
kb.B[len(kb.B)-1]++
|
||||
ts.Seek(kb.B)
|
||||
}
|
||||
|
@ -994,7 +1004,8 @@ func (is *indexSearch) searchTagValuesOnDate(tvs map[string]struct{}, tagKey []b
|
|||
continue
|
||||
}
|
||||
|
||||
skipTag := isArtificialTagKey(mp.Tag.Key)
|
||||
key := mp.Tag.Key
|
||||
skipTag := isArtificialTagKey(key)
|
||||
if !skipTag {
|
||||
tvs[string(mp.Tag.Value)] = struct{}{}
|
||||
if mp.MetricIDsLen() < maxMetricIDsPerRow/2 {
|
||||
|
@ -1009,7 +1020,12 @@ func (is *indexSearch) searchTagValuesOnDate(tvs map[string]struct{}, tagKey []b
|
|||
// Just increment it in order to jump to the next tag value.
|
||||
kb.B = is.marshalCommonPrefix(kb.B[:0], nsPrefixDateTagToMetricIDs)
|
||||
kb.B = encoding.MarshalUint64(kb.B, date)
|
||||
kb.B = marshalTagValue(kb.B, mp.Tag.Key)
|
||||
if len(key) > 0 && key[0] == compositeTagKeyPrefix {
|
||||
// skip composite tag entries
|
||||
kb.B = append(kb.B, compositeTagKeyPrefix)
|
||||
} else {
|
||||
kb.B = marshalTagValue(kb.B, key)
|
||||
}
|
||||
if !skipTag {
|
||||
kb.B = marshalTagValue(kb.B, mp.Tag.Value)
|
||||
}
|
||||
|
@ -1082,7 +1098,8 @@ func (is *indexSearch) searchTagValues(tvs map[string]struct{}, tagKey []byte, m
|
|||
continue
|
||||
}
|
||||
|
||||
skipTag := isArtificialTagKey(mp.Tag.Key)
|
||||
key := mp.Tag.Key
|
||||
skipTag := isArtificialTagKey(key)
|
||||
if !skipTag {
|
||||
tvs[string(mp.Tag.Value)] = struct{}{}
|
||||
if mp.MetricIDsLen() < maxMetricIDsPerRow/2 {
|
||||
|
@ -1096,7 +1113,12 @@ func (is *indexSearch) searchTagValues(tvs map[string]struct{}, tagKey []byte, m
|
|||
// The last char in kb.B must be tagSeparatorChar.
|
||||
// Just increment it in order to jump to the next tag value.
|
||||
kb.B = is.marshalCommonPrefix(kb.B[:0], nsPrefixTagToMetricIDs)
|
||||
kb.B = marshalTagValue(kb.B, mp.Tag.Key)
|
||||
if len(key) > 0 && key[0] == compositeTagKeyPrefix {
|
||||
// skip composite tag entries
|
||||
kb.B = append(kb.B, compositeTagKeyPrefix)
|
||||
} else {
|
||||
kb.B = marshalTagValue(kb.B, key)
|
||||
}
|
||||
if !skipTag {
|
||||
kb.B = marshalTagValue(kb.B, mp.Tag.Value)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue