mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: simplify code for searching for label values
This is a follow-up after 9dd191b27c
This commit is contained in:
parent
3c3805865b
commit
c3affb0c4f
1 changed files with 20 additions and 40 deletions
|
@ -981,10 +981,9 @@ func (is *indexSearch) searchTagValuesOnDate(tvs map[string]struct{}, tagKey []b
|
||||||
if mp.IsDeletedTag(dmis) {
|
if mp.IsDeletedTag(dmis) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if string(mp.Tag.Key) != string(tagKey) {
|
||||||
key := mp.Tag.Key
|
break
|
||||||
skipTag := isArtificialTagKey(key)
|
}
|
||||||
if !skipTag {
|
|
||||||
tvs[string(mp.Tag.Value)] = struct{}{}
|
tvs[string(mp.Tag.Value)] = struct{}{}
|
||||||
if mp.MetricIDsLen() < maxMetricIDsPerRow/2 {
|
if mp.MetricIDsLen() < maxMetricIDsPerRow/2 {
|
||||||
// There is no need in searching for the next tag value,
|
// There is no need in searching for the next tag value,
|
||||||
|
@ -992,21 +991,12 @@ func (is *indexSearch) searchTagValuesOnDate(tvs map[string]struct{}, tagKey []b
|
||||||
// because the current row contains incomplete metricIDs set.
|
// because the current row contains incomplete metricIDs set.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Search for the next tag value.
|
// Search for the next tag value.
|
||||||
// The last char in kb.B must be tagSeparatorChar.
|
// The last char in kb.B must be tagSeparatorChar.
|
||||||
// Just increment it in order to jump to the next tag value.
|
// Just increment it in order to jump to the next tag value.
|
||||||
kb.B = is.marshalCommonPrefix(kb.B[:0], nsPrefixDateTagToMetricIDs)
|
kb.B = is.marshalCommonPrefix(kb.B[:0], nsPrefixDateTagToMetricIDs)
|
||||||
kb.B = encoding.MarshalUint64(kb.B, date)
|
kb.B = encoding.MarshalUint64(kb.B, date)
|
||||||
if len(key) > 0 && key[0] == compositeTagKeyPrefix {
|
kb.B = marshalTagValue(kb.B, mp.Tag.Key)
|
||||||
// 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)
|
|
||||||
}
|
|
||||||
kb.B[len(kb.B)-1]++
|
kb.B[len(kb.B)-1]++
|
||||||
ts.Seek(kb.B)
|
ts.Seek(kb.B)
|
||||||
}
|
}
|
||||||
|
@ -1075,10 +1065,9 @@ func (is *indexSearch) searchTagValues(tvs map[string]struct{}, tagKey []byte, m
|
||||||
if mp.IsDeletedTag(dmis) {
|
if mp.IsDeletedTag(dmis) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if string(mp.Tag.Key) != string(tagKey) {
|
||||||
key := mp.Tag.Key
|
break
|
||||||
skipTag := isArtificialTagKey(key)
|
}
|
||||||
if !skipTag {
|
|
||||||
tvs[string(mp.Tag.Value)] = struct{}{}
|
tvs[string(mp.Tag.Value)] = struct{}{}
|
||||||
if mp.MetricIDsLen() < maxMetricIDsPerRow/2 {
|
if mp.MetricIDsLen() < maxMetricIDsPerRow/2 {
|
||||||
// There is no need in searching for the next tag value,
|
// There is no need in searching for the next tag value,
|
||||||
|
@ -1086,20 +1075,11 @@ func (is *indexSearch) searchTagValues(tvs map[string]struct{}, tagKey []byte, m
|
||||||
// because the current row contains incomplete metricIDs set.
|
// because the current row contains incomplete metricIDs set.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Search for the next tag value.
|
// Search for the next tag value.
|
||||||
// The last char in kb.B must be tagSeparatorChar.
|
// The last char in kb.B must be tagSeparatorChar.
|
||||||
// Just increment it in order to jump to the next tag value.
|
// Just increment it in order to jump to the next tag value.
|
||||||
kb.B = is.marshalCommonPrefix(kb.B[:0], nsPrefixTagToMetricIDs)
|
kb.B = is.marshalCommonPrefix(kb.B[:0], nsPrefixTagToMetricIDs)
|
||||||
if len(key) > 0 && key[0] == compositeTagKeyPrefix {
|
kb.B = marshalTagValue(kb.B, mp.Tag.Key)
|
||||||
// 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)
|
|
||||||
}
|
|
||||||
kb.B[len(kb.B)-1]++
|
kb.B[len(kb.B)-1]++
|
||||||
ts.Seek(kb.B)
|
ts.Seek(kb.B)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue