Wire up tag not null/empty filter
parent
877f90aed3
commit
f8fdb4e5ff
15
index.go
15
index.go
|
@ -210,7 +210,22 @@ func (m measurementIndex) seriesByTags(tags map[string]string) *Series {
|
|||
func (m measurementIndex) seriesIDs(filter *Filter) (ids SeriesIDs) {
|
||||
values := m.tagsToSeries[filter.Key]
|
||||
if values != nil {
|
||||
// this is for the value is not null query
|
||||
if filter.Not && filter.Value == "" {
|
||||
for _, v := range values {
|
||||
if ids == nil {
|
||||
ids = v
|
||||
} else {
|
||||
ids.Intersect(v)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// get the ids that have the given key/value tag pair
|
||||
ids = SeriesIDs(values[filter.Value])
|
||||
|
||||
// filter out these ids from the entire set if it's a not query
|
||||
if filter.Not {
|
||||
ids = m.ids.Reject(ids)
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ func TestIndex_SeriesIDsWhereFilter(t *testing.T) {
|
|||
// match against no tags
|
||||
{
|
||||
names: []string{"cpu_load", "redis"},
|
||||
result: []uint32{uint32(1), uint32(2), uint32(3), uint32(4), uint32(5)},
|
||||
result: []uint32{uint32(1), uint32(2), uint32(3), uint32(4), uint32(5), uint32(6)},
|
||||
},
|
||||
|
||||
// match against all tags
|
||||
|
@ -217,6 +217,13 @@ func TestIndex_SeriesIDsWhereFilter(t *testing.T) {
|
|||
},
|
||||
|
||||
// query against a tag NOT null
|
||||
{
|
||||
names: []string{"queue_depth"},
|
||||
filters: []*influxdb.Filter{
|
||||
&influxdb.Filter{Key: "app", Value: "", Not: true},
|
||||
},
|
||||
result: []uint32{uint32(6)},
|
||||
},
|
||||
|
||||
// query against a tag value and a NOT value on the same key
|
||||
|
||||
|
@ -330,6 +337,15 @@ func indexWithFixtureData() *influxdb.Index {
|
|||
return nil
|
||||
}
|
||||
|
||||
s = &influxdb.Series{
|
||||
ID: uint32(6),
|
||||
Tags: map[string]string{"name": "high priority", "app": "paultown"}}
|
||||
|
||||
added = idx.AddSeries("queue_depth", s)
|
||||
if !added {
|
||||
return nil
|
||||
}
|
||||
|
||||
return idx
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue