This commit is contained in:
Aliaksandr Valialkin 2024-05-28 15:58:36 +02:00
parent 22e14a3dbe
commit ba40c1a2d5
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB

View file

@ -113,7 +113,7 @@ func (fa *filterAnd) getByFieldTokens() []fieldTokens {
}
func (fa *filterAnd) initByFieldTokens() {
m := make(map[string][]string)
m := make(map[string]map[string]struct{})
byFieldFilters := make(map[string]int)
var fieldNames []string
@ -146,11 +146,15 @@ func (fa *filterAnd) initByFieldTokens() {
byFieldFilters[fieldName]++
if len(tokens) > 0 {
a, ok := m[fieldName]
mTokens, ok := m[fieldName]
if !ok {
fieldNames = append(fieldNames, fieldName)
mTokens = make(map[string]struct{})
m[fieldName] = mTokens
}
for _, token := range tokens {
mTokens[token] = struct{}{}
}
m[fieldName] = append(a, tokens...)
}
}
@ -160,9 +164,16 @@ func (fa *filterAnd) initByFieldTokens() {
// It is faster to perform bloom filter match inline when visiting the corresponding column
continue
}
mTokens := m[fieldName]
tokens := make([]string, 0, len(mTokens))
for token := range mTokens {
tokens = append(tokens, token)
}
byFieldTokens = append(byFieldTokens, fieldTokens{
field: fieldName,
tokens: m[fieldName],
tokens: tokens,
})
}