mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect/promql: do not add step to range end, since this hack became obsolete since commit 9e1119dab8
This commit is contained in:
parent
4a1de7fee9
commit
e6d9ea3094
3 changed files with 17 additions and 44 deletions
|
@ -40,25 +40,11 @@ func Exec(ec *EvalConfig, q string, isFirstPointOnly bool) ([]netstorage.Result,
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add an additional point to the end. This point is used
|
|
||||||
// in calculating the last value for rate, deriv, increase
|
|
||||||
// and delta funcs.
|
|
||||||
ec.End += ec.Step
|
|
||||||
|
|
||||||
rv, err := evalExpr(ec, e)
|
rv, err := evalExpr(ec, e)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the additional point at the end.
|
|
||||||
for _, ts := range rv {
|
|
||||||
ts.Values = ts.Values[:len(ts.Values)-1]
|
|
||||||
|
|
||||||
// ts.Timestamps may be shared between timeseries, so truncate it with len(ts.Values) instead of len(ts.Timestamps)-1
|
|
||||||
ts.Timestamps = ts.Timestamps[:len(ts.Values)]
|
|
||||||
}
|
|
||||||
ec.End -= ec.Step
|
|
||||||
|
|
||||||
if isFirstPointOnly {
|
if isFirstPointOnly {
|
||||||
// Remove all the points except the first one from every time series.
|
// Remove all the points except the first one from every time series.
|
||||||
for _, ts := range rv {
|
for _, ts := range rv {
|
||||||
|
|
|
@ -3471,7 +3471,7 @@ func TestExecSuccess(t *testing.T) {
|
||||||
q := `sort(histogram_over_time(alias(label_set(rand(0)*1.3+1.1, "foo", "bar"), "xxx")[200s:5s]))`
|
q := `sort(histogram_over_time(alias(label_set(rand(0)*1.3+1.1, "foo", "bar"), "xxx")[200s:5s]))`
|
||||||
r1 := netstorage.Result{
|
r1 := netstorage.Result{
|
||||||
MetricName: metricNameExpected,
|
MetricName: metricNameExpected,
|
||||||
Values: []float64{13, 14, 12, 8, 12, 13},
|
Values: []float64{14, 15, 12, 13, 15, 11},
|
||||||
Timestamps: timestampsExpected,
|
Timestamps: timestampsExpected,
|
||||||
}
|
}
|
||||||
r1.MetricName.Tags = []storage.Tag{
|
r1.MetricName.Tags = []storage.Tag{
|
||||||
|
@ -3481,12 +3481,12 @@ func TestExecSuccess(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Key: []byte("vmrange"),
|
Key: []byte("vmrange"),
|
||||||
Value: []byte("1.0e0...1.5e0"),
|
Value: []byte("2.0e0...2.5e0"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
r2 := netstorage.Result{
|
r2 := netstorage.Result{
|
||||||
MetricName: metricNameExpected,
|
MetricName: metricNameExpected,
|
||||||
Values: []float64{14, 15, 12, 13, 15, 11},
|
Values: []float64{13, 14, 12, 8, 12, 13},
|
||||||
Timestamps: timestampsExpected,
|
Timestamps: timestampsExpected,
|
||||||
}
|
}
|
||||||
r2.MetricName.Tags = []storage.Tag{
|
r2.MetricName.Tags = []storage.Tag{
|
||||||
|
@ -3496,7 +3496,7 @@ func TestExecSuccess(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Key: []byte("vmrange"),
|
Key: []byte("vmrange"),
|
||||||
Value: []byte("2.0e0...2.5e0"),
|
Value: []byte("1.0e0...1.5e0"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
r3 := netstorage.Result{
|
r3 := netstorage.Result{
|
||||||
|
@ -3522,24 +3522,24 @@ func TestExecSuccess(t *testing.T) {
|
||||||
q := `sort(sum(histogram_over_time(alias(label_set(rand(0)*1.3+1.1, "foo", "bar"), "xxx")[200s:5s])) by (vmrange))`
|
q := `sort(sum(histogram_over_time(alias(label_set(rand(0)*1.3+1.1, "foo", "bar"), "xxx")[200s:5s])) by (vmrange))`
|
||||||
r1 := netstorage.Result{
|
r1 := netstorage.Result{
|
||||||
MetricName: metricNameExpected,
|
MetricName: metricNameExpected,
|
||||||
Values: []float64{13, 14, 12, 8, 12, 13},
|
Values: []float64{14, 15, 12, 13, 15, 11},
|
||||||
Timestamps: timestampsExpected,
|
Timestamps: timestampsExpected,
|
||||||
}
|
}
|
||||||
r1.MetricName.Tags = []storage.Tag{
|
r1.MetricName.Tags = []storage.Tag{
|
||||||
{
|
{
|
||||||
Key: []byte("vmrange"),
|
Key: []byte("vmrange"),
|
||||||
Value: []byte("1.0e0...1.5e0"),
|
Value: []byte("2.0e0...2.5e0"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
r2 := netstorage.Result{
|
r2 := netstorage.Result{
|
||||||
MetricName: metricNameExpected,
|
MetricName: metricNameExpected,
|
||||||
Values: []float64{14, 15, 12, 13, 15, 11},
|
Values: []float64{13, 14, 12, 8, 12, 13},
|
||||||
Timestamps: timestampsExpected,
|
Timestamps: timestampsExpected,
|
||||||
}
|
}
|
||||||
r2.MetricName.Tags = []storage.Tag{
|
r2.MetricName.Tags = []storage.Tag{
|
||||||
{
|
{
|
||||||
Key: []byte("vmrange"),
|
Key: []byte("vmrange"),
|
||||||
Value: []byte("2.0e0...2.5e0"),
|
Value: []byte("1.0e0...1.5e0"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
r3 := netstorage.Result{
|
r3 := netstorage.Result{
|
||||||
|
@ -3787,12 +3787,12 @@ func TestExecSuccess(t *testing.T) {
|
||||||
q := `sort(bottomk_avg(1, label_set(10, "foo", "bar") or label_set(time()/150, "baz", "sss")))`
|
q := `sort(bottomk_avg(1, label_set(10, "foo", "bar") or label_set(time()/150, "baz", "sss")))`
|
||||||
r1 := netstorage.Result{
|
r1 := netstorage.Result{
|
||||||
MetricName: metricNameExpected,
|
MetricName: metricNameExpected,
|
||||||
Values: []float64{10, 10, 10, nan, nan, nan},
|
Values: []float64{6.666666666666667, 8, 9.333333333333334, 10.666666666666666, 12, 13.333333333333334},
|
||||||
Timestamps: timestampsExpected,
|
Timestamps: timestampsExpected,
|
||||||
}
|
}
|
||||||
r1.MetricName.Tags = []storage.Tag{{
|
r1.MetricName.Tags = []storage.Tag{{
|
||||||
Key: []byte("foo"),
|
Key: []byte("baz"),
|
||||||
Value: []byte("bar"),
|
Value: []byte("sss"),
|
||||||
}}
|
}}
|
||||||
resultExpected := []netstorage.Result{r1}
|
resultExpected := []netstorage.Result{r1}
|
||||||
f(q, resultExpected)
|
f(q, resultExpected)
|
||||||
|
@ -4708,21 +4708,21 @@ func TestExecSuccess(t *testing.T) {
|
||||||
}}
|
}}
|
||||||
r2 := netstorage.Result{
|
r2 := netstorage.Result{
|
||||||
MetricName: metricNameExpected,
|
MetricName: metricNameExpected,
|
||||||
Values: []float64{0.1, 0.04, 0.49, 0.46, 0.57, 0.92},
|
Values: []float64{0.9, 0.32, 0.82, 0.13, 0.28, 0.86},
|
||||||
Timestamps: timestampsExpected,
|
Timestamps: timestampsExpected,
|
||||||
}
|
}
|
||||||
r2.MetricName.Tags = []storage.Tag{{
|
r2.MetricName.Tags = []storage.Tag{{
|
||||||
Key: []byte("rollup"),
|
Key: []byte("rollup"),
|
||||||
Value: []byte("close"),
|
Value: []byte("open"),
|
||||||
}}
|
}}
|
||||||
r3 := netstorage.Result{
|
r3 := netstorage.Result{
|
||||||
MetricName: metricNameExpected,
|
MetricName: metricNameExpected,
|
||||||
Values: []float64{0.9, 0.32, 0.82, 0.13, 0.28, 0.86},
|
Values: []float64{0.1, 0.04, 0.49, 0.46, 0.57, 0.92},
|
||||||
Timestamps: timestampsExpected,
|
Timestamps: timestampsExpected,
|
||||||
}
|
}
|
||||||
r3.MetricName.Tags = []storage.Tag{{
|
r3.MetricName.Tags = []storage.Tag{{
|
||||||
Key: []byte("rollup"),
|
Key: []byte("rollup"),
|
||||||
Value: []byte("open"),
|
Value: []byte("close"),
|
||||||
}}
|
}}
|
||||||
r4 := netstorage.Result{
|
r4 := netstorage.Result{
|
||||||
MetricName: metricNameExpected,
|
MetricName: metricNameExpected,
|
||||||
|
|
|
@ -820,10 +820,6 @@ func transformRangeQuantile(tfa *transformFuncArg) ([]*timeseries, error) {
|
||||||
hf.Reset()
|
hf.Reset()
|
||||||
lastIdx := -1
|
lastIdx := -1
|
||||||
values := ts.Values
|
values := ts.Values
|
||||||
if len(values) > 0 {
|
|
||||||
// Ignore the last value. See Exec func for details.
|
|
||||||
values = values[:len(values)-1]
|
|
||||||
}
|
|
||||||
for i, v := range values {
|
for i, v := range values {
|
||||||
if math.IsNaN(v) {
|
if math.IsNaN(v) {
|
||||||
continue
|
continue
|
||||||
|
@ -874,14 +870,7 @@ func transformRangeLast(tfa *transformFuncArg) ([]*timeseries, error) {
|
||||||
|
|
||||||
func setLastValues(tss []*timeseries) {
|
func setLastValues(tss []*timeseries) {
|
||||||
for _, ts := range tss {
|
for _, ts := range tss {
|
||||||
values := ts.Values
|
values := skipTrailingNaNs(ts.Values)
|
||||||
if len(values) < 2 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// Do not take into account the last value, since it shouldn't be included
|
|
||||||
// in the range. See Exec func for details.
|
|
||||||
values = values[:len(values)-1]
|
|
||||||
values = skipTrailingNaNs(values)
|
|
||||||
if len(values) == 0 {
|
if len(values) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -1521,9 +1510,7 @@ func transformStart(tfa *transformFuncArg) float64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
func transformEnd(tfa *transformFuncArg) float64 {
|
func transformEnd(tfa *transformFuncArg) float64 {
|
||||||
// Subtract step from end, since it shouldn't go to the range.
|
return float64(tfa.ec.End) * 1e-3
|
||||||
// See Exec func for details.
|
|
||||||
return float64(tfa.ec.End-tfa.ec.Step) * 1e-3
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// copyTimeseriesMetricNames returns a copy of arg with real copy of MetricNames,
|
// copyTimeseriesMetricNames returns a copy of arg with real copy of MetricNames,
|
||||||
|
|
Loading…
Reference in a new issue