Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

querier: Use select params for mint and maxt #1012

Merged
merged 1 commit into from
Sep 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/querier/chunk_store_queryable.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ type chunkStoreQuerier struct {
mint, maxt int64
}

func (q *chunkStoreQuerier) Select(_ *storage.SelectParams, matchers ...*labels.Matcher) (storage.SeriesSet, error) {
chunks, err := q.store.Get(q.ctx, model.Time(q.mint), model.Time(q.maxt), matchers...)
func (q *chunkStoreQuerier) Select(sp *storage.SelectParams, matchers ...*labels.Matcher) (storage.SeriesSet, error) {
chunks, err := q.store.Get(q.ctx, model.Time(sp.Start), model.Time(sp.End), matchers...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this check that sp != nil ? Maybe it can't be today, but it seems safer to follow the general pattern.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only call by querier.go (Select), which includes that check. Calling this with nil should panic IMO. The only "root" queriers are the ones in querier.go and unified_querier.go, where the nil check need to be.

if err != nil {
return nil, promql.ErrStorage(err)
}
Expand Down
10 changes: 8 additions & 2 deletions pkg/querier/distributor_queryable.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ type distributorQuerier struct {
mint, maxt int64
}

func (q *distributorQuerier) Select(_ *storage.SelectParams, matchers ...*labels.Matcher) (storage.SeriesSet, error) {
matrix, err := q.distributor.Query(q.ctx, model.Time(q.mint), model.Time(q.maxt), matchers...)
func (q *distributorQuerier) Select(sp *storage.SelectParams, matchers ...*labels.Matcher) (storage.SeriesSet, error) {
mint, maxt := q.mint, q.maxt
if sp != nil {
mint = sp.Start
maxt = sp.End
}

matrix, err := q.distributor.Query(q.ctx, model.Time(mint), model.Time(maxt), matchers...)
if err != nil {
return nil, promql.ErrStorage(err)
}
Expand Down
10 changes: 8 additions & 2 deletions pkg/querier/ingester_streaming_queryable.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,19 @@ type ingesterStreamingQuerier struct {
distributorQuerier
}

func (q *ingesterStreamingQuerier) Select(_ *storage.SelectParams, matchers ...*labels.Matcher) (storage.SeriesSet, error) {
func (q *ingesterStreamingQuerier) Select(sp *storage.SelectParams, matchers ...*labels.Matcher) (storage.SeriesSet, error) {
userID, err := user.ExtractOrgID(q.ctx)
if err != nil {
return nil, promql.ErrStorage(err)
}

results, err := q.distributor.QueryStream(q.ctx, model.Time(q.mint), model.Time(q.maxt), matchers...)
mint, maxt := q.mint, q.maxt
if sp != nil {
mint = sp.Start
maxt = sp.End
}

results, err := q.distributor.QueryStream(q.ctx, model.Time(mint), model.Time(maxt), matchers...)
if err != nil {
return nil, promql.ErrStorage(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/querier/unified_querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (q *unifiedChunkQuerier) Select(sp *storage.SelectParams, matchers ...*labe
errs := make(chan error, len(q.stores))
for _, store := range q.stores {
go func(store ChunkStore) {
cs, err := store.Get(q.ctx, model.Time(q.mint), model.Time(q.maxt), matchers...)
cs, err := store.Get(q.ctx, model.Time(sp.Start), model.Time(sp.End), matchers...)
if err != nil {
errs <- err
} else {
Expand Down