mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
0418bd0fa9
commit
944f4ab01c
4 changed files with 31 additions and 31 deletions
|
@ -36,15 +36,15 @@ func (fn *filterNoop) apply(_ *blockSearch, _ *bitmap) {
|
|||
// nothing to do
|
||||
}
|
||||
|
||||
// orFilter contains filters joined by OR operator.
|
||||
// filterOr contains filters joined by OR operator.
|
||||
//
|
||||
// It is epxressed as `f1 OR f2 ... OR fN` in LogsQL.
|
||||
type orFilter struct {
|
||||
type filterOr struct {
|
||||
filters []filter
|
||||
}
|
||||
|
||||
func (of *orFilter) String() string {
|
||||
filters := of.filters
|
||||
func (fo *filterOr) String() string {
|
||||
filters := fo.filters
|
||||
a := make([]string, len(filters))
|
||||
for i, f := range filters {
|
||||
s := f.String()
|
||||
|
@ -53,10 +53,10 @@ func (of *orFilter) String() string {
|
|||
return strings.Join(a, " or ")
|
||||
}
|
||||
|
||||
func (of *orFilter) apply(bs *blockSearch, bm *bitmap) {
|
||||
func (fo *filterOr) apply(bs *blockSearch, bm *bitmap) {
|
||||
bmResult := getBitmap(bm.bitsLen)
|
||||
bmTmp := getBitmap(bm.bitsLen)
|
||||
for _, f := range of.filters {
|
||||
for _, f := range fo.filters {
|
||||
// Minimize the number of rows to check by the filter by checking only
|
||||
// the rows, which may change the output bm:
|
||||
// - bm matches them, e.g. the caller wants to get them
|
||||
|
@ -92,7 +92,7 @@ func (af *andFilter) String() string {
|
|||
for i, f := range filters {
|
||||
s := f.String()
|
||||
switch f.(type) {
|
||||
case *orFilter:
|
||||
case *filterOr:
|
||||
s = "(" + s + ")"
|
||||
}
|
||||
a[i] = s
|
||||
|
@ -171,7 +171,7 @@ type notFilter struct {
|
|||
func (fn *notFilter) String() string {
|
||||
s := fn.f.String()
|
||||
switch fn.f.(type) {
|
||||
case *andFilter, *orFilter:
|
||||
case *andFilter, *filterOr:
|
||||
s = "(" + s + ")"
|
||||
}
|
||||
return "!" + s
|
||||
|
|
|
@ -368,7 +368,7 @@ func TestComplexFilters(t *testing.T) {
|
|||
phrase: "baz",
|
||||
},
|
||||
},
|
||||
&orFilter{
|
||||
&filterOr{
|
||||
filters: []filter{
|
||||
&phraseFilter{
|
||||
fieldName: "foo",
|
||||
|
@ -397,7 +397,7 @@ func TestComplexFilters(t *testing.T) {
|
|||
phrase: "baz",
|
||||
},
|
||||
},
|
||||
&orFilter{
|
||||
&filterOr{
|
||||
filters: []filter{
|
||||
&phraseFilter{
|
||||
fieldName: "foo",
|
||||
|
@ -426,7 +426,7 @@ func TestComplexFilters(t *testing.T) {
|
|||
phrase: "baz",
|
||||
},
|
||||
},
|
||||
&orFilter{
|
||||
&filterOr{
|
||||
filters: []filter{
|
||||
&phraseFilter{
|
||||
fieldName: "foo",
|
||||
|
@ -459,7 +459,7 @@ func TestComplexFilters(t *testing.T) {
|
|||
phrase: "qwert",
|
||||
},
|
||||
},
|
||||
&orFilter{
|
||||
&filterOr{
|
||||
filters: []filter{
|
||||
&phraseFilter{
|
||||
fieldName: "foo",
|
||||
|
@ -500,7 +500,7 @@ func TestOrFilter(t *testing.T) {
|
|||
}
|
||||
|
||||
// non-empty union
|
||||
of := &orFilter{
|
||||
fo := &filterOr{
|
||||
filters: []filter{
|
||||
&phraseFilter{
|
||||
fieldName: "foo",
|
||||
|
@ -512,10 +512,10 @@ func TestOrFilter(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
testFilterMatchForColumns(t, columns, of, "foo", []int{2, 6, 9})
|
||||
testFilterMatchForColumns(t, columns, fo, "foo", []int{2, 6, 9})
|
||||
|
||||
// reverse non-empty union
|
||||
of = &orFilter{
|
||||
fo = &filterOr{
|
||||
filters: []filter{
|
||||
&prefixFilter{
|
||||
fieldName: "foo",
|
||||
|
@ -527,10 +527,10 @@ func TestOrFilter(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
testFilterMatchForColumns(t, columns, of, "foo", []int{2, 6, 9})
|
||||
testFilterMatchForColumns(t, columns, fo, "foo", []int{2, 6, 9})
|
||||
|
||||
// first empty result, second non-empty result
|
||||
of = &orFilter{
|
||||
fo = &filterOr{
|
||||
filters: []filter{
|
||||
&prefixFilter{
|
||||
fieldName: "foo",
|
||||
|
@ -542,10 +542,10 @@ func TestOrFilter(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
testFilterMatchForColumns(t, columns, of, "foo", []int{9})
|
||||
testFilterMatchForColumns(t, columns, fo, "foo", []int{9})
|
||||
|
||||
// first non-empty result, second empty result
|
||||
of = &orFilter{
|
||||
fo = &filterOr{
|
||||
filters: []filter{
|
||||
&phraseFilter{
|
||||
fieldName: "foo",
|
||||
|
@ -557,10 +557,10 @@ func TestOrFilter(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
testFilterMatchForColumns(t, columns, of, "foo", []int{9})
|
||||
testFilterMatchForColumns(t, columns, fo, "foo", []int{9})
|
||||
|
||||
// first match all
|
||||
of = &orFilter{
|
||||
fo = &filterOr{
|
||||
filters: []filter{
|
||||
&phraseFilter{
|
||||
fieldName: "foo",
|
||||
|
@ -572,10 +572,10 @@ func TestOrFilter(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
testFilterMatchForColumns(t, columns, of, "foo", []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9})
|
||||
testFilterMatchForColumns(t, columns, fo, "foo", []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9})
|
||||
|
||||
// second match all
|
||||
of = &orFilter{
|
||||
fo = &filterOr{
|
||||
filters: []filter{
|
||||
&prefixFilter{
|
||||
fieldName: "foo",
|
||||
|
@ -587,10 +587,10 @@ func TestOrFilter(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
testFilterMatchForColumns(t, columns, of, "foo", []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9})
|
||||
testFilterMatchForColumns(t, columns, fo, "foo", []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9})
|
||||
|
||||
// both empty results
|
||||
of = &orFilter{
|
||||
fo = &filterOr{
|
||||
filters: []filter{
|
||||
&phraseFilter{
|
||||
fieldName: "foo",
|
||||
|
@ -602,7 +602,7 @@ func TestOrFilter(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
testFilterMatchForColumns(t, columns, of, "foo", nil)
|
||||
testFilterMatchForColumns(t, columns, fo, "foo", nil)
|
||||
}
|
||||
|
||||
func TestAndFilter(t *testing.T) {
|
||||
|
|
|
@ -262,10 +262,10 @@ func parseOrFilter(lex *lexer, fieldName string) (filter, error) {
|
|||
if len(filters) == 1 {
|
||||
return filters[0], nil
|
||||
}
|
||||
of := &orFilter{
|
||||
fo := &filterOr{
|
||||
filters: filters,
|
||||
}
|
||||
return of, nil
|
||||
return fo, nil
|
||||
case lex.isKeyword("or"):
|
||||
if !lex.mustNextToken() {
|
||||
return nil, fmt.Errorf("missing filter after 'or'")
|
||||
|
|
|
@ -341,7 +341,7 @@ func hasStreamFilters(f filter) bool {
|
|||
switch t := f.(type) {
|
||||
case *andFilter:
|
||||
return hasStreamFiltersInList(t.filters)
|
||||
case *orFilter:
|
||||
case *filterOr:
|
||||
return hasStreamFiltersInList(t.filters)
|
||||
case *notFilter:
|
||||
return hasStreamFilters(t.f)
|
||||
|
@ -367,8 +367,8 @@ func initStreamFilters(tenantIDs []TenantID, idb *indexdb, f filter) filter {
|
|||
return &andFilter{
|
||||
filters: initStreamFiltersList(tenantIDs, idb, t.filters),
|
||||
}
|
||||
case *orFilter:
|
||||
return &orFilter{
|
||||
case *filterOr:
|
||||
return &filterOr{
|
||||
filters: initStreamFiltersList(tenantIDs, idb, t.filters),
|
||||
}
|
||||
case *notFilter:
|
||||
|
|
Loading…
Reference in a new issue