Browse Source

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
commit
4ce01e9770
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      promql/engine.go
  2. 24
      storage/buffer.go
  3. 2
      storage/buffer_test.go
  4. 12
      storage/memoized_iterator.go
  5. 2
      storage/memoized_iterator_test.go
  6. 2
      web/federate.go

8
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))

24
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()
}

2
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")
}

12
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()
}

2
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")
}

2
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)

Loading…
Cancel
Save