mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
storage: rename iterator value getters to At()
This commit is contained in:
parent
89b6b3be9f
commit
bc20d93f0a
|
@ -431,7 +431,7 @@ func (ng *Engine) populateIterators(ctx context.Context, s *EvalStmt) (storage.Q
|
|||
|
||||
func expandSeriesSet(it storage.SeriesSet) (res []storage.Series, err error) {
|
||||
for it.Next() {
|
||||
res = append(res, it.Series())
|
||||
res = append(res, it.At())
|
||||
}
|
||||
return res, it.Err()
|
||||
}
|
||||
|
@ -676,7 +676,7 @@ func (ev *evaluator) matrixSelector(node *MatrixSelector) Matrix {
|
|||
|
||||
buf := it.Buffer()
|
||||
for buf.Next() {
|
||||
t, v := buf.Values()
|
||||
t, v := buf.At()
|
||||
// Values in the buffer are guaranteed to be smaller than maxt.
|
||||
if t >= mint {
|
||||
ss.Points = append(ss.Points, Point{T: t, V: v})
|
||||
|
|
|
@ -62,7 +62,7 @@ func (b *BufferedSeriesIterator) Seek(t int64) bool {
|
|||
// Next advances the iterator to the next element.
|
||||
func (b *BufferedSeriesIterator) Next() bool {
|
||||
// Add current element to buffer before advancing.
|
||||
b.buf.add(b.it.Values())
|
||||
b.buf.add(b.it.At())
|
||||
|
||||
ok := b.it.Next()
|
||||
if ok {
|
||||
|
@ -73,7 +73,7 @@ func (b *BufferedSeriesIterator) Next() bool {
|
|||
|
||||
// Values returns the current element of the iterator.
|
||||
func (b *BufferedSeriesIterator) Values() (int64, float64) {
|
||||
return b.it.Values()
|
||||
return b.it.At()
|
||||
}
|
||||
|
||||
// Err returns the last encountered error.
|
||||
|
@ -130,7 +130,7 @@ func (it *sampleRingIterator) Err() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (it *sampleRingIterator) Values() (int64, float64) {
|
||||
func (it *sampleRingIterator) At() (int64, float64) {
|
||||
return it.r.at(it.i)
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ func TestBufferedSeriesIterator(t *testing.T) {
|
|||
var b []sample
|
||||
bit := it.Buffer()
|
||||
for bit.Next() {
|
||||
t, v := bit.Values()
|
||||
t, v := bit.At()
|
||||
b = append(b, sample{t: t, v: v})
|
||||
}
|
||||
require.Equal(t, exp, b, "buffer mismatch")
|
||||
|
@ -153,7 +153,7 @@ func newListSeriesIterator(list []sample) *listSeriesIterator {
|
|||
return &listSeriesIterator{list: list, idx: -1}
|
||||
}
|
||||
|
||||
func (it *listSeriesIterator) Values() (int64, float64) {
|
||||
func (it *listSeriesIterator) At() (int64, float64) {
|
||||
s := it.list[it.idx]
|
||||
return s.t, s.v
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ type Appender interface {
|
|||
// SeriesSet contains a set of series.
|
||||
type SeriesSet interface {
|
||||
Next() bool
|
||||
Series() Series
|
||||
At() Series
|
||||
Err() error
|
||||
}
|
||||
|
||||
|
@ -79,8 +79,8 @@ type SeriesIterator interface {
|
|||
// Seek advances the iterator forward to the value at or after
|
||||
// the given timestamp.
|
||||
Seek(t int64) bool
|
||||
// Values returns the current timestamp/value pair.
|
||||
Values() (t int64, v float64)
|
||||
// At returns the current timestamp/value pair.
|
||||
At() (t int64, v float64)
|
||||
// Next advances the iterator by one.
|
||||
Next() bool
|
||||
// Err returns the current error.
|
||||
|
|
|
@ -58,9 +58,9 @@ type seriesSet struct {
|
|||
set tsdb.SeriesSet
|
||||
}
|
||||
|
||||
func (s seriesSet) Next() bool { return s.set.Next() }
|
||||
func (s seriesSet) Err() error { return s.set.Err() }
|
||||
func (s seriesSet) Series() storage.Series { return series{s: s.set.Series()} }
|
||||
func (s seriesSet) Next() bool { return s.set.Next() }
|
||||
func (s seriesSet) Err() error { return s.set.Err() }
|
||||
func (s seriesSet) At() storage.Series { return series{s: s.set.At()} }
|
||||
|
||||
type series struct {
|
||||
s tsdb.Series
|
||||
|
@ -76,6 +76,7 @@ type appender struct {
|
|||
func (a appender) Add(lset labels.Labels, t int64, v float64) error {
|
||||
return a.a.Add(toTSDBLabels(lset), t, v)
|
||||
}
|
||||
|
||||
func (a appender) Commit() error { return a.a.Commit() }
|
||||
|
||||
func convertMatcher(m *labels.Matcher) tsdbLabels.Matcher {
|
||||
|
|
|
@ -309,7 +309,7 @@ func (api *API) series(r *http.Request) (interface{}, *apiError) {
|
|||
for _, mset := range matcherSets {
|
||||
series := q.Select(mset...)
|
||||
for series.Next() {
|
||||
metrics = append(metrics, series.Series().Labels())
|
||||
metrics = append(metrics, series.At().Labels())
|
||||
}
|
||||
if series.Err() != nil {
|
||||
return nil, &apiError{errorExec, series.Err()}
|
||||
|
|
|
@ -77,7 +77,7 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
|
|||
for _, mset := range matcherSets {
|
||||
series := q.Select(mset...)
|
||||
for series.Next() {
|
||||
s := series.Series()
|
||||
s := series.At()
|
||||
// TODO(fabxc): allow fast path for most recent sample either
|
||||
// in the storage itself or caching layer in Prometheus.
|
||||
it := storage.NewBuffer(s.Iterator(), int64(promql.StalenessDelta/1e6))
|
||||
|
|
Loading…
Reference in a new issue