diff --git a/storage/local/chunk/chunk.go b/storage/local/chunk/chunk.go index d48973660..d26237394 100644 --- a/storage/local/chunk/chunk.go +++ b/storage/local/chunk/chunk.go @@ -299,7 +299,7 @@ type Iterator interface { // or an error has occurred. FindAtOrAfter(model.Time) bool // Returns the last value scanned (by the scan method) or found (by one - // of the find... methods). It returns ZeroSamplePair before any of + // of the find... methods). It returns model.ZeroSamplePair before any of // those methods were called. Value() model.SamplePair // Returns the last error encountered. In general, an error signals data @@ -409,7 +409,7 @@ func newIndexAccessingChunkIterator(len int, acc indexAccessor) *indexAccessingC return &indexAccessingChunkIterator{ len: len, pos: -1, - lastValue: model.SamplePair{Timestamp: model.Earliest}, + lastValue: model.ZeroSamplePair, acc: acc, } } diff --git a/storage/local/interface.go b/storage/local/interface.go index 4b88a7f6b..7e95a158b 100644 --- a/storage/local/interface.go +++ b/storage/local/interface.go @@ -91,7 +91,7 @@ type Querier interface { type SeriesIterator interface { // Gets the value that is closest before the given time. In case a value // exists at precisely the given time, that value is returned. If no - // applicable value exists, ZeroSamplePair is returned. + // applicable value exists, model.ZeroSamplePair is returned. ValueAtOrBeforeTime(model.Time) model.SamplePair // Gets all values contained within a given interval. RangeValues(metric.Interval) []model.SamplePair @@ -100,17 +100,3 @@ type SeriesIterator interface { // Closes the iterator and releases the underlying data. Close() } - -// ZeroSamplePair is the pseudo zero-value of model.SamplePair used by the local -// package to signal a non-existing sample pair. It is a SamplePair with -// timestamp model.Earliest and value 0.0. Note that the natural zero value of -// SamplePair has a timestamp of 0, which is possible to appear in a real -// SamplePair and thus not suitable to signal a non-existing SamplePair. -var ZeroSamplePair = model.SamplePair{Timestamp: model.Earliest} - -// ZeroSample is the pseudo zero-value of model.Sample used by the local package -// to signal a non-existing sample. It is a Sample with timestamp -// model.Earliest, value 0.0, and metric nil. Note that the natural zero value -// of Sample has a timestamp of 0, which is possible to appear in a real -// Sample and thus not suitable to signal a non-existing Sample. -var ZeroSample = model.Sample{Timestamp: model.Earliest} diff --git a/storage/local/series.go b/storage/local/series.go index 3f733787a..9717cb0ea 100644 --- a/storage/local/series.go +++ b/storage/local/series.go @@ -430,7 +430,7 @@ func (s *memorySeries) preloadChunksForInstant( lastSample := s.lastSamplePair() if !through.Before(lastSample.Timestamp) && !from.After(lastSample.Timestamp) && - lastSample != ZeroSamplePair { + lastSample != model.ZeroSamplePair { iter := &boundedIterator{ it: &singleSampleSeriesIterator{ samplePair: lastSample, @@ -522,7 +522,7 @@ func (s *memorySeries) firstTime() model.Time { } // lastSamplePair returns the last ingested SamplePair. It returns -// ZeroSamplePair if this memorySeries has never received a sample (via the add +// model.ZeroSamplePair if this memorySeries has never received a sample (via the add // method), which is the case for freshly unarchived series or newly created // ones and also for all series after a server restart. However, in that case, // series will most likely be considered stale anyway. @@ -530,7 +530,7 @@ func (s *memorySeries) firstTime() model.Time { // The caller must have locked the fingerprint of the memorySeries. func (s *memorySeries) lastSamplePair() model.SamplePair { if !s.lastSampleValueSet { - return ZeroSamplePair + return model.ZeroSamplePair } return model.SamplePair{ Timestamp: s.lastTime, @@ -583,7 +583,7 @@ func (it *memorySeriesIterator) ValueAtOrBeforeTime(t model.Time) model.SamplePa containsT, err := it.chunkIt.Contains(t) if err != nil { it.quarantine(err) - return ZeroSamplePair + return model.ZeroSamplePair } if containsT { if it.chunkIt.FindAtOrBefore(t) { @@ -592,12 +592,12 @@ func (it *memorySeriesIterator) ValueAtOrBeforeTime(t model.Time) model.SamplePa if it.chunkIt.Err() != nil { it.quarantine(it.chunkIt.Err()) } - return ZeroSamplePair + return model.ZeroSamplePair } } if len(it.chunks) == 0 { - return ZeroSamplePair + return model.ZeroSamplePair } // Find the last chunk where FirstTime() is before or equal to t. @@ -607,7 +607,7 @@ func (it *memorySeriesIterator) ValueAtOrBeforeTime(t model.Time) model.SamplePa }) if i == len(it.chunks) { // Even the first chunk starts after t. - return ZeroSamplePair + return model.ZeroSamplePair } it.chunkIt = it.chunkIterator(l - i) if it.chunkIt.FindAtOrBefore(t) { @@ -616,7 +616,7 @@ func (it *memorySeriesIterator) ValueAtOrBeforeTime(t model.Time) model.SamplePa if it.chunkIt.Err() != nil { it.quarantine(it.chunkIt.Err()) } - return ZeroSamplePair + return model.ZeroSamplePair } // RangeValues implements SeriesIterator. @@ -686,7 +686,7 @@ type singleSampleSeriesIterator struct { // ValueAtTime implements SeriesIterator. func (it *singleSampleSeriesIterator) ValueAtOrBeforeTime(t model.Time) model.SamplePair { if it.samplePair.Timestamp.After(t) { - return ZeroSamplePair + return model.ZeroSamplePair } return it.samplePair } @@ -712,7 +712,7 @@ type nopSeriesIterator struct{} // ValueAtTime implements SeriesIterator. func (i nopSeriesIterator) ValueAtOrBeforeTime(t model.Time) model.SamplePair { - return ZeroSamplePair + return model.ZeroSamplePair } // RangeValues implements SeriesIterator. diff --git a/storage/local/storage.go b/storage/local/storage.go index 4f38325a4..603d38dfb 100644 --- a/storage/local/storage.go +++ b/storage/local/storage.go @@ -452,7 +452,7 @@ type boundedIterator struct { // ValueAtOrBeforeTime implements the SeriesIterator interface. func (bit *boundedIterator) ValueAtOrBeforeTime(ts model.Time) model.SamplePair { if ts < bit.start { - return ZeroSamplePair + return model.ZeroSamplePair } return bit.it.ValueAtOrBeforeTime(ts) }