Merge pull request #11643 from codesome/histochunkreset

Fix reset of a histogram chunk iterator
This commit is contained in:
Ganesh Vernekar 2022-11-30 21:59:40 +05:30 committed by GitHub
commit 0e4cbd0f4c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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) { 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. // We skip that for actual samples.
it.br = newBReader(b[2:]) it.br = newBReader(b[3:])
it.numTotal = binary.BigEndian.Uint16(b) it.numTotal = binary.BigEndian.Uint16(b)
it.numRead = 0 it.numRead = 0

View file

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