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 <beorn@grafana.com>
pull/9893/head
Björn Rabenstein 3 years ago committed by GitHub
parent 7e42acd3b1
commit 4ce01e9770
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1649,9 +1649,9 @@ func (ev *evaluator) vectorSelectorSingle(it *storage.MemoizedSeriesIterator, no
ev.error(it.Err()) ev.error(it.Err())
} }
case chunkenc.ValFloat: case chunkenc.ValFloat:
t, v = it.Values() t, v = it.At()
case chunkenc.ValHistogram, chunkenc.ValFloatHistogram: case chunkenc.ValHistogram, chunkenc.ValFloatHistogram:
t, h = it.FloatHistogramValues() t, h = it.AtFloatHistogram()
default: default:
panic(fmt.Errorf("unknown value type %v", valueType)) panic(fmt.Errorf("unknown value type %v", valueType))
} }
@ -1793,7 +1793,7 @@ loop:
// The sought sample might also be in the range. // The sought sample might also be in the range.
switch soughtValueType { switch soughtValueType {
case chunkenc.ValFloatHistogram, chunkenc.ValHistogram: case chunkenc.ValFloatHistogram, chunkenc.ValHistogram:
t, h := it.FloatHistogramValues() t, h := it.AtFloatHistogram()
if t == maxt && !value.IsStaleNaN(h.Sum) { if t == maxt && !value.IsStaleNaN(h.Sum) {
if ev.currentSamples >= ev.maxSamples { if ev.currentSamples >= ev.maxSamples {
ev.error(ErrTooManySamples(env)) ev.error(ErrTooManySamples(env))
@ -1802,7 +1802,7 @@ loop:
ev.currentSamples++ ev.currentSamples++
} }
case chunkenc.ValFloat: case chunkenc.ValFloat:
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))

@ -93,11 +93,11 @@ func (b *BufferedSeriesIterator) Seek(t int64) chunkenc.ValueType {
case chunkenc.ValNone: case chunkenc.ValNone:
return chunkenc.ValNone return chunkenc.ValNone
case chunkenc.ValFloat: case chunkenc.ValFloat:
b.lastTime, _ = b.Values() b.lastTime, _ = b.At()
case chunkenc.ValHistogram: case chunkenc.ValHistogram:
b.lastTime, _ = b.HistogramValues() b.lastTime, _ = b.AtHistogram()
case chunkenc.ValFloatHistogram: case chunkenc.ValFloatHistogram:
b.lastTime, _ = b.FloatHistogramValues() b.lastTime, _ = b.AtFloatHistogram()
default: default:
panic(fmt.Errorf("BufferedSeriesIterator: unknown value type %v", b.valueType)) panic(fmt.Errorf("BufferedSeriesIterator: unknown value type %v", b.valueType))
} }
@ -137,29 +137,29 @@ func (b *BufferedSeriesIterator) Next() chunkenc.ValueType {
case chunkenc.ValNone: case chunkenc.ValNone:
// Do nothing. // Do nothing.
case chunkenc.ValFloat: case chunkenc.ValFloat:
b.lastTime, _ = b.Values() b.lastTime, _ = b.At()
case chunkenc.ValHistogram: case chunkenc.ValHistogram:
b.lastTime, _ = b.HistogramValues() b.lastTime, _ = b.AtHistogram()
case chunkenc.ValFloatHistogram: case chunkenc.ValFloatHistogram:
b.lastTime, _ = b.FloatHistogramValues() b.lastTime, _ = b.AtFloatHistogram()
default: default:
panic(fmt.Errorf("BufferedSeriesIterator: unknown value type %v", b.valueType)) panic(fmt.Errorf("BufferedSeriesIterator: unknown value type %v", b.valueType))
} }
return b.valueType return b.valueType
} }
// Values returns the current element of the iterator. // At returns the current float element of the iterator.
func (b *BufferedSeriesIterator) Values() (int64, float64) { func (b *BufferedSeriesIterator) At() (int64, float64) {
return b.it.At() return b.it.At()
} }
// HistogramValues returns the current histogram element of the iterator. // AtHistogram returns the current histogram element of the iterator.
func (b *BufferedSeriesIterator) HistogramValues() (int64, *histogram.Histogram) { func (b *BufferedSeriesIterator) AtHistogram() (int64, *histogram.Histogram) {
return b.it.AtHistogram() return b.it.AtHistogram()
} }
// FloatHistogramValues returns the current float-histogram element of the iterator. // AtFloatHistogram returns the current float-histogram element of the iterator.
func (b *BufferedSeriesIterator) FloatHistogramValues() (int64, *histogram.FloatHistogram) { func (b *BufferedSeriesIterator) AtFloatHistogram() (int64, *histogram.FloatHistogram) {
return b.it.AtFloatHistogram() return b.it.AtFloatHistogram()
} }

@ -102,7 +102,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")
} }

@ -127,18 +127,18 @@ func (b *MemoizedSeriesIterator) Next() chunkenc.ValueType {
return b.valueType return b.valueType
} }
// Values returns the current element of the iterator. // At returns the current float element of the iterator.
func (b *MemoizedSeriesIterator) Values() (int64, float64) { func (b *MemoizedSeriesIterator) At() (int64, float64) {
return b.it.At() return b.it.At()
} }
// Values returns the current element of the iterator. // AtHistogram returns the current histogram element of the iterator.
func (b *MemoizedSeriesIterator) HistogramValues() (int64, *histogram.Histogram) { func (b *MemoizedSeriesIterator) AtHistogram() (int64, *histogram.Histogram) {
return b.it.AtHistogram() return b.it.AtHistogram()
} }
// Values returns the current element of the iterator. // AtFloatHistogram returns the current float-histogram element of the iterator.
func (b *MemoizedSeriesIterator) FloatHistogramValues() (int64, *histogram.FloatHistogram) { func (b *MemoizedSeriesIterator) AtFloatHistogram() (int64, *histogram.FloatHistogram) {
return b.it.AtFloatHistogram() return b.it.AtFloatHistogram()
} }

@ -26,7 +26,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")
} }

@ -115,7 +115,7 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
valueType := it.Seek(maxt) valueType := it.Seek(maxt)
if valueType == chunkenc.ValFloat { if valueType == chunkenc.ValFloat {
t, v = it.Values() t, v = it.At()
} else { } else {
// TODO(beorn7): Handle histograms. // TODO(beorn7): Handle histograms.
t, v, _, ok = it.PeekBack(1) t, v, _, ok = it.PeekBack(1)

Loading…
Cancel
Save