mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08:00
Remove local.ZeroSample{,Pair}, use model definitions
This commit is contained in:
parent
50b5837a63
commit
c25f0de5ae
|
@ -299,7 +299,7 @@ type Iterator interface {
|
||||||
// or an error has occurred.
|
// or an error has occurred.
|
||||||
FindAtOrAfter(model.Time) bool
|
FindAtOrAfter(model.Time) bool
|
||||||
// Returns the last value scanned (by the scan method) or found (by one
|
// 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.
|
// those methods were called.
|
||||||
Value() model.SamplePair
|
Value() model.SamplePair
|
||||||
// Returns the last error encountered. In general, an error signals data
|
// Returns the last error encountered. In general, an error signals data
|
||||||
|
@ -409,7 +409,7 @@ func newIndexAccessingChunkIterator(len int, acc indexAccessor) *indexAccessingC
|
||||||
return &indexAccessingChunkIterator{
|
return &indexAccessingChunkIterator{
|
||||||
len: len,
|
len: len,
|
||||||
pos: -1,
|
pos: -1,
|
||||||
lastValue: model.SamplePair{Timestamp: model.Earliest},
|
lastValue: model.ZeroSamplePair,
|
||||||
acc: acc,
|
acc: acc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ type Querier interface {
|
||||||
type SeriesIterator interface {
|
type SeriesIterator interface {
|
||||||
// Gets the value that is closest before the given time. In case a value
|
// 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
|
// 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
|
ValueAtOrBeforeTime(model.Time) model.SamplePair
|
||||||
// Gets all values contained within a given interval.
|
// Gets all values contained within a given interval.
|
||||||
RangeValues(metric.Interval) []model.SamplePair
|
RangeValues(metric.Interval) []model.SamplePair
|
||||||
|
@ -100,17 +100,3 @@ type SeriesIterator interface {
|
||||||
// Closes the iterator and releases the underlying data.
|
// Closes the iterator and releases the underlying data.
|
||||||
Close()
|
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}
|
|
||||||
|
|
|
@ -430,7 +430,7 @@ func (s *memorySeries) preloadChunksForInstant(
|
||||||
lastSample := s.lastSamplePair()
|
lastSample := s.lastSamplePair()
|
||||||
if !through.Before(lastSample.Timestamp) &&
|
if !through.Before(lastSample.Timestamp) &&
|
||||||
!from.After(lastSample.Timestamp) &&
|
!from.After(lastSample.Timestamp) &&
|
||||||
lastSample != ZeroSamplePair {
|
lastSample != model.ZeroSamplePair {
|
||||||
iter := &boundedIterator{
|
iter := &boundedIterator{
|
||||||
it: &singleSampleSeriesIterator{
|
it: &singleSampleSeriesIterator{
|
||||||
samplePair: lastSample,
|
samplePair: lastSample,
|
||||||
|
@ -522,7 +522,7 @@ func (s *memorySeries) firstTime() model.Time {
|
||||||
}
|
}
|
||||||
|
|
||||||
// lastSamplePair returns the last ingested SamplePair. It returns
|
// 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
|
// 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,
|
// ones and also for all series after a server restart. However, in that case,
|
||||||
// series will most likely be considered stale anyway.
|
// 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.
|
// The caller must have locked the fingerprint of the memorySeries.
|
||||||
func (s *memorySeries) lastSamplePair() model.SamplePair {
|
func (s *memorySeries) lastSamplePair() model.SamplePair {
|
||||||
if !s.lastSampleValueSet {
|
if !s.lastSampleValueSet {
|
||||||
return ZeroSamplePair
|
return model.ZeroSamplePair
|
||||||
}
|
}
|
||||||
return model.SamplePair{
|
return model.SamplePair{
|
||||||
Timestamp: s.lastTime,
|
Timestamp: s.lastTime,
|
||||||
|
@ -583,7 +583,7 @@ func (it *memorySeriesIterator) ValueAtOrBeforeTime(t model.Time) model.SamplePa
|
||||||
containsT, err := it.chunkIt.Contains(t)
|
containsT, err := it.chunkIt.Contains(t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
it.quarantine(err)
|
it.quarantine(err)
|
||||||
return ZeroSamplePair
|
return model.ZeroSamplePair
|
||||||
}
|
}
|
||||||
if containsT {
|
if containsT {
|
||||||
if it.chunkIt.FindAtOrBefore(t) {
|
if it.chunkIt.FindAtOrBefore(t) {
|
||||||
|
@ -592,12 +592,12 @@ func (it *memorySeriesIterator) ValueAtOrBeforeTime(t model.Time) model.SamplePa
|
||||||
if it.chunkIt.Err() != nil {
|
if it.chunkIt.Err() != nil {
|
||||||
it.quarantine(it.chunkIt.Err())
|
it.quarantine(it.chunkIt.Err())
|
||||||
}
|
}
|
||||||
return ZeroSamplePair
|
return model.ZeroSamplePair
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(it.chunks) == 0 {
|
if len(it.chunks) == 0 {
|
||||||
return ZeroSamplePair
|
return model.ZeroSamplePair
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the last chunk where FirstTime() is before or equal to t.
|
// 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) {
|
if i == len(it.chunks) {
|
||||||
// Even the first chunk starts after t.
|
// Even the first chunk starts after t.
|
||||||
return ZeroSamplePair
|
return model.ZeroSamplePair
|
||||||
}
|
}
|
||||||
it.chunkIt = it.chunkIterator(l - i)
|
it.chunkIt = it.chunkIterator(l - i)
|
||||||
if it.chunkIt.FindAtOrBefore(t) {
|
if it.chunkIt.FindAtOrBefore(t) {
|
||||||
|
@ -616,7 +616,7 @@ func (it *memorySeriesIterator) ValueAtOrBeforeTime(t model.Time) model.SamplePa
|
||||||
if it.chunkIt.Err() != nil {
|
if it.chunkIt.Err() != nil {
|
||||||
it.quarantine(it.chunkIt.Err())
|
it.quarantine(it.chunkIt.Err())
|
||||||
}
|
}
|
||||||
return ZeroSamplePair
|
return model.ZeroSamplePair
|
||||||
}
|
}
|
||||||
|
|
||||||
// RangeValues implements SeriesIterator.
|
// RangeValues implements SeriesIterator.
|
||||||
|
@ -686,7 +686,7 @@ type singleSampleSeriesIterator struct {
|
||||||
// ValueAtTime implements SeriesIterator.
|
// ValueAtTime implements SeriesIterator.
|
||||||
func (it *singleSampleSeriesIterator) ValueAtOrBeforeTime(t model.Time) model.SamplePair {
|
func (it *singleSampleSeriesIterator) ValueAtOrBeforeTime(t model.Time) model.SamplePair {
|
||||||
if it.samplePair.Timestamp.After(t) {
|
if it.samplePair.Timestamp.After(t) {
|
||||||
return ZeroSamplePair
|
return model.ZeroSamplePair
|
||||||
}
|
}
|
||||||
return it.samplePair
|
return it.samplePair
|
||||||
}
|
}
|
||||||
|
@ -712,7 +712,7 @@ type nopSeriesIterator struct{}
|
||||||
|
|
||||||
// ValueAtTime implements SeriesIterator.
|
// ValueAtTime implements SeriesIterator.
|
||||||
func (i nopSeriesIterator) ValueAtOrBeforeTime(t model.Time) model.SamplePair {
|
func (i nopSeriesIterator) ValueAtOrBeforeTime(t model.Time) model.SamplePair {
|
||||||
return ZeroSamplePair
|
return model.ZeroSamplePair
|
||||||
}
|
}
|
||||||
|
|
||||||
// RangeValues implements SeriesIterator.
|
// RangeValues implements SeriesIterator.
|
||||||
|
|
|
@ -452,7 +452,7 @@ type boundedIterator struct {
|
||||||
// ValueAtOrBeforeTime implements the SeriesIterator interface.
|
// ValueAtOrBeforeTime implements the SeriesIterator interface.
|
||||||
func (bit *boundedIterator) ValueAtOrBeforeTime(ts model.Time) model.SamplePair {
|
func (bit *boundedIterator) ValueAtOrBeforeTime(ts model.Time) model.SamplePair {
|
||||||
if ts < bit.start {
|
if ts < bit.start {
|
||||||
return ZeroSamplePair
|
return model.ZeroSamplePair
|
||||||
}
|
}
|
||||||
return bit.it.ValueAtOrBeforeTime(ts)
|
return bit.it.ValueAtOrBeforeTime(ts)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue