mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 13:44:05 -08:00
Reda correct label number, fix buffered iterator panic
This commit is contained in:
parent
d9ca4b47f5
commit
ce7f4106c2
|
@ -44,7 +44,7 @@ func FromData(e Encoding, d []byte) (Chunk, error) {
|
|||
switch e {
|
||||
case EncXOR:
|
||||
return &XORChunk{
|
||||
b: &bstream{count: 8},
|
||||
b: &bstream{count: 0, stream: d},
|
||||
num: binary.BigEndian.Uint16(d),
|
||||
}, nil
|
||||
}
|
||||
|
|
19
querier.go
19
querier.go
|
@ -2,6 +2,7 @@ package tsdb
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
|
@ -657,14 +658,17 @@ func (it *chunkSeriesIterator) Err() error {
|
|||
type BufferedSeriesIterator struct {
|
||||
it SeriesIterator
|
||||
buf *sampleRing
|
||||
|
||||
lastTime int64
|
||||
}
|
||||
|
||||
// NewBuffer returns a new iterator that buffers the values within the time range
|
||||
// of the current element and the duration of delta before.
|
||||
func NewBuffer(it SeriesIterator, delta int64) *BufferedSeriesIterator {
|
||||
return &BufferedSeriesIterator{
|
||||
it: it,
|
||||
buf: newSampleRing(delta, 16),
|
||||
it: it,
|
||||
buf: newSampleRing(delta, 16),
|
||||
lastTime: math.MinInt64,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -676,14 +680,13 @@ func (b *BufferedSeriesIterator) PeekBack() (t int64, v float64, ok bool) {
|
|||
|
||||
// Seek advances the iterator to the element at time t or greater.
|
||||
func (b *BufferedSeriesIterator) Seek(t int64) bool {
|
||||
tcur, _ := b.it.Values()
|
||||
|
||||
t0 := t - b.buf.delta
|
||||
|
||||
// If the delta would cause us to seek backwards, preserve the buffer
|
||||
// and just continue regular advancment while filling the buffer on the way.
|
||||
if t0 <= tcur {
|
||||
if t0 <= b.lastTime {
|
||||
for b.Next() {
|
||||
if tcur, _ = b.it.Values(); tcur >= t {
|
||||
if tcur, _ := b.it.Values(); tcur >= t {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -711,7 +714,9 @@ func (b *BufferedSeriesIterator) Next() bool {
|
|||
// Add current element to buffer before advancing.
|
||||
b.buf.add(b.it.Values())
|
||||
|
||||
return b.it.Next()
|
||||
ok := b.it.Next()
|
||||
b.lastTime, _ = b.Values()
|
||||
return ok
|
||||
}
|
||||
|
||||
// Values returns the current element of the iterator.
|
||||
|
|
|
@ -247,9 +247,9 @@ func (r *indexReader) Series(ref uint32, mint, maxt int64) (Series, error) {
|
|||
}
|
||||
|
||||
b := r.b[int(ref)+n:]
|
||||
offsets := make([]uint32, 0, k)
|
||||
offsets := make([]uint32, 0, 2*k)
|
||||
|
||||
for i := 0; i < int(k); i++ {
|
||||
for i := 0; i < 2*int(k); i++ {
|
||||
o, n := binary.Uvarint(b)
|
||||
if n < 1 {
|
||||
return nil, errors.Wrap(errInvalidSize, "symbol offset")
|
||||
|
|
Loading…
Reference in a new issue