Remove local.ZeroSample{,Pair}, use model definitions

This commit is contained in:
Julius Volz 2016-09-28 23:40:26 +02:00
parent 50b5837a63
commit c25f0de5ae
4 changed files with 14 additions and 28 deletions

View file

@ -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,
}
}

View file

@ -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}

View file

@ -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.

View file

@ -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)
}