mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Fix iterator behavior in view.GetSampleAtTime()
This commit is contained in:
parent
bb9c5ed7aa
commit
4e7db57e76
|
@ -126,18 +126,22 @@ func (v view) Close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v view) GetValueAtTime(f model.Fingerprint, t time.Time) (s []model.SamplePair) {
|
func (v view) GetValueAtTime(f model.Fingerprint, t time.Time) (s []model.SamplePair) {
|
||||||
var (
|
series, ok := v.fingerprintToSeries[f]
|
||||||
series, ok = v.fingerprintToSeries[f]
|
|
||||||
)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
iterator := series.values.Seek(skipListTime(t))
|
||||||
iterator = series.values.Seek(skipListTime(t))
|
|
||||||
)
|
|
||||||
if iterator == nil {
|
if iterator == nil {
|
||||||
return
|
// If the iterator is nil, it means we seeked past the end of the series,
|
||||||
|
// so we seek to the last value instead. Due to the reverse ordering
|
||||||
|
// defined on skipListTime, this corresponds to the sample with the
|
||||||
|
// earliest timestamp.
|
||||||
|
iterator = series.values.SeekToLast()
|
||||||
|
if iterator == nil {
|
||||||
|
// The list is empty.
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defer iterator.Close()
|
defer iterator.Close()
|
||||||
|
|
Loading…
Reference in a new issue