mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08:00
Return a nop iterator for series that have been purged completely.
Change-Id: I6e92cac4472486feefdecba8593c17867e8c710d
This commit is contained in:
parent
6e3a366f91
commit
2b4ff620aa
|
@ -456,13 +456,6 @@ func (s *memorySeries) preloadChunksForRange(from clientmodel.Timestamp, through
|
||||||
return s.preloadChunks(pinIndexes, p)
|
return s.preloadChunks(pinIndexes, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// memorySeriesIterator implements SeriesIterator.
|
|
||||||
type memorySeriesIterator struct {
|
|
||||||
lock, unlock func()
|
|
||||||
chunkIt chunkIterator
|
|
||||||
chunks chunks
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *memorySeries) newIterator(lockFunc, unlockFunc func()) SeriesIterator {
|
func (s *memorySeries) newIterator(lockFunc, unlockFunc func()) SeriesIterator {
|
||||||
chunks := make(chunks, 0, len(s.chunkDescs))
|
chunks := make(chunks, 0, len(s.chunkDescs))
|
||||||
for i, cd := range s.chunkDescs {
|
for i, cd := range s.chunkDescs {
|
||||||
|
@ -504,6 +497,13 @@ func (s *memorySeries) lastTime() clientmodel.Timestamp {
|
||||||
return s.head().lastTime()
|
return s.head().lastTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// memorySeriesIterator implements SeriesIterator.
|
||||||
|
type memorySeriesIterator struct {
|
||||||
|
lock, unlock func()
|
||||||
|
chunkIt chunkIterator
|
||||||
|
chunks chunks
|
||||||
|
}
|
||||||
|
|
||||||
// GetValueAtTime implements SeriesIterator.
|
// GetValueAtTime implements SeriesIterator.
|
||||||
func (it *memorySeriesIterator) GetValueAtTime(t clientmodel.Timestamp) metric.Values {
|
func (it *memorySeriesIterator) GetValueAtTime(t clientmodel.Timestamp) metric.Values {
|
||||||
it.lock()
|
it.lock()
|
||||||
|
@ -628,3 +628,21 @@ func (it *memorySeriesIterator) GetRangeValues(in metric.Interval) metric.Values
|
||||||
}
|
}
|
||||||
return values
|
return values
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nopSeriesIterator implements Series Iterator. It never returns any values.
|
||||||
|
type nopSeriesIterator struct{}
|
||||||
|
|
||||||
|
// GetValueAtTime implements SeriesIterator.
|
||||||
|
func (_ nopSeriesIterator) GetValueAtTime(t clientmodel.Timestamp) metric.Values {
|
||||||
|
return metric.Values{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetBoundaryValues implements SeriesIterator.
|
||||||
|
func (_ nopSeriesIterator) GetBoundaryValues(in metric.Interval) metric.Values {
|
||||||
|
return metric.Values{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRangeValues implements SeriesIterator.
|
||||||
|
func (_ nopSeriesIterator) GetRangeValues(in metric.Interval) metric.Values {
|
||||||
|
return metric.Values{}
|
||||||
|
}
|
||||||
|
|
|
@ -185,8 +185,12 @@ func (s *memorySeriesStorage) NewIterator(fp clientmodel.Fingerprint) SeriesIter
|
||||||
|
|
||||||
series, ok := s.fingerprintToSeries.get(fp)
|
series, ok := s.fingerprintToSeries.get(fp)
|
||||||
if !ok {
|
if !ok {
|
||||||
// TODO: Could this legitimately happen? Series just got purged?
|
// Oops, no series for fp found. That happens if, after
|
||||||
panic("requested iterator for non-existent series")
|
// preloading is done, the whole series is identified as old
|
||||||
|
// enough for purging and hence purged for good. As there is no
|
||||||
|
// data left to iterate over, return an iterator that will never
|
||||||
|
// return any values.
|
||||||
|
return nopSeriesIterator{}
|
||||||
}
|
}
|
||||||
return series.newIterator(
|
return series.newIterator(
|
||||||
func() { s.fpLocker.Lock(fp) },
|
func() { s.fpLocker.Lock(fp) },
|
||||||
|
|
Loading…
Reference in a new issue