mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-20 15:16:42 +00:00
wip
This commit is contained in:
parent
94d4f34cbf
commit
846d5358cf
1 changed files with 20 additions and 0 deletions
|
@ -10,6 +10,7 @@ import (
|
||||||
"unicode"
|
"unicode"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promutils"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -275,6 +276,9 @@ func (q *Query) Optimize() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Substitute '*' prefixFilter with filterNoop.
|
||||||
|
q.f = removeStarFilters(q.f)
|
||||||
|
|
||||||
// Optimize 'in(query)' filters
|
// Optimize 'in(query)' filters
|
||||||
optimizeFilterIn(q.f)
|
optimizeFilterIn(q.f)
|
||||||
for _, p := range q.pipes {
|
for _, p := range q.pipes {
|
||||||
|
@ -289,6 +293,22 @@ func (q *Query) Optimize() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeStarFilters(f filter) filter {
|
||||||
|
visitFunc := func(f filter) bool {
|
||||||
|
fp, ok := f.(*filterPrefix)
|
||||||
|
return ok && isMsgFieldName(fp.fieldName) && fp.prefix == ""
|
||||||
|
}
|
||||||
|
copyFunc := func(_ filter) (filter, error) {
|
||||||
|
fn := &filterNoop{}
|
||||||
|
return fn, nil
|
||||||
|
}
|
||||||
|
f, err := copyFilter(f, visitFunc, copyFunc)
|
||||||
|
if err != nil {
|
||||||
|
logger.Fatalf("BUG: unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|
||||||
func optimizeFilterIn(f filter) {
|
func optimizeFilterIn(f filter) {
|
||||||
visitFunc := func(f filter) bool {
|
visitFunc := func(f filter) bool {
|
||||||
fi, ok := f.(*filterIn)
|
fi, ok := f.(*filterIn)
|
||||||
|
|
Loading…
Reference in a new issue