|
|
@ -115,20 +115,24 @@ func NewBlockQuerier(b BlockReader, mint, maxt int64) (storage.Querier, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (q *blockQuerier) Select(ctx context.Context, sortSeries bool, hints *storage.SelectHints, ms ...*labels.Matcher) storage.SeriesSet {
|
|
|
|
func (q *blockQuerier) Select(ctx context.Context, sortSeries bool, hints *storage.SelectHints, ms ...*labels.Matcher) storage.SeriesSet {
|
|
|
|
mint := q.mint
|
|
|
|
return selectSeriesSet(ctx, sortSeries, hints, ms, q.index, q.chunks, q.tombstones, q.mint, q.maxt)
|
|
|
|
maxt := q.maxt
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func selectSeriesSet(ctx context.Context, sortSeries bool, hints *storage.SelectHints, ms []*labels.Matcher,
|
|
|
|
|
|
|
|
index IndexReader, chunks ChunkReader, tombstones tombstones.Reader, mint, maxt int64,
|
|
|
|
|
|
|
|
) storage.SeriesSet {
|
|
|
|
disableTrimming := false
|
|
|
|
disableTrimming := false
|
|
|
|
sharded := hints != nil && hints.ShardCount > 0
|
|
|
|
sharded := hints != nil && hints.ShardCount > 0
|
|
|
|
|
|
|
|
|
|
|
|
p, err := PostingsForMatchers(ctx, q.index, ms...)
|
|
|
|
p, err := PostingsForMatchers(ctx, index, ms...)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return storage.ErrSeriesSet(err)
|
|
|
|
return storage.ErrSeriesSet(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if sharded {
|
|
|
|
if sharded {
|
|
|
|
p = q.index.ShardedPostings(p, hints.ShardIndex, hints.ShardCount)
|
|
|
|
p = index.ShardedPostings(p, hints.ShardIndex, hints.ShardCount)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if sortSeries {
|
|
|
|
if sortSeries {
|
|
|
|
p = q.index.SortedPostings(p)
|
|
|
|
p = index.SortedPostings(p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if hints != nil {
|
|
|
|
if hints != nil {
|
|
|
@ -137,11 +141,11 @@ func (q *blockQuerier) Select(ctx context.Context, sortSeries bool, hints *stora
|
|
|
|
disableTrimming = hints.DisableTrimming
|
|
|
|
disableTrimming = hints.DisableTrimming
|
|
|
|
if hints.Func == "series" {
|
|
|
|
if hints.Func == "series" {
|
|
|
|
// When you're only looking up metadata (for example series API), you don't need to load any chunks.
|
|
|
|
// When you're only looking up metadata (for example series API), you don't need to load any chunks.
|
|
|
|
return newBlockSeriesSet(q.index, newNopChunkReader(), q.tombstones, p, mint, maxt, disableTrimming)
|
|
|
|
return newBlockSeriesSet(index, newNopChunkReader(), tombstones, p, mint, maxt, disableTrimming)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return newBlockSeriesSet(q.index, q.chunks, q.tombstones, p, mint, maxt, disableTrimming)
|
|
|
|
return newBlockSeriesSet(index, chunks, tombstones, p, mint, maxt, disableTrimming)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// blockChunkQuerier provides chunk querying access to a single block database.
|
|
|
|
// blockChunkQuerier provides chunk querying access to a single block database.
|
|
|
@ -159,8 +163,12 @@ func NewBlockChunkQuerier(b BlockReader, mint, maxt int64) (storage.ChunkQuerier
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (q *blockChunkQuerier) Select(ctx context.Context, sortSeries bool, hints *storage.SelectHints, ms ...*labels.Matcher) storage.ChunkSeriesSet {
|
|
|
|
func (q *blockChunkQuerier) Select(ctx context.Context, sortSeries bool, hints *storage.SelectHints, ms ...*labels.Matcher) storage.ChunkSeriesSet {
|
|
|
|
mint := q.mint
|
|
|
|
return selectChunkSeriesSet(ctx, sortSeries, hints, ms, q.blockID, q.index, q.chunks, q.tombstones, q.mint, q.maxt)
|
|
|
|
maxt := q.maxt
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func selectChunkSeriesSet(ctx context.Context, sortSeries bool, hints *storage.SelectHints, ms []*labels.Matcher,
|
|
|
|
|
|
|
|
blockID ulid.ULID, index IndexReader, chunks ChunkReader, tombstones tombstones.Reader, mint, maxt int64,
|
|
|
|
|
|
|
|
) storage.ChunkSeriesSet {
|
|
|
|
disableTrimming := false
|
|
|
|
disableTrimming := false
|
|
|
|
sharded := hints != nil && hints.ShardCount > 0
|
|
|
|
sharded := hints != nil && hints.ShardCount > 0
|
|
|
|
|
|
|
|
|
|
|
@ -169,17 +177,17 @@ func (q *blockChunkQuerier) Select(ctx context.Context, sortSeries bool, hints *
|
|
|
|
maxt = hints.End
|
|
|
|
maxt = hints.End
|
|
|
|
disableTrimming = hints.DisableTrimming
|
|
|
|
disableTrimming = hints.DisableTrimming
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p, err := PostingsForMatchers(ctx, q.index, ms...)
|
|
|
|
p, err := PostingsForMatchers(ctx, index, ms...)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return storage.ErrChunkSeriesSet(err)
|
|
|
|
return storage.ErrChunkSeriesSet(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if sharded {
|
|
|
|
if sharded {
|
|
|
|
p = q.index.ShardedPostings(p, hints.ShardIndex, hints.ShardCount)
|
|
|
|
p = index.ShardedPostings(p, hints.ShardIndex, hints.ShardCount)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if sortSeries {
|
|
|
|
if sortSeries {
|
|
|
|
p = q.index.SortedPostings(p)
|
|
|
|
p = index.SortedPostings(p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NewBlockChunkSeriesSet(q.blockID, q.index, q.chunks, q.tombstones, p, mint, maxt, disableTrimming)
|
|
|
|
return NewBlockChunkSeriesSet(blockID, index, chunks, tombstones, p, mint, maxt, disableTrimming)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// PostingsForMatchers assembles a single postings iterator against the index reader
|
|
|
|
// PostingsForMatchers assembles a single postings iterator against the index reader
|
|
|
|