Inline method

Signed-off-by: Charles Korn <charles.korn@grafana.com>
This commit is contained in:
Charles Korn 2023-06-28 15:09:58 +10:00
parent a2a2cc757e
commit eeface2e17
No known key found for this signature in database
1 changed files with 29 additions and 35 deletions

View File

@ -1832,35 +1832,28 @@ func (ev *evaluator) evalTimestampFunctionOverVectorSelector(vs *parser.VectorSe
// needs to be adjusted for every point. // needs to be adjusted for every point.
vs.Offset = time.Duration(enh.Ts-*vs.Timestamp) * time.Millisecond vs.Offset = time.Duration(enh.Ts-*vs.Timestamp) * time.Millisecond
} }
val, ws := ev.vectorSelector(vs, enh.Ts) ws, err := checkAndExpandSeriesSet(ev.ctx, vs)
return call([]parser.Value{val}, e.Args, enh), ws
})
}
// vectorSelector evaluates a *parser.VectorSelector expression.
func (ev *evaluator) vectorSelector(node *parser.VectorSelector, ts int64) (Vector, storage.Warnings) {
ws, err := checkAndExpandSeriesSet(ev.ctx, node)
if err != nil { if err != nil {
ev.error(errWithWarnings{fmt.Errorf("expanding series: %w", err), ws}) ev.error(errWithWarnings{fmt.Errorf("expanding series: %w", err), ws})
} }
vec := make(Vector, 0, len(node.Series)) vec := make(Vector, 0, len(vs.Series))
it := storage.NewMemoizedEmptyIterator(durationMilliseconds(ev.lookbackDelta)) it := storage.NewMemoizedEmptyIterator(durationMilliseconds(ev.lookbackDelta))
var chkIter chunkenc.Iterator var chkIter chunkenc.Iterator
for i, s := range node.Series { for i, s := range vs.Series {
chkIter = s.Iterator(chkIter) chkIter = s.Iterator(chkIter)
it.Reset(chkIter) it.Reset(chkIter)
t, f, h, ok := ev.vectorSelectorSingle(it, node, ts) t, f, h, ok := ev.vectorSelectorSingle(it, vs, enh.Ts)
if ok { if ok {
vec = append(vec, Sample{ vec = append(vec, Sample{
Metric: node.Series[i].Labels(), Metric: vs.Series[i].Labels(),
T: t, T: t,
F: f, F: f,
H: h, H: h,
}) })
ev.currentSamples++ ev.currentSamples++
ev.samplesStats.IncrementSamplesAtTimestamp(ts, 1) ev.samplesStats.IncrementSamplesAtTimestamp(enh.Ts, 1)
if ev.currentSamples > ev.maxSamples { if ev.currentSamples > ev.maxSamples {
ev.error(ErrTooManySamples(env)) ev.error(ErrTooManySamples(env))
} }
@ -1868,7 +1861,8 @@ func (ev *evaluator) vectorSelector(node *parser.VectorSelector, ts int64) (Vect
} }
ev.samplesStats.UpdatePeak(ev.currentSamples) ev.samplesStats.UpdatePeak(ev.currentSamples)
return vec, ws return call([]parser.Value{vec}, e.Args, enh), ws
})
} }
// vectorSelectorSingle evaluates an instant vector for the iterator of one time series. // vectorSelectorSingle evaluates an instant vector for the iterator of one time series.