mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
storage: Consolidate iterator method names (Values -> At) (#9888)
`BufferedSeriesIterator` and `MemoizedSeriesIterator` use a method called `Values` for exactly the purpose for which all other iterators of the same kind use a method called `At`. That alone is confusing, but on top of that, the `Values` method only returns a single sample, not multiple values. I assume the naming has historical reasons. This commit makes it more consistent. It is now easier to read, and now `BufferedSeriesIterator` and `MemoizedSeriesIterator` implement `chunkenc.Iterator` like many other iterators, too. Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
parent
b866db009b
commit
d677aa4b29
|
@ -1643,7 +1643,7 @@ func (ev *evaluator) vectorSelectorSingle(it *storage.MemoizedSeriesIterator, no
|
||||||
}
|
}
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
t, v = it.Values()
|
t, v = it.At()
|
||||||
}
|
}
|
||||||
|
|
||||||
if !ok || t > refTime {
|
if !ok || t > refTime {
|
||||||
|
@ -1763,7 +1763,7 @@ func (ev *evaluator) matrixIterSlice(it *storage.BufferedSeriesIterator, mint, m
|
||||||
}
|
}
|
||||||
// The seeked sample might also be in the range.
|
// The seeked sample might also be in the range.
|
||||||
if ok {
|
if ok {
|
||||||
t, v := it.Values()
|
t, v := it.At()
|
||||||
if t == maxt && !value.IsStaleNaN(v) {
|
if t == maxt && !value.IsStaleNaN(v) {
|
||||||
if ev.currentSamples >= ev.maxSamples {
|
if ev.currentSamples >= ev.maxSamples {
|
||||||
ev.error(ErrTooManySamples(env))
|
ev.error(ErrTooManySamples(env))
|
||||||
|
|
|
@ -89,7 +89,7 @@ func (b *BufferedSeriesIterator) Seek(t int64) bool {
|
||||||
if !b.ok {
|
if !b.ok {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
b.lastTime, _ = b.Values()
|
b.lastTime, _ = b.At()
|
||||||
}
|
}
|
||||||
|
|
||||||
if b.lastTime >= t {
|
if b.lastTime >= t {
|
||||||
|
@ -115,14 +115,14 @@ func (b *BufferedSeriesIterator) Next() bool {
|
||||||
|
|
||||||
b.ok = b.it.Next()
|
b.ok = b.it.Next()
|
||||||
if b.ok {
|
if b.ok {
|
||||||
b.lastTime, _ = b.Values()
|
b.lastTime, _ = b.At()
|
||||||
}
|
}
|
||||||
|
|
||||||
return b.ok
|
return b.ok
|
||||||
}
|
}
|
||||||
|
|
||||||
// Values returns the current element of the iterator.
|
// At returns the current element of the iterator.
|
||||||
func (b *BufferedSeriesIterator) Values() (int64, float64) {
|
func (b *BufferedSeriesIterator) At() (int64, float64) {
|
||||||
return b.it.At()
|
return b.it.At()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ func TestBufferedSeriesIterator(t *testing.T) {
|
||||||
require.Equal(t, exp, b, "buffer mismatch")
|
require.Equal(t, exp, b, "buffer mismatch")
|
||||||
}
|
}
|
||||||
sampleEq := func(ets int64, ev float64) {
|
sampleEq := func(ets int64, ev float64) {
|
||||||
ts, v := it.Values()
|
ts, v := it.At()
|
||||||
require.Equal(t, ets, ts, "timestamp mismatch")
|
require.Equal(t, ets, ts, "timestamp mismatch")
|
||||||
require.Equal(t, ev, v, "value mismatch")
|
require.Equal(t, ev, v, "value mismatch")
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,8 +112,8 @@ func (b *MemoizedSeriesIterator) Next() bool {
|
||||||
return b.ok
|
return b.ok
|
||||||
}
|
}
|
||||||
|
|
||||||
// Values returns the current element of the iterator.
|
// At returns the current element of the iterator.
|
||||||
func (b *MemoizedSeriesIterator) Values() (int64, float64) {
|
func (b *MemoizedSeriesIterator) At() (int64, float64) {
|
||||||
return b.it.At()
|
return b.it.At()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ func TestMemoizedSeriesIterator(t *testing.T) {
|
||||||
var it *MemoizedSeriesIterator
|
var it *MemoizedSeriesIterator
|
||||||
|
|
||||||
sampleEq := func(ets int64, ev float64) {
|
sampleEq := func(ets int64, ev float64) {
|
||||||
ts, v := it.Values()
|
ts, v := it.At()
|
||||||
require.Equal(t, ets, ts, "timestamp mismatch")
|
require.Equal(t, ets, ts, "timestamp mismatch")
|
||||||
require.Equal(t, ev, v, "value mismatch")
|
require.Equal(t, ev, v, "value mismatch")
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
|
||||||
|
|
||||||
ok := it.Seek(maxt)
|
ok := it.Seek(maxt)
|
||||||
if ok {
|
if ok {
|
||||||
t, v = it.Values()
|
t, v = it.At()
|
||||||
} else {
|
} else {
|
||||||
t, v, ok = it.PeekBack(1)
|
t, v, ok = it.PeekBack(1)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
Loading…
Reference in a new issue