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:
Björn Rabenstein 2021-11-29 11:16:40 +01:00 committed by GitHub
parent b866db009b
commit d677aa4b29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 11 deletions

View file

@ -1643,7 +1643,7 @@ func (ev *evaluator) vectorSelectorSingle(it *storage.MemoizedSeriesIterator, no
}
if ok {
t, v = it.Values()
t, v = it.At()
}
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.
if ok {
t, v := it.Values()
t, v := it.At()
if t == maxt && !value.IsStaleNaN(v) {
if ev.currentSamples >= ev.maxSamples {
ev.error(ErrTooManySamples(env))

View file

@ -89,7 +89,7 @@ func (b *BufferedSeriesIterator) Seek(t int64) bool {
if !b.ok {
return false
}
b.lastTime, _ = b.Values()
b.lastTime, _ = b.At()
}
if b.lastTime >= t {
@ -115,14 +115,14 @@ func (b *BufferedSeriesIterator) Next() bool {
b.ok = b.it.Next()
if b.ok {
b.lastTime, _ = b.Values()
b.lastTime, _ = b.At()
}
return b.ok
}
// Values returns the current element of the iterator.
func (b *BufferedSeriesIterator) Values() (int64, float64) {
// At returns the current element of the iterator.
func (b *BufferedSeriesIterator) At() (int64, float64) {
return b.it.At()
}

View file

@ -99,7 +99,7 @@ func TestBufferedSeriesIterator(t *testing.T) {
require.Equal(t, exp, b, "buffer mismatch")
}
sampleEq := func(ets int64, ev float64) {
ts, v := it.Values()
ts, v := it.At()
require.Equal(t, ets, ts, "timestamp mismatch")
require.Equal(t, ev, v, "value mismatch")
}

View file

@ -112,8 +112,8 @@ func (b *MemoizedSeriesIterator) Next() bool {
return b.ok
}
// Values returns the current element of the iterator.
func (b *MemoizedSeriesIterator) Values() (int64, float64) {
// At returns the current element of the iterator.
func (b *MemoizedSeriesIterator) At() (int64, float64) {
return b.it.At()
}

View file

@ -23,7 +23,7 @@ func TestMemoizedSeriesIterator(t *testing.T) {
var it *MemoizedSeriesIterator
sampleEq := func(ets int64, ev float64) {
ts, v := it.Values()
ts, v := it.At()
require.Equal(t, ets, ts, "timestamp mismatch")
require.Equal(t, ev, v, "value mismatch")
}

View file

@ -113,7 +113,7 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
ok := it.Seek(maxt)
if ok {
t, v = it.Values()
t, v = it.At()
} else {
t, v, ok = it.PeekBack(1)
if !ok {