mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 21:54:10 -08:00
Fix GetBoundaryValues.
Change-Id: I8f8bbdb88e9b24e4c37ff869126ed9343f261ce2
This commit is contained in:
parent
4fc8ad6677
commit
83b4fa868d
|
@ -540,9 +540,6 @@ func (it *memorySeriesIterator) GetValueAtTime(t clientmodel.Timestamp) metric.V
|
|||
|
||||
// GetBoundaryValues implements SeriesIterator.
|
||||
func (it *memorySeriesIterator) GetBoundaryValues(in metric.Interval) metric.Values {
|
||||
return it.GetRangeValues(in)
|
||||
|
||||
// TODO: The following doesn't work as expected. Fix it.
|
||||
it.lock()
|
||||
defer it.unlock()
|
||||
|
||||
|
@ -550,9 +547,8 @@ func (it *memorySeriesIterator) GetBoundaryValues(in metric.Interval) metric.Val
|
|||
i := sort.Search(len(it.chunks), func(i int) bool {
|
||||
return !it.chunks[i].lastTime().Before(in.OldestInclusive)
|
||||
})
|
||||
values := metric.Values{}
|
||||
for ; i < len(it.chunks); i++ {
|
||||
c := it.chunks[i]
|
||||
values := make(metric.Values, 0, 2)
|
||||
for i, c := range it.chunks[i:] {
|
||||
var chunkIt chunkIterator
|
||||
if c.firstTime().After(in.NewestInclusive) {
|
||||
if len(values) == 1 {
|
||||
|
@ -585,6 +581,13 @@ func (it *memorySeriesIterator) GetBoundaryValues(in metric.Interval) metric.Val
|
|||
break
|
||||
}
|
||||
}
|
||||
if len(values) == 1 {
|
||||
// We found exactly one value. In that case, add the most recent we know.
|
||||
values = append(
|
||||
values,
|
||||
it.chunks[len(it.chunks)-1].newIterator().getValueAtTime(in.NewestInclusive)[0],
|
||||
)
|
||||
}
|
||||
if len(values) == 2 && values[0].Equal(&values[1]) {
|
||||
return values[:1]
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ type SamplePair struct {
|
|||
|
||||
// Equal returns true if this SamplePair and o have equal Values and equal
|
||||
// Timestamps.
|
||||
// TODO: can this method be deleted, or is it used in tests?
|
||||
func (s *SamplePair) Equal(o *SamplePair) bool {
|
||||
if s == o {
|
||||
return true
|
||||
|
|
Loading…
Reference in a new issue