mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-01 14:47:38 +00:00
lib/storage: revert ecf132933e
, since negative filters require the same amount of work as non-negative filters
This commit is contained in:
parent
bbc287ea6a
commit
0c5bb2a397
1 changed files with 3 additions and 14 deletions
|
@ -255,15 +255,15 @@ func (tf *tagFilter) Less(other *tagFilter) bool {
|
||||||
if tf.matchCost != other.matchCost {
|
if tf.matchCost != other.matchCost {
|
||||||
return tf.matchCost < other.matchCost
|
return tf.matchCost < other.matchCost
|
||||||
}
|
}
|
||||||
if tf.isNegative != other.isNegative {
|
|
||||||
return !tf.isNegative
|
|
||||||
}
|
|
||||||
if tf.isRegexp != other.isRegexp {
|
if tf.isRegexp != other.isRegexp {
|
||||||
return !tf.isRegexp
|
return !tf.isRegexp
|
||||||
}
|
}
|
||||||
if len(tf.orSuffixes) != len(other.orSuffixes) {
|
if len(tf.orSuffixes) != len(other.orSuffixes) {
|
||||||
return len(tf.orSuffixes) < len(other.orSuffixes)
|
return len(tf.orSuffixes) < len(other.orSuffixes)
|
||||||
}
|
}
|
||||||
|
if tf.isNegative != other.isNegative {
|
||||||
|
return !tf.isNegative
|
||||||
|
}
|
||||||
return bytes.Compare(tf.prefix, other.prefix) < 0
|
return bytes.Compare(tf.prefix, other.prefix) < 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,9 +333,6 @@ func (tf *tagFilter) InitFromGraphiteQuery(commonPrefix, query []byte, paths []s
|
||||||
tf.prefix = marshalTagValueNoTrailingTagSeparator(tf.prefix, []byte(prefix))
|
tf.prefix = marshalTagValueNoTrailingTagSeparator(tf.prefix, []byte(prefix))
|
||||||
tf.orSuffixes = append(tf.orSuffixes[:0], orSuffixes...)
|
tf.orSuffixes = append(tf.orSuffixes[:0], orSuffixes...)
|
||||||
tf.reSuffixMatch, tf.matchCost = newMatchFuncForOrSuffixes(orSuffixes)
|
tf.reSuffixMatch, tf.matchCost = newMatchFuncForOrSuffixes(orSuffixes)
|
||||||
if isNegative {
|
|
||||||
tf.matchCost *= negativeMatchCostMultiplier
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCommonPrefix(ss []string) (string, []string) {
|
func getCommonPrefix(ss []string) (string, []string) {
|
||||||
|
@ -403,9 +400,6 @@ func (tf *tagFilter) Init(commonPrefix, key, value []byte, isNegative, isRegexp
|
||||||
tf.orSuffixes = append(tf.orSuffixes[:0], "")
|
tf.orSuffixes = append(tf.orSuffixes[:0], "")
|
||||||
tf.isEmptyMatch = len(prefix) == 0
|
tf.isEmptyMatch = len(prefix) == 0
|
||||||
tf.matchCost = fullMatchCost
|
tf.matchCost = fullMatchCost
|
||||||
if isNegative {
|
|
||||||
tf.matchCost *= negativeMatchCostMultiplier
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
rcv, err := getRegexpFromCache(expr)
|
rcv, err := getRegexpFromCache(expr)
|
||||||
|
@ -415,9 +409,6 @@ func (tf *tagFilter) Init(commonPrefix, key, value []byte, isNegative, isRegexp
|
||||||
tf.orSuffixes = append(tf.orSuffixes[:0], rcv.orValues...)
|
tf.orSuffixes = append(tf.orSuffixes[:0], rcv.orValues...)
|
||||||
tf.reSuffixMatch = rcv.reMatch
|
tf.reSuffixMatch = rcv.reMatch
|
||||||
tf.matchCost = rcv.reCost
|
tf.matchCost = rcv.reCost
|
||||||
if isNegative {
|
|
||||||
tf.matchCost *= negativeMatchCostMultiplier
|
|
||||||
}
|
|
||||||
tf.isEmptyMatch = len(prefix) == 0 && tf.reSuffixMatch(nil)
|
tf.isEmptyMatch = len(prefix) == 0 && tf.reSuffixMatch(nil)
|
||||||
if !tf.isNegative && len(key) == 0 && strings.IndexByte(rcv.literalSuffix, '.') >= 0 {
|
if !tf.isNegative && len(key) == 0 && strings.IndexByte(rcv.literalSuffix, '.') >= 0 {
|
||||||
// Reverse suffix is needed only for non-negative regexp filters on __name__ that contains dots.
|
// Reverse suffix is needed only for non-negative regexp filters on __name__ that contains dots.
|
||||||
|
@ -589,8 +580,6 @@ const (
|
||||||
reMatchCost = 100
|
reMatchCost = 100
|
||||||
)
|
)
|
||||||
|
|
||||||
const negativeMatchCostMultiplier = 1000
|
|
||||||
|
|
||||||
func getOptimizedReMatchFuncExt(reMatch func(b []byte) bool, sre *syntax.Regexp) (func(b []byte) bool, string, uint64) {
|
func getOptimizedReMatchFuncExt(reMatch func(b []byte) bool, sre *syntax.Regexp) (func(b []byte) bool, string, uint64) {
|
||||||
if isDotStar(sre) {
|
if isDotStar(sre) {
|
||||||
// '.*'
|
// '.*'
|
||||||
|
|
Loading…
Reference in a new issue