This commit is contained in:
Aliaksandr Valialkin 2024-04-29 03:51:09 +02:00
parent 4a819f65f2
commit 0418bd0fa9
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
2 changed files with 10 additions and 10 deletions

View file

@ -24,15 +24,15 @@ type filter interface {
apply(bs *blockSearch, bm *bitmap) apply(bs *blockSearch, bm *bitmap)
} }
// noopFilter does nothing // filterNoop does nothing
type noopFilter struct { type filterNoop struct {
} }
func (nf *noopFilter) String() string { func (fn *filterNoop) String() string {
return "" return ""
} }
func (nf *noopFilter) apply(_ *blockSearch, _ *bitmap) { func (fn *filterNoop) apply(_ *blockSearch, _ *bitmap) {
// nothing to do // nothing to do
} }
@ -168,21 +168,21 @@ type notFilter struct {
f filter f filter
} }
func (nf *notFilter) String() string { func (fn *notFilter) String() string {
s := nf.f.String() s := fn.f.String()
switch nf.f.(type) { switch fn.f.(type) {
case *andFilter, *orFilter: case *andFilter, *orFilter:
s = "(" + s + ")" s = "(" + s + ")"
} }
return "!" + s return "!" + s
} }
func (nf *notFilter) apply(bs *blockSearch, bm *bitmap) { func (fn *notFilter) apply(bs *blockSearch, bm *bitmap) {
// Minimize the number of rows to check by the filter by applying it // Minimize the number of rows to check by the filter by applying it
// only to the rows, which match the bm, e.g. they may change the bm result. // only to the rows, which match the bm, e.g. they may change the bm result.
bmTmp := getBitmap(bm.bitsLen) bmTmp := getBitmap(bm.bitsLen)
bmTmp.copyFrom(bm) bmTmp.copyFrom(bm)
nf.f.apply(bs, bmTmp) fn.f.apply(bs, bmTmp)
bm.andNot(bmTmp) bm.andNot(bmTmp)
putBitmap(bmTmp) putBitmap(bmTmp)
} }

View file

@ -708,7 +708,7 @@ func getCommonStreamFilter(f filter) (*StreamFilter, filter) {
} }
} }
case *streamFilter: case *streamFilter:
return t.f, &noopFilter{} return t.f, &filterNoop{}
} }
return nil, f return nil, f
} }