Fix bug on array values in tsdb storage engine

pull/10291/head
linxGnu 2018-07-24 13:21:39 +09:00 committed by Stuart Carnie
parent f67bbe76b5
commit 2356a30833
3 changed files with 19 additions and 0 deletions

View File

@ -58,6 +58,9 @@ func (a *FloatArray) Exclude(min, max int64) {
vs := a.Values[:rmin+rest]
copy(vs[rmin:], a.Values[rmax:])
a.Values = vs
} else {
a.Timestamps = a.Timestamps[:rmin]
a.Values = a.Values[:rmin]
}
} else {
a.Timestamps = a.Timestamps[:rmin]
@ -258,6 +261,9 @@ func (a *IntegerArray) Exclude(min, max int64) {
vs := a.Values[:rmin+rest]
copy(vs[rmin:], a.Values[rmax:])
a.Values = vs
} else {
a.Timestamps = a.Timestamps[:rmin]
a.Values = a.Values[:rmin]
}
} else {
a.Timestamps = a.Timestamps[:rmin]
@ -458,6 +464,9 @@ func (a *UnsignedArray) Exclude(min, max int64) {
vs := a.Values[:rmin+rest]
copy(vs[rmin:], a.Values[rmax:])
a.Values = vs
} else {
a.Timestamps = a.Timestamps[:rmin]
a.Values = a.Values[:rmin]
}
} else {
a.Timestamps = a.Timestamps[:rmin]
@ -658,6 +667,9 @@ func (a *StringArray) Exclude(min, max int64) {
vs := a.Values[:rmin+rest]
copy(vs[rmin:], a.Values[rmax:])
a.Values = vs
} else {
a.Timestamps = a.Timestamps[:rmin]
a.Values = a.Values[:rmin]
}
} else {
a.Timestamps = a.Timestamps[:rmin]
@ -858,6 +870,9 @@ func (a *BooleanArray) Exclude(min, max int64) {
vs := a.Values[:rmin+rest]
copy(vs[rmin:], a.Values[rmax:])
a.Values = vs
} else {
a.Timestamps = a.Timestamps[:rmin]
a.Values = a.Values[:rmin]
}
} else {
a.Timestamps = a.Timestamps[:rmin]

View File

@ -56,6 +56,9 @@ func (a *{{ $typename }}) Exclude(min, max int64) {
vs := a.Values[:rmin+rest]
copy(vs[rmin:], a.Values[rmax:])
a.Values = vs
} else {
a.Timestamps = a.Timestamps[:rmin]
a.Values = a.Values[:rmin]
}
} else {
a.Timestamps = a.Timestamps[:rmin]

View File

@ -80,6 +80,7 @@ func TestIntegerArray_Exclude(t *testing.T) {
{"excl all but first and last", 12, 16, []int64{10, 18}},
{"excl none in middle", 13, 13, []int64{10, 12, 14, 16, 18}},
{"excl middle", 14, 14, []int64{10, 12, 16, 18}},
{"excl suffix", 16, 18, []int64{10, 12, 14}},
}
for _, tc := range cases {