Skip to content

Commit

Permalink
[performance] metrics query: range vector support streaming agg when …
Browse files Browse the repository at this point in the history
…no overlap (grafana#7380)

metrics query: range vector support streaming agg when no overlap
  • Loading branch information
liguozhong authored and Abuelodelanada committed Dec 1, 2022
1 parent f16bf75 commit a54580e
Show file tree
Hide file tree
Showing 4 changed files with 581 additions and 39 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#### Loki

##### Enhancements
* [7380](https://github.com/grafana/loki/pull/7380) **liguozhong**: metrics query: range vector support streaming agg when no overlap

* [7684](https://github.com/grafana/loki/pull/7684) **kavirajk**: Add missing `embedded-cache` config under `cache_config` doc.
* [6360](https://github.com/grafana/loki/pull/6099) **liguozhong**: Hide error message when ctx timeout occurs in s3.getObject
Expand Down
17 changes: 7 additions & 10 deletions pkg/logql/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,16 +420,15 @@ func rangeAggEvaluator(
q Params,
o time.Duration,
) (StepEvaluator, error) {
agg, err := aggregator(expr)
if err != nil {
return nil, err
}
iter := newRangeVectorIterator(
it,
iter, err := newRangeVectorIterator(
it, expr,
expr.Left.Interval.Nanoseconds(),
q.Step().Nanoseconds(),
q.Start().UnixNano(), q.End().UnixNano(), o.Nanoseconds(),
)
if err != nil {
return nil, err
}
if expr.Operation == syntax.OpRangeTypeAbsent {
return &absentRangeVectorEvaluator{
iter: iter,
Expand All @@ -438,12 +437,10 @@ func rangeAggEvaluator(
}
return &rangeVectorEvaluator{
iter: iter,
agg: agg,
}, nil
}

type rangeVectorEvaluator struct {
agg RangeVectorAggregator
iter RangeVectorIterator

err error
Expand All @@ -454,7 +451,7 @@ func (r *rangeVectorEvaluator) Next() (bool, int64, promql.Vector) {
if !next {
return false, 0, promql.Vector{}
}
ts, vec := r.iter.At(r.agg)
ts, vec := r.iter.At()
for _, s := range vec {
// Errors are not allowed in metrics.
if s.Metric.Has(logqlmodel.ErrorLabel) {
Expand Down Expand Up @@ -486,7 +483,7 @@ func (r *absentRangeVectorEvaluator) Next() (bool, int64, promql.Vector) {
if !next {
return false, 0, promql.Vector{}
}
ts, vec := r.iter.At(one)
ts, vec := r.iter.At()
for _, s := range vec {
// Errors are not allowed in metrics.
if s.Metric.Has(logqlmodel.ErrorLabel) {
Expand Down
Loading

0 comments on commit a54580e

Please sign in to comment.