Fix reset of a histogram chunk iterator

Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
This commit is contained in:
Ganesh Vernekar 2022-11-30 17:49:33 +05:30
parent 414d31aee6
commit b8b0d45d69
No known key found for this signature in database
GPG key ID: F056451B52F1DC34
2 changed files with 10 additions and 10 deletions

View file

@ -624,9 +624,9 @@ func (it *histogramIterator) Err() error {
}
func (it *histogramIterator) Reset(b []byte) {
// The first 2 bytes contain chunk headers.
// The first 3 bytes contain chunk headers.
// We skip that for actual samples.
it.br = newBReader(b[2:])
it.br = newBReader(b[3:])
it.numTotal = binary.BigEndian.Uint16(b)
it.numRead = 0

View file

@ -84,14 +84,14 @@ func TestHistogramChunkSameBuckets(t *testing.T) {
require.Equal(t, exp, act)
// 2. Expand second iterator while reusing first one.
// it2 := c.Iterator(it1)
// var res2 []pair
// for it2.Next() {
// ts, v := it2.At()
// res2 = append(res2, pair{t: ts, v: v})
// }
// require.NoError(t, it2.Err())
// require.Equal(t, exp, res2)
it2 := c.Iterator(it)
var res2 []res
for it2.Next() == ValHistogram {
ts, h := it2.AtHistogram()
res2 = append(res2, res{t: ts, h: h})
}
require.NoError(t, it2.Err())
require.Equal(t, exp, res2)
// 3. Test iterator Seek.
// mid := len(exp) / 2