mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-13 17:14:05 -08:00
Implement remaining View Get* methods.
This commit is contained in:
parent
1f42364733
commit
bdb067b47f
|
@ -70,7 +70,7 @@ type StalenessPolicy struct {
|
||||||
// preloading operation.
|
// preloading operation.
|
||||||
type View interface {
|
type View interface {
|
||||||
GetValueAtTime(model.Fingerprint, time.Time) []model.SamplePair
|
GetValueAtTime(model.Fingerprint, time.Time) []model.SamplePair
|
||||||
GetBoundaryValues(model.Fingerprint, model.Interval) []model.SamplePair
|
GetBoundaryValues(model.Fingerprint, model.Interval) (first []model.SamplePair, second []model.SamplePair)
|
||||||
GetRangeValues(model.Fingerprint, model.Interval) []model.SamplePair
|
GetRangeValues(model.Fingerprint, model.Interval) []model.SamplePair
|
||||||
|
|
||||||
// Destroy this view.
|
// Destroy this view.
|
||||||
|
|
|
@ -125,7 +125,7 @@ func (v view) Close() {
|
||||||
v.fingerprintToSeries = make(map[model.Fingerprint]viewStream)
|
v.fingerprintToSeries = make(map[model.Fingerprint]viewStream)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v view) GetValueAtTime(f model.Fingerprint, t time.Time) (s []model.SamplePair) {
|
func (v view) GetValueAtTime(f model.Fingerprint, t time.Time) (samples []model.SamplePair) {
|
||||||
series, ok := v.fingerprintToSeries[f]
|
series, ok := v.fingerprintToSeries[f]
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
|
@ -150,13 +150,13 @@ func (v view) GetValueAtTime(f model.Fingerprint, t time.Time) (s []model.Sample
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
s = append(s, model.SamplePair{
|
samples = append(samples, model.SamplePair{
|
||||||
Timestamp: time.Time(iterator.Key().(skipListTime)),
|
Timestamp: time.Time(iterator.Key().(skipListTime)),
|
||||||
Value: iterator.Value().(value).get(),
|
Value: iterator.Value().(value).get(),
|
||||||
})
|
})
|
||||||
|
|
||||||
if iterator.Previous() {
|
if iterator.Previous() {
|
||||||
s = append(s, model.SamplePair{
|
samples = append(samples, model.SamplePair{
|
||||||
Timestamp: time.Time(iterator.Key().(skipListTime)),
|
Timestamp: time.Time(iterator.Key().(skipListTime)),
|
||||||
Value: iterator.Value().(value).get(),
|
Value: iterator.Value().(value).get(),
|
||||||
})
|
})
|
||||||
|
@ -165,11 +165,39 @@ func (v view) GetValueAtTime(f model.Fingerprint, t time.Time) (s []model.Sample
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v view) GetBoundaryValues(f model.Fingerprint, i model.Interval) (s []model.SamplePair) {
|
func (v view) GetBoundaryValues(f model.Fingerprint, i model.Interval) (first []model.SamplePair, second []model.SamplePair) {
|
||||||
|
first = v.GetValueAtTime(f, i.OldestInclusive)
|
||||||
|
second = v.GetValueAtTime(f, i.NewestInclusive)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v view) GetRangeValues(f model.Fingerprint, i model.Interval) (s []model.SamplePair) {
|
func (v view) GetRangeValues(f model.Fingerprint, i model.Interval) (samples []model.SamplePair) {
|
||||||
|
series, ok := v.fingerprintToSeries[f]
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
iterator := series.values.Seek(skipListTime(i.NewestInclusive))
|
||||||
|
if iterator == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
timestamp := time.Time(iterator.Key().(skipListTime))
|
||||||
|
if timestamp.Before(i.OldestInclusive) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
samples = append(samples, model.SamplePair{
|
||||||
|
Value: iterator.Value().(value).get(),
|
||||||
|
Timestamp: timestamp,
|
||||||
|
})
|
||||||
|
|
||||||
|
if !iterator.Next() {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue