lib/storage: fix metric name match for composite filter

This commit is contained in:
Aliaksandr Valialkin 2021-02-10 01:24:45 +02:00
parent c7dccebaef
commit fcb7655d1e

View file

@ -1885,6 +1885,10 @@ func (is *indexSearch) updateMetricIDsByMetricNameMatch(metricIDs, srcMetricIDs
// sort srcMetricIDs in order to speed up Seek below.
sortedMetricIDs := srcMetricIDs.AppendTo(nil)
kb := &is.kb
kb.B = marshalCommonPrefix(kb.B[:0], nsPrefixTagToMetricIDs)
tfs = fromCompositeTagFilters(tfs, kb.B)
metricName := kbPool.Get()
defer kbPool.Put(metricName)
mn := GetMetricName()
@ -2115,6 +2119,7 @@ func fromCompositeTagFilters(tfs []*tagFilter, prefix []byte) []*tagFilter {
}
tagKey = tagKey[nameLen:]
tfNew := *tf
tfNew.key = append(tfNew.key[:0], tagKey...)
tfNew.prefix = append(tfNew.prefix[:0], prefix...)
tfNew.prefix = marshalTagValue(tfNew.prefix, tagKey)
tfNew.prefix = append(tfNew.prefix, tail...)
@ -2125,7 +2130,6 @@ func fromCompositeTagFilters(tfs []*tagFilter, prefix []byte) []*tagFilter {
func matchTagFilters(mn *MetricName, tfs []*tagFilter, kb *bytesutil.ByteBuffer) (bool, error) {
kb.B = marshalCommonPrefix(kb.B[:0], nsPrefixTagToMetricIDs)
tfs = fromCompositeTagFilters(tfs, kb.B)
for i, tf := range tfs {
if bytes.Equal(tf.key, graphiteReverseTagKey) {
// Skip artificial tag filter for Graphite-like metric names with dots,