Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Arve Knudsen <[email protected]>
  • Loading branch information
aknuds1 committed Sep 12, 2023
1 parent f7d39d3 commit d1f7d3c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions tsdb/index/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,7 @@ func (r *Reader) LabelValuesStream(name string, matchers ...*labels.Matcher) sto
return &labelValuesV1{
matchers: matchers,
it: reflect.ValueOf(p).MapRange(),
name: name,
}
}

Expand Down
12 changes: 10 additions & 2 deletions tsdb/index/labelvalues.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,18 @@ func (l *labelValuesV2) Warnings() storage.Warnings {
type labelValuesV1 struct {
it *reflect.MapIter
matchers []*labels.Matcher
name string
}

func (l *labelValuesV1) Next() bool {
loop:
for l.it.Next() {
for _, m := range l.matchers {
if m.Name != l.name {
// This should not happen
continue
}

if !m.Matches(l.At()) {
continue loop
}
Expand Down Expand Up @@ -203,8 +209,10 @@ func (it *intersectLabelValues) Next() bool {
// These are always the same number of bytes,
// and it's faster to skip than to parse.
it.skip = it.d.Len()
it.d.Uvarint() // Keycount.
it.d.UvarintBytes() // Label name.
// Key count
it.d.Uvarint()
// Label name
it.d.UvarintBytes()
it.skip -= it.d.Len()
} else {
it.d.Skip(it.skip)
Expand Down
5 changes: 5 additions & 0 deletions tsdb/index/postings.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ func (p *MemPostings) LabelValuesStream(name string, matchers ...*labels.Matcher
loop:
for v := range p.m[name] {
for _, m := range matchers {
if m.Name != name {
// This should not happen
continue
}

if !m.Matches(v) {
continue loop
}
Expand Down

0 comments on commit d1f7d3c

Please sign in to comment.