From 4ce01e97707d04c57ab2a39a34400ad64956ff38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Rabenstein?= Date: Mon, 29 Nov 2021 11:53:04 +0100 Subject: [PATCH] storage: Rename ...Values methods to At... (#9889) This mirrors #9888 for the richer iterators we have with histograms in the game. Signed-off-by: beorn7 --- promql/engine.go | 8 ++++---- storage/buffer.go | 24 ++++++++++++------------ storage/buffer_test.go | 2 +- storage/memoized_iterator.go | 12 ++++++------ storage/memoized_iterator_test.go | 2 +- web/federate.go | 2 +- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/promql/engine.go b/promql/engine.go index 0e96f458e..6a83d201e 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -1649,9 +1649,9 @@ func (ev *evaluator) vectorSelectorSingle(it *storage.MemoizedSeriesIterator, no ev.error(it.Err()) } case chunkenc.ValFloat: - t, v = it.Values() + t, v = it.At() case chunkenc.ValHistogram, chunkenc.ValFloatHistogram: - t, h = it.FloatHistogramValues() + t, h = it.AtFloatHistogram() default: panic(fmt.Errorf("unknown value type %v", valueType)) } @@ -1793,7 +1793,7 @@ loop: // The sought sample might also be in the range. switch soughtValueType { case chunkenc.ValFloatHistogram, chunkenc.ValHistogram: - t, h := it.FloatHistogramValues() + t, h := it.AtFloatHistogram() if t == maxt && !value.IsStaleNaN(h.Sum) { if ev.currentSamples >= ev.maxSamples { ev.error(ErrTooManySamples(env)) @@ -1802,7 +1802,7 @@ loop: ev.currentSamples++ } case chunkenc.ValFloat: - t, v := it.Values() + t, v := it.At() if t == maxt && !value.IsStaleNaN(v) { if ev.currentSamples >= ev.maxSamples { ev.error(ErrTooManySamples(env)) diff --git a/storage/buffer.go b/storage/buffer.go index 3dad74d08..34b7d2987 100644 --- a/storage/buffer.go +++ b/storage/buffer.go @@ -93,11 +93,11 @@ func (b *BufferedSeriesIterator) Seek(t int64) chunkenc.ValueType { case chunkenc.ValNone: return chunkenc.ValNone case chunkenc.ValFloat: - b.lastTime, _ = b.Values() + b.lastTime, _ = b.At() case chunkenc.ValHistogram: - b.lastTime, _ = b.HistogramValues() + b.lastTime, _ = b.AtHistogram() case chunkenc.ValFloatHistogram: - b.lastTime, _ = b.FloatHistogramValues() + b.lastTime, _ = b.AtFloatHistogram() default: panic(fmt.Errorf("BufferedSeriesIterator: unknown value type %v", b.valueType)) } @@ -137,29 +137,29 @@ func (b *BufferedSeriesIterator) Next() chunkenc.ValueType { case chunkenc.ValNone: // Do nothing. case chunkenc.ValFloat: - b.lastTime, _ = b.Values() + b.lastTime, _ = b.At() case chunkenc.ValHistogram: - b.lastTime, _ = b.HistogramValues() + b.lastTime, _ = b.AtHistogram() case chunkenc.ValFloatHistogram: - b.lastTime, _ = b.FloatHistogramValues() + b.lastTime, _ = b.AtFloatHistogram() default: panic(fmt.Errorf("BufferedSeriesIterator: unknown value type %v", b.valueType)) } return b.valueType } -// Values returns the current element of the iterator. -func (b *BufferedSeriesIterator) Values() (int64, float64) { +// At returns the current float element of the iterator. +func (b *BufferedSeriesIterator) At() (int64, float64) { return b.it.At() } -// HistogramValues returns the current histogram element of the iterator. -func (b *BufferedSeriesIterator) HistogramValues() (int64, *histogram.Histogram) { +// AtHistogram returns the current histogram element of the iterator. +func (b *BufferedSeriesIterator) AtHistogram() (int64, *histogram.Histogram) { return b.it.AtHistogram() } -// FloatHistogramValues returns the current float-histogram element of the iterator. -func (b *BufferedSeriesIterator) FloatHistogramValues() (int64, *histogram.FloatHistogram) { +// AtFloatHistogram returns the current float-histogram element of the iterator. +func (b *BufferedSeriesIterator) AtFloatHistogram() (int64, *histogram.FloatHistogram) { return b.it.AtFloatHistogram() } diff --git a/storage/buffer_test.go b/storage/buffer_test.go index 1bcc82058..04d37fb05 100644 --- a/storage/buffer_test.go +++ b/storage/buffer_test.go @@ -102,7 +102,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") } diff --git a/storage/memoized_iterator.go b/storage/memoized_iterator.go index a4001cde2..ca8ed6863 100644 --- a/storage/memoized_iterator.go +++ b/storage/memoized_iterator.go @@ -127,18 +127,18 @@ func (b *MemoizedSeriesIterator) Next() chunkenc.ValueType { return b.valueType } -// Values returns the current element of the iterator. -func (b *MemoizedSeriesIterator) Values() (int64, float64) { +// At returns the current float element of the iterator. +func (b *MemoizedSeriesIterator) At() (int64, float64) { return b.it.At() } -// Values returns the current element of the iterator. -func (b *MemoizedSeriesIterator) HistogramValues() (int64, *histogram.Histogram) { +// AtHistogram returns the current histogram element of the iterator. +func (b *MemoizedSeriesIterator) AtHistogram() (int64, *histogram.Histogram) { return b.it.AtHistogram() } -// Values returns the current element of the iterator. -func (b *MemoizedSeriesIterator) FloatHistogramValues() (int64, *histogram.FloatHistogram) { +// AtFloatHistogram returns the current float-histogram element of the iterator. +func (b *MemoizedSeriesIterator) AtFloatHistogram() (int64, *histogram.FloatHistogram) { return b.it.AtFloatHistogram() } diff --git a/storage/memoized_iterator_test.go b/storage/memoized_iterator_test.go index 22c7bbdfc..71c647e71 100644 --- a/storage/memoized_iterator_test.go +++ b/storage/memoized_iterator_test.go @@ -26,7 +26,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") } diff --git a/web/federate.go b/web/federate.go index 137f7f08c..5ba68fa28 100644 --- a/web/federate.go +++ b/web/federate.go @@ -115,7 +115,7 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) { valueType := it.Seek(maxt) if valueType == chunkenc.ValFloat { - t, v = it.Values() + t, v = it.At() } else { // TODO(beorn7): Handle histograms. t, v, _, ok = it.PeekBack(1)