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

refactor: allow newIndexSeriesCursor() to accept an influxql.Expr #19833

Merged
merged 2 commits into from
Oct 27, 2020
Merged
Changes from 1 commit
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
Next Next commit
refactor: allow newIndexSeriesCursor() to accept an influxql.Expr
In order to let TagKeys and TagValues get the right answer,
sometimes they will need to examine their predicate and
see if using the index is possible, or if a block scan is needed.
For those cases we want to examine the predicate before creating
the index series cursor. This change allows us to create an
index series cursor with an already-deserialized influxql.Expr.
  • Loading branch information
Christopher Wolff committed Oct 27, 2020
commit 507ede7e3e4a56850c607d8eb1824d912c341789
18 changes: 14 additions & 4 deletions v1/services/storage/series_cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ type indexSeriesCursor struct {
}

func newIndexSeriesCursor(ctx context.Context, predicate *datatypes.Predicate, shards []*tsdb.Shard) (*indexSeriesCursor, error) {
var expr influxql.Expr
if root := predicate.GetRoot(); root != nil {
var err error
if expr, err = reads.NodeToExpr(root, measurementRemap); err != nil {
return nil, err
}
}

return newIndexSeriesCursorInfluxQL(ctx, expr, shards)
wolffcm marked this conversation as resolved.
Show resolved Hide resolved
}

func newIndexSeriesCursorInfluxQL(ctx context.Context, predicate influxql.Expr, shards []*tsdb.Shard) (*indexSeriesCursor, error) {
queries, err := tsdb.CreateCursorIterators(ctx, shards)
if err != nil {
return nil, err
Expand All @@ -61,10 +73,8 @@ func newIndexSeriesCursor(ctx context.Context, predicate *datatypes.Predicate, s
}
p := &indexSeriesCursor{row: reads.SeriesRow{Query: queries}}

if root := predicate.GetRoot(); root != nil {
if p.cond, err = reads.NodeToExpr(root, measurementRemap); err != nil {
return nil, err
}
if predicate != nil {
p.cond = predicate

p.hasFieldExpr, p.hasValueExpr = HasFieldKeyOrValue(p.cond)
if !(p.hasFieldExpr || p.hasValueExpr) {
Expand Down