Skip to content

Commit

Permalink
Specify that indexheader.Reader returns LabelNames in order, so we ca…
Browse files Browse the repository at this point in the history
…n use that.

Signed-off-by: Peter Štibraný <[email protected]>
  • Loading branch information
pstibrany committed Apr 27, 2021
1 parent 2ce15c5 commit 5838ceb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/block/indexheader/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ type Reader interface {
// then empty string is returned and no error.
LabelValues(name string) ([]string, error)

// LabelNames returns all label names.
// LabelNames returns all label names in sorted order.
LabelNames() ([]string, error)
}
3 changes: 1 addition & 2 deletions pkg/store/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -1208,13 +1208,12 @@ func (s *BucketStore) LabelNames(ctx context.Context, req *storepb.LabelNamesReq
var result []string
if len(reqSeriesMatchers) == 0 {
// Do it via index reader to have pending reader registered correctly.
// LabelNames are already sorted.
res, err := indexr.block.indexHeaderReader.LabelNames()
if err != nil {
return errors.Wrapf(err, "label names for block %s", b.meta.ULID)
}

sort.Strings(res)

// Add a set for the external labels as well.
// We're not adding them directly to res because there could be duplicates.
// b.extLset is already sorted by label name, no need to sort it again.
Expand Down

0 comments on commit 5838ceb

Please sign in to comment.