|
|
@ -361,6 +361,22 @@ func postingsForMatcher(ix IndexReader, m *labels.Matcher) (index.Postings, erro
|
|
|
|
|
|
|
|
|
|
|
|
// inversePostingsForMatcher returns the postings for the series with the label name set but not matching the matcher.
|
|
|
|
// inversePostingsForMatcher returns the postings for the series with the label name set but not matching the matcher.
|
|
|
|
func inversePostingsForMatcher(ix IndexReader, m *labels.Matcher) (index.Postings, error) {
|
|
|
|
func inversePostingsForMatcher(ix IndexReader, m *labels.Matcher) (index.Postings, error) {
|
|
|
|
|
|
|
|
// Fast-path for MatchNotRegexp matching.
|
|
|
|
|
|
|
|
// Inverse of a MatchNotRegexp is MatchRegexp (double negation).
|
|
|
|
|
|
|
|
// Fast-path for set matching.
|
|
|
|
|
|
|
|
if m.Type == labels.MatchNotRegexp {
|
|
|
|
|
|
|
|
setMatches := findSetMatches(m.GetRegexString())
|
|
|
|
|
|
|
|
if len(setMatches) > 0 {
|
|
|
|
|
|
|
|
return ix.Postings(m.Name, setMatches...)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Fast-path for MatchNotEqual matching.
|
|
|
|
|
|
|
|
// Inverse of a MatchNotEqual is MatchEqual (double negation).
|
|
|
|
|
|
|
|
if m.Type == labels.MatchNotEqual {
|
|
|
|
|
|
|
|
return ix.Postings(m.Name, m.Value)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vals, err := ix.LabelValues(m.Name)
|
|
|
|
vals, err := ix.LabelValues(m.Name)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
@ -371,14 +387,6 @@ func inversePostingsForMatcher(ix IndexReader, m *labels.Matcher) (index.Posting
|
|
|
|
if m.Type == labels.MatchEqual && m.Value == "" {
|
|
|
|
if m.Type == labels.MatchEqual && m.Value == "" {
|
|
|
|
res = vals
|
|
|
|
res = vals
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Inverse of a MatchNotRegexp is MatchRegexp (double negation).
|
|
|
|
|
|
|
|
// Fast-path for set matching.
|
|
|
|
|
|
|
|
if m.Type == labels.MatchNotRegexp {
|
|
|
|
|
|
|
|
setMatches := findSetMatches(m.GetRegexString())
|
|
|
|
|
|
|
|
if len(setMatches) > 0 {
|
|
|
|
|
|
|
|
return ix.Postings(m.Name, setMatches...)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, val := range vals {
|
|
|
|
for _, val := range vals {
|
|
|
|
if !m.Matches(val) {
|
|
|
|
if !m.Matches(val) {
|
|
|
|
res = append(res, val)
|
|
|
|
res = append(res, val)
|
|
|
|