SearchLabelValues implements storage.Searcher.
(ctx context.Context, name string, hints *storage.SearchHints, matchers ...*labels.Matcher)
| 108 | |
| 109 | // SearchLabelValues implements storage.Searcher. |
| 110 | func (q *blockBaseQuerier) SearchLabelValues(ctx context.Context, name string, hints *storage.SearchHints, matchers ...*labels.Matcher) storage.SearchResultSet { |
| 111 | if hints == nil { |
| 112 | hints = &storage.SearchHints{} |
| 113 | } |
| 114 | |
| 115 | // Limit pushdown is only correct when natural (ascending) index order |
| 116 | // is preserved all the way to the output and no filtering discards |
| 117 | // values ahead of the limit. |
| 118 | labelHints := &storage.LabelHints{} |
| 119 | if hints.OrderBy == storage.OrderByValueAsc && hints.Filter == nil { |
| 120 | labelHints.Limit = hints.Limit |
| 121 | } |
| 122 | |
| 123 | var ( |
| 124 | values []string |
| 125 | err error |
| 126 | ) |
| 127 | switch hints.OrderBy { |
| 128 | case storage.OrderByScoreDesc: |
| 129 | // Score-based sorting happens in ApplySearchHints; avoid the |
| 130 | // index-level sort. |
| 131 | values, err = q.index.LabelValues(ctx, name, labelHints, matchers...) |
| 132 | default: |
| 133 | values, err = q.index.SortedLabelValues(ctx, name, labelHints, matchers...) |
| 134 | } |
| 135 | if err != nil { |
| 136 | return storage.ErrSearchResultSet(err) |
| 137 | } |
| 138 | |
| 139 | return storage.NewSearchResultSetFromSlice(storage.ApplySearchHints(values, hints), nil) |
| 140 | } |
| 141 | |
| 142 | func (q *blockBaseQuerier) Close() error { |
| 143 | if q.closed { |
nothing calls this directly
no test coverage detected