mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
203bb5f651
commit
ecef86c641
4 changed files with 86 additions and 86 deletions
|
@ -72,10 +72,10 @@ func (fs *streamFilter) apply(bs *blockSearch, bm *bitmap) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// rangeFilter matches the given range [minValue..maxValue].
|
// filterRange matches the given range [minValue..maxValue].
|
||||||
//
|
//
|
||||||
// Example LogsQL: `fieldName:range(minValue, maxValue]`
|
// Example LogsQL: `fieldName:range(minValue, maxValue]`
|
||||||
type rangeFilter struct {
|
type filterRange struct {
|
||||||
fieldName string
|
fieldName string
|
||||||
minValue float64
|
minValue float64
|
||||||
maxValue float64
|
maxValue float64
|
||||||
|
@ -83,11 +83,11 @@ type rangeFilter struct {
|
||||||
stringRepr string
|
stringRepr string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fr *rangeFilter) String() string {
|
func (fr *filterRange) String() string {
|
||||||
return quoteFieldNameIfNeeded(fr.fieldName) + "range" + fr.stringRepr
|
return quoteFieldNameIfNeeded(fr.fieldName) + "range" + fr.stringRepr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fr *rangeFilter) apply(bs *blockSearch, bm *bitmap) {
|
func (fr *filterRange) apply(bs *blockSearch, bm *bitmap) {
|
||||||
fieldName := fr.fieldName
|
fieldName := fr.fieldName
|
||||||
minValue := fr.minValue
|
minValue := fr.minValue
|
||||||
maxValue := fr.maxValue
|
maxValue := fr.maxValue
|
||||||
|
|
|
@ -697,7 +697,7 @@ func TestRegexpFilter(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRangeFilter(t *testing.T) {
|
func TestFilterRange(t *testing.T) {
|
||||||
t.Run("const-column", func(t *testing.T) {
|
t.Run("const-column", func(t *testing.T) {
|
||||||
columns := []column{
|
columns := []column{
|
||||||
{
|
{
|
||||||
|
@ -711,21 +711,21 @@ func TestRangeFilter(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// match
|
// match
|
||||||
fr := &rangeFilter{
|
fr := &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -10,
|
minValue: -10,
|
||||||
maxValue: 20,
|
maxValue: 20,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{0, 1, 2})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{0, 1, 2})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 10,
|
minValue: 10,
|
||||||
maxValue: 10,
|
maxValue: 10,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{0, 1, 2})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{0, 1, 2})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 10,
|
minValue: 10,
|
||||||
maxValue: 20,
|
maxValue: 20,
|
||||||
|
@ -733,35 +733,35 @@ func TestRangeFilter(t *testing.T) {
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{0, 1, 2})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{0, 1, 2})
|
||||||
|
|
||||||
// mismatch
|
// mismatch
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -10,
|
minValue: -10,
|
||||||
maxValue: 9.99,
|
maxValue: 9.99,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 20,
|
minValue: 20,
|
||||||
maxValue: -10,
|
maxValue: -10,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 10.1,
|
minValue: 10.1,
|
||||||
maxValue: 20,
|
maxValue: 20,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "non-existing-column",
|
fieldName: "non-existing-column",
|
||||||
minValue: 10,
|
minValue: 10,
|
||||||
maxValue: 20,
|
maxValue: 20,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 11,
|
minValue: 11,
|
||||||
maxValue: 10,
|
maxValue: 10,
|
||||||
|
@ -786,21 +786,21 @@ func TestRangeFilter(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// match
|
// match
|
||||||
fr := &rangeFilter{
|
fr := &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -10,
|
minValue: -10,
|
||||||
maxValue: 20,
|
maxValue: 20,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{1, 3, 4})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{1, 3, 4})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 10,
|
minValue: 10,
|
||||||
maxValue: 20,
|
maxValue: 20,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{1, 3, 4})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{1, 3, 4})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 10.1,
|
minValue: 10.1,
|
||||||
maxValue: 19.9,
|
maxValue: 19.9,
|
||||||
|
@ -808,28 +808,28 @@ func TestRangeFilter(t *testing.T) {
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{4})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{4})
|
||||||
|
|
||||||
// mismatch
|
// mismatch
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -11,
|
minValue: -11,
|
||||||
maxValue: 0,
|
maxValue: 0,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 11,
|
minValue: 11,
|
||||||
maxValue: 19,
|
maxValue: 19,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 20.1,
|
minValue: 20.1,
|
||||||
maxValue: 100,
|
maxValue: 100,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 20,
|
minValue: 20,
|
||||||
maxValue: 10,
|
maxValue: 10,
|
||||||
|
@ -858,21 +858,21 @@ func TestRangeFilter(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// match
|
// match
|
||||||
fr := &rangeFilter{
|
fr := &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -100,
|
minValue: -100,
|
||||||
maxValue: 100,
|
maxValue: 100,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{2, 3, 4, 5})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{2, 3, 4, 5})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 10,
|
minValue: 10,
|
||||||
maxValue: 20,
|
maxValue: 20,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{2, 3, 4})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{2, 3, 4})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -5,
|
minValue: -5,
|
||||||
maxValue: -5,
|
maxValue: -5,
|
||||||
|
@ -880,21 +880,21 @@ func TestRangeFilter(t *testing.T) {
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{5})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{5})
|
||||||
|
|
||||||
// mismatch
|
// mismatch
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -10,
|
minValue: -10,
|
||||||
maxValue: -5.1,
|
maxValue: -5.1,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 20.1,
|
minValue: 20.1,
|
||||||
maxValue: 100,
|
maxValue: 100,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 20,
|
minValue: 20,
|
||||||
maxValue: 10,
|
maxValue: 10,
|
||||||
|
@ -923,21 +923,21 @@ func TestRangeFilter(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// match
|
// match
|
||||||
fr := &rangeFilter{
|
fr := &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 0,
|
minValue: 0,
|
||||||
maxValue: 3,
|
maxValue: 3,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7, 8})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7, 8})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 0.1,
|
minValue: 0.1,
|
||||||
maxValue: 2.9,
|
maxValue: 2.9,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{6, 7})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{6, 7})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -1e18,
|
minValue: -1e18,
|
||||||
maxValue: 2.9,
|
maxValue: 2.9,
|
||||||
|
@ -945,21 +945,21 @@ func TestRangeFilter(t *testing.T) {
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7})
|
||||||
|
|
||||||
// mismatch
|
// mismatch
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -1e18,
|
minValue: -1e18,
|
||||||
maxValue: -0.1,
|
maxValue: -0.1,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 0.1,
|
minValue: 0.1,
|
||||||
maxValue: 0.9,
|
maxValue: 0.9,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 2.9,
|
minValue: 2.9,
|
||||||
maxValue: 0.1,
|
maxValue: 0.1,
|
||||||
|
@ -989,21 +989,21 @@ func TestRangeFilter(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// match
|
// match
|
||||||
fr := &rangeFilter{
|
fr := &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 0,
|
minValue: 0,
|
||||||
maxValue: 3,
|
maxValue: 3,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7, 8})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7, 8})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 0.1,
|
minValue: 0.1,
|
||||||
maxValue: 2.9,
|
maxValue: 2.9,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{6, 7})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{6, 7})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -1e18,
|
minValue: -1e18,
|
||||||
maxValue: 2.9,
|
maxValue: 2.9,
|
||||||
|
@ -1011,21 +1011,21 @@ func TestRangeFilter(t *testing.T) {
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7})
|
||||||
|
|
||||||
// mismatch
|
// mismatch
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -1e18,
|
minValue: -1e18,
|
||||||
maxValue: -0.1,
|
maxValue: -0.1,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 0.1,
|
minValue: 0.1,
|
||||||
maxValue: 0.9,
|
maxValue: 0.9,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 2.9,
|
minValue: 2.9,
|
||||||
maxValue: 0.1,
|
maxValue: 0.1,
|
||||||
|
@ -1054,21 +1054,21 @@ func TestRangeFilter(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// match
|
// match
|
||||||
fr := &rangeFilter{
|
fr := &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 0,
|
minValue: 0,
|
||||||
maxValue: 3,
|
maxValue: 3,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7, 8})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7, 8})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 0.1,
|
minValue: 0.1,
|
||||||
maxValue: 2.9,
|
maxValue: 2.9,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{6, 7})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{6, 7})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -1e18,
|
minValue: -1e18,
|
||||||
maxValue: 2.9,
|
maxValue: 2.9,
|
||||||
|
@ -1076,21 +1076,21 @@ func TestRangeFilter(t *testing.T) {
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7})
|
||||||
|
|
||||||
// mismatch
|
// mismatch
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -1e18,
|
minValue: -1e18,
|
||||||
maxValue: -0.1,
|
maxValue: -0.1,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 0.1,
|
minValue: 0.1,
|
||||||
maxValue: 0.9,
|
maxValue: 0.9,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 2.9,
|
minValue: 2.9,
|
||||||
maxValue: 0.1,
|
maxValue: 0.1,
|
||||||
|
@ -1119,28 +1119,28 @@ func TestRangeFilter(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// match
|
// match
|
||||||
fr := &rangeFilter{
|
fr := &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: math.Inf(-1),
|
minValue: math.Inf(-1),
|
||||||
maxValue: 3,
|
maxValue: 3,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7, 8})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7, 8})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 0.1,
|
minValue: 0.1,
|
||||||
maxValue: 2.9,
|
maxValue: 2.9,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{6, 7})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{6, 7})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -1e18,
|
minValue: -1e18,
|
||||||
maxValue: 2.9,
|
maxValue: 2.9,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 1000,
|
minValue: 1000,
|
||||||
maxValue: math.Inf(1),
|
maxValue: math.Inf(1),
|
||||||
|
@ -1148,21 +1148,21 @@ func TestRangeFilter(t *testing.T) {
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{5})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{5})
|
||||||
|
|
||||||
// mismatch
|
// mismatch
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -1e18,
|
minValue: -1e18,
|
||||||
maxValue: -0.1,
|
maxValue: -0.1,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 0.1,
|
minValue: 0.1,
|
||||||
maxValue: 0.9,
|
maxValue: 0.9,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 2.9,
|
minValue: 2.9,
|
||||||
maxValue: 0.1,
|
maxValue: 0.1,
|
||||||
|
@ -1191,28 +1191,28 @@ func TestRangeFilter(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// match
|
// match
|
||||||
fr := &rangeFilter{
|
fr := &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: math.Inf(-1),
|
minValue: math.Inf(-1),
|
||||||
maxValue: 3,
|
maxValue: 3,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7, 8})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 7, 8})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 0.1,
|
minValue: 0.1,
|
||||||
maxValue: 2.9,
|
maxValue: 2.9,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{7})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{7})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -1e18,
|
minValue: -1e18,
|
||||||
maxValue: 1.9,
|
maxValue: 1.9,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 8})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{3, 4, 6, 8})
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 1000,
|
minValue: 1000,
|
||||||
maxValue: math.Inf(1),
|
maxValue: math.Inf(1),
|
||||||
|
@ -1220,21 +1220,21 @@ func TestRangeFilter(t *testing.T) {
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", []int{5})
|
testFilterMatchForColumns(t, columns, fr, "foo", []int{5})
|
||||||
|
|
||||||
// mismatch
|
// mismatch
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -1e18,
|
minValue: -1e18,
|
||||||
maxValue: -334.1,
|
maxValue: -334.1,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 0.1,
|
minValue: 0.1,
|
||||||
maxValue: 0.9,
|
maxValue: 0.9,
|
||||||
}
|
}
|
||||||
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
testFilterMatchForColumns(t, columns, fr, "foo", nil)
|
||||||
|
|
||||||
fr = &rangeFilter{
|
fr = &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: 2.9,
|
minValue: 2.9,
|
||||||
maxValue: 0.1,
|
maxValue: 0.1,
|
||||||
|
@ -1264,7 +1264,7 @@ func TestRangeFilter(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// range filter always mismatches ipv4
|
// range filter always mismatches ipv4
|
||||||
fr := &rangeFilter{
|
fr := &filterRange{
|
||||||
fieldName: "foo",
|
fieldName: "foo",
|
||||||
minValue: -100,
|
minValue: -100,
|
||||||
maxValue: 100,
|
maxValue: 100,
|
||||||
|
@ -1291,7 +1291,7 @@ func TestRangeFilter(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// range filter always mismatches timestmap
|
// range filter always mismatches timestmap
|
||||||
fr := &rangeFilter{
|
fr := &filterRange{
|
||||||
fieldName: "_msg",
|
fieldName: "_msg",
|
||||||
minValue: -100,
|
minValue: -100,
|
||||||
maxValue: 100,
|
maxValue: 100,
|
||||||
|
|
|
@ -332,7 +332,7 @@ func parseGenericFilter(lex *lexer, fieldName string) (filter, error) {
|
||||||
case lex.isKeyword("len_range"):
|
case lex.isKeyword("len_range"):
|
||||||
return parseFilterLenRange(lex, fieldName)
|
return parseFilterLenRange(lex, fieldName)
|
||||||
case lex.isKeyword("range"):
|
case lex.isKeyword("range"):
|
||||||
return parseRangeFilter(lex, fieldName)
|
return parseFilterRange(lex, fieldName)
|
||||||
case lex.isKeyword("re"):
|
case lex.isKeyword("re"):
|
||||||
return parseRegexpFilter(lex, fieldName)
|
return parseRegexpFilter(lex, fieldName)
|
||||||
case lex.isKeyword("seq"):
|
case lex.isKeyword("seq"):
|
||||||
|
@ -664,7 +664,7 @@ func parseRegexpFilter(lex *lexer, fieldName string) (filter, error) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseRangeFilter(lex *lexer, fieldName string) (filter, error) {
|
func parseFilterRange(lex *lexer, fieldName string) (filter, error) {
|
||||||
funcName := lex.token
|
funcName := lex.token
|
||||||
lex.nextToken()
|
lex.nextToken()
|
||||||
|
|
||||||
|
@ -726,7 +726,7 @@ func parseRangeFilter(lex *lexer, fieldName string) (filter, error) {
|
||||||
maxValue = math.Nextafter(maxValue, math.Inf(-1))
|
maxValue = math.Nextafter(maxValue, math.Inf(-1))
|
||||||
}
|
}
|
||||||
|
|
||||||
fr := &rangeFilter{
|
fr := &filterRange{
|
||||||
fieldName: fieldName,
|
fieldName: fieldName,
|
||||||
minValue: minValue,
|
minValue: minValue,
|
||||||
maxValue: maxValue,
|
maxValue: maxValue,
|
||||||
|
|
|
@ -332,18 +332,18 @@ func TestParseFilterIPv4Range(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %s", err)
|
t.Fatalf("unexpected error: %s", err)
|
||||||
}
|
}
|
||||||
rf, ok := q.f.(*filterIPv4Range)
|
fr, ok := q.f.(*filterIPv4Range)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("unexpected filter type; got %T; want *filterIPv4Range; filter: %s", q.f, q.f)
|
t.Fatalf("unexpected filter type; got %T; want *filterIPv4Range; filter: %s", q.f, q.f)
|
||||||
}
|
}
|
||||||
if rf.fieldName != fieldNameExpected {
|
if fr.fieldName != fieldNameExpected {
|
||||||
t.Fatalf("unexpected fieldName; got %q; want %q", rf.fieldName, fieldNameExpected)
|
t.Fatalf("unexpected fieldName; got %q; want %q", fr.fieldName, fieldNameExpected)
|
||||||
}
|
}
|
||||||
if rf.minValue != minValueExpected {
|
if fr.minValue != minValueExpected {
|
||||||
t.Fatalf("unexpected minValue; got %08x; want %08x", rf.minValue, minValueExpected)
|
t.Fatalf("unexpected minValue; got %08x; want %08x", fr.minValue, minValueExpected)
|
||||||
}
|
}
|
||||||
if rf.maxValue != maxValueExpected {
|
if fr.maxValue != maxValueExpected {
|
||||||
t.Fatalf("unexpected maxValue; got %08x; want %08x", rf.maxValue, maxValueExpected)
|
t.Fatalf("unexpected maxValue; got %08x; want %08x", fr.maxValue, maxValueExpected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,18 +363,18 @@ func TestParseFilterStringRange(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %s", err)
|
t.Fatalf("unexpected error: %s", err)
|
||||||
}
|
}
|
||||||
rf, ok := q.f.(*filterStringRange)
|
fr, ok := q.f.(*filterStringRange)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("unexpected filter type; got %T; want *filterStringRange; filter: %s", q.f, q.f)
|
t.Fatalf("unexpected filter type; got %T; want *filterStringRange; filter: %s", q.f, q.f)
|
||||||
}
|
}
|
||||||
if rf.fieldName != fieldNameExpected {
|
if fr.fieldName != fieldNameExpected {
|
||||||
t.Fatalf("unexpected fieldName; got %q; want %q", rf.fieldName, fieldNameExpected)
|
t.Fatalf("unexpected fieldName; got %q; want %q", fr.fieldName, fieldNameExpected)
|
||||||
}
|
}
|
||||||
if rf.minValue != minValueExpected {
|
if fr.minValue != minValueExpected {
|
||||||
t.Fatalf("unexpected minValue; got %q; want %q", rf.minValue, minValueExpected)
|
t.Fatalf("unexpected minValue; got %q; want %q", fr.minValue, minValueExpected)
|
||||||
}
|
}
|
||||||
if rf.maxValue != maxValueExpected {
|
if fr.maxValue != maxValueExpected {
|
||||||
t.Fatalf("unexpected maxValue; got %q; want %q", rf.maxValue, maxValueExpected)
|
t.Fatalf("unexpected maxValue; got %q; want %q", fr.maxValue, maxValueExpected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,11 +389,11 @@ func TestParseRegexpFilter(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %s", err)
|
t.Fatalf("unexpected error: %s", err)
|
||||||
}
|
}
|
||||||
rf, ok := q.f.(*regexpFilter)
|
fr, ok := q.f.(*regexpFilter)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("unexpected filter type; got %T; want *regexpFilter; filter: %s", q.f, q.f)
|
t.Fatalf("unexpected filter type; got %T; want *regexpFilter; filter: %s", q.f, q.f)
|
||||||
}
|
}
|
||||||
if reString := rf.re.String(); reString != reExpected {
|
if reString := fr.re.String(); reString != reExpected {
|
||||||
t.Fatalf("unexpected regexp; got %q; want %q", reString, reExpected)
|
t.Fatalf("unexpected regexp; got %q; want %q", reString, reExpected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -517,18 +517,18 @@ func TestParseRangeFilter(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %s", err)
|
t.Fatalf("unexpected error: %s", err)
|
||||||
}
|
}
|
||||||
rf, ok := q.f.(*rangeFilter)
|
fr, ok := q.f.(*filterRange)
|
||||||
if !ok {
|
if !ok {
|
||||||
t.Fatalf("unexpected filter type; got %T; want *filterIPv4Range; filter: %s", q.f, q.f)
|
t.Fatalf("unexpected filter type; got %T; want *filterIPv4Range; filter: %s", q.f, q.f)
|
||||||
}
|
}
|
||||||
if rf.fieldName != fieldNameExpected {
|
if fr.fieldName != fieldNameExpected {
|
||||||
t.Fatalf("unexpected fieldName; got %q; want %q", rf.fieldName, fieldNameExpected)
|
t.Fatalf("unexpected fieldName; got %q; want %q", fr.fieldName, fieldNameExpected)
|
||||||
}
|
}
|
||||||
if rf.minValue != minValueExpected {
|
if fr.minValue != minValueExpected {
|
||||||
t.Fatalf("unexpected minValue; got %v; want %v", rf.minValue, minValueExpected)
|
t.Fatalf("unexpected minValue; got %v; want %v", fr.minValue, minValueExpected)
|
||||||
}
|
}
|
||||||
if rf.maxValue != maxValueExpected {
|
if fr.maxValue != maxValueExpected {
|
||||||
t.Fatalf("unexpected maxValue; got %v; want %v", rf.maxValue, maxValueExpected)
|
t.Fatalf("unexpected maxValue; got %v; want %v", fr.maxValue, maxValueExpected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue