MCPcopy Create free account
hub / github.com/cortexproject/cortex / Select

Method Select

pkg/querier/querier_test.go:1467–1497  ·  view source on GitHub ↗

Select implements storage.Querier interface. The bool passed is ignored because the series is always sorted.

(_ context.Context, _ bool, sp *storage.SelectHints, matchers ...*labels.Matcher)

Source from the content-addressed store, hash-verified

1465// Select implements storage.Querier interface.
1466// The bool passed is ignored because the series is always sorted.
1467func (q *mockStoreQuerier) Select(_ context.Context, _ bool, sp *storage.SelectHints, matchers ...*labels.Matcher) storage.SeriesSet {
1468 // If we don't skip here, it'll make /series lookups extremely slow as all the chunks will be loaded.
1469 // That flag is only to be set with blocks storage engine, and this is a protective measure.
1470 if sp != nil && sp.Func == "series" {
1471 return storage.EmptySeriesSet()
1472 }
1473
1474 chunks, err := q.store.Get()
1475 if err != nil {
1476 return storage.ErrSeriesSet(err)
1477 }
1478
1479 cs := make([]storage.Series, 0, len(chunks))
1480 chunksBySeries := map[string][]chunk.Chunk{}
1481
1482 for _, c := range chunks {
1483 key := client.LabelsToKeyString(c.Metric)
1484 chunksBySeries[key] = append(chunksBySeries[key], c)
1485 }
1486
1487 for i, c := range chunksBySeries {
1488 cs = append(cs, &storage.SeriesEntry{
1489 Lset: chunksBySeries[i][0].Metric,
1490 SampleIteratorFn: func(it chunkenc.Iterator) chunkenc.Iterator {
1491 return q.chunkIteratorFunc(it, c, model.Time(mint), model.Time(maxt))
1492 },
1493 })
1494 }
1495
1496 return series.NewConcreteSeriesSet(true, cs)
1497}
1498
1499func (q *mockStoreQuerier) LabelValues(ctx context.Context, name string, _ *storage.LabelHints, labels ...*labels.Matcher) ([]string, annotations.Annotations, error) {
1500 return nil, nil, nil

Callers

nothing calls this directly

Calls 3

LabelsToKeyStringFunction · 0.92
NewConcreteSeriesSetFunction · 0.92
GetMethod · 0.65

Tested by

no test coverage detected