mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
Fix bug with Seek() and optimise bounding params.
Signed-off-by: Goutham Veeramachaneni <cs14btech11014@iith.ac.in>
This commit is contained in:
parent
d4cb579443
commit
9e1f34dae3
18
querier.go
18
querier.go
|
@ -657,10 +657,6 @@ func newChunkSeriesIterator(cs []*ChunkMeta, dranges intervals, mint, maxt int64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *chunkSeriesIterator) inBounds(t int64) bool {
|
|
||||||
return t >= it.mint && t <= it.maxt
|
|
||||||
}
|
|
||||||
|
|
||||||
func (it *chunkSeriesIterator) Seek(t int64) (ok bool) {
|
func (it *chunkSeriesIterator) Seek(t int64) (ok bool) {
|
||||||
if t > it.maxt {
|
if t > it.maxt {
|
||||||
return false
|
return false
|
||||||
|
@ -673,7 +669,9 @@ func (it *chunkSeriesIterator) Seek(t int64) (ok bool) {
|
||||||
|
|
||||||
// Only do binary search forward to stay in line with other iterators
|
// Only do binary search forward to stay in line with other iterators
|
||||||
// that can only move forward.
|
// that can only move forward.
|
||||||
x := sort.Search(len(it.chunks[it.i:]), func(i int) bool { return it.chunks[i].MinTime >= t })
|
x := sort.Search(len(it.chunks[it.i:]), func(i int) bool {
|
||||||
|
return it.chunks[it.i+i].MinTime >= t
|
||||||
|
})
|
||||||
x += it.i
|
x += it.i
|
||||||
|
|
||||||
// If the timestamp was not found, it might be in the last chunk.
|
// If the timestamp was not found, it might be in the last chunk.
|
||||||
|
@ -708,9 +706,15 @@ func (it *chunkSeriesIterator) At() (t int64, v float64) {
|
||||||
func (it *chunkSeriesIterator) Next() bool {
|
func (it *chunkSeriesIterator) Next() bool {
|
||||||
for it.cur.Next() {
|
for it.cur.Next() {
|
||||||
t, _ := it.cur.At()
|
t, _ := it.cur.At()
|
||||||
if it.inBounds(t) {
|
if t < it.mint {
|
||||||
return true
|
return it.Seek(it.mint)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if t > it.maxt {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := it.cur.Err(); err != nil {
|
if err := it.cur.Err(); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue