Browse Source

Avoid creating new slices for labels values on postings for matchers (#13958)

* Avoid creating new slices for labels values on postings for matchers

Signed-off-by: alanprot <alanprot@gmail.com>

* refactor

Signed-off-by: alanprot <alanprot@gmail.com>

---------

Signed-off-by: alanprot <alanprot@gmail.com>
pull/13990/head
Alan Protasio 7 months ago committed by GitHub
parent
commit
d15869af32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      tsdb/querier.go

4
tsdb/querier.go

@ -331,7 +331,7 @@ func postingsForMatcher(ctx context.Context, ix IndexReader, m *labels.Matcher)
return nil, err
}
var res []string
res := vals[:0]
for _, val := range vals {
if m.Matches(val) {
res = append(res, val)
@ -368,7 +368,7 @@ func inversePostingsForMatcher(ctx context.Context, ix IndexReader, m *labels.Ma
return nil, err
}
var res []string
res := vals[:0]
// If the inverse match is ="", we just want all the values.
if m.Type == labels.MatchEqual && m.Value == "" {
res = vals

Loading…
Cancel
Save