Skip to content

Commit

Permalink
Address CR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fpetkovski committed Oct 14, 2022
1 parent 17d993c commit 47b2130
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"

"github.com/thanos-community/promql-engine/logicalplan"

"github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/promql/parser"
"github.com/prometheus/prometheus/storage"
v1 "github.com/prometheus/prometheus/web/api/v1"

"github.com/thanos-community/promql-engine/logicalplan"
"github.com/thanos-community/promql-engine/physicalplan"
"github.com/thanos-community/promql-engine/physicalplan/model"
"github.com/thanos-community/promql-engine/physicalplan/parse"
Expand Down
2 changes: 1 addition & 1 deletion logicalplan/sort_matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (m SortMatchers) Optimize(expr parser.Expr) parser.Expr {
}

sort.Slice(e.LabelMatchers, func(i, j int) bool {
return e.LabelMatchers[i].Name == e.LabelMatchers[j].Name
return e.LabelMatchers[i].Name < e.LabelMatchers[j].Name
})
})
return expr
Expand Down
6 changes: 3 additions & 3 deletions physicalplan/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ func newOperator(expr parser.Expr, selectorPool *engstore.SelectorPool, mint, ma
case *parser.VectorSelector:
start, end := getTimeRangesForVectorSelector(e, mint, maxt, lookbackDelta, 0)
filter := selectorPool.GetSelector(start, end, e.LabelMatchers)
return newVectorSelector(filter, mint, maxt, e.Offset, lookbackDelta, step)
return newShardedVectorSelector(filter, mint, maxt, e.Offset, lookbackDelta, step)

case *logicalplan.FilteredSelector:
start, end := getTimeRangesForVectorSelector(e.VectorSelector, mint, maxt, lookbackDelta, 0)
selector := selectorPool.GetFilteredSelector(start, end, e.LabelMatchers, e.Filters)
return newVectorSelector(selector, mint, maxt, e.Offset, lookbackDelta, step)
return newShardedVectorSelector(selector, mint, maxt, e.Offset, lookbackDelta, step)

case *parser.Call:
if len(e.Args) != 1 {
Expand Down Expand Up @@ -182,7 +182,7 @@ func unpackVectorSelector(t *parser.MatrixSelector) (*parser.VectorSelector, []*
}
}

func newVectorSelector(selector engstore.SeriesSelector, mint time.Time, maxt time.Time, offset, lookbackDelta time.Duration, step time.Duration) (model.VectorOperator, error) {
func newShardedVectorSelector(selector engstore.SeriesSelector, mint time.Time, maxt time.Time, offset, lookbackDelta time.Duration, step time.Duration) (model.VectorOperator, error) {
numShards := runtime.GOMAXPROCS(0) / 2
if numShards < 1 {
numShards = 1
Expand Down

0 comments on commit 47b2130

Please sign in to comment.