mirror of https://github.com/prometheus/prometheus
postings: Fix bad test and revert changed logic
A bad test was introduced a couple of commits ago which also made changes to pass the bad test. Fixed the test and revert the changes. Signed-off-by: Goutham Veeramachaneni <cs14btech11014@iith.ac.in>pull/5805/head
parent
86929ed090
commit
f8a8b77976
25
postings.go
25
postings.go
|
@ -201,30 +201,7 @@ func (it *mergedPostings) Seek(id uint32) bool {
|
||||||
it.aok = it.a.Seek(id)
|
it.aok = it.a.Seek(id)
|
||||||
it.bok = it.b.Seek(id)
|
it.bok = it.b.Seek(id)
|
||||||
|
|
||||||
if !it.aok && !it.bok {
|
return it.Next()
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if !it.aok {
|
|
||||||
it.cur = it.b.At()
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if !it.bok {
|
|
||||||
it.cur = it.a.At()
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
acur, bcur := it.a.At(), it.b.At()
|
|
||||||
|
|
||||||
if acur < bcur {
|
|
||||||
it.cur = acur
|
|
||||||
} else {
|
|
||||||
it.cur = bcur
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (it *mergedPostings) Err() error {
|
func (it *mergedPostings) Err() error {
|
||||||
|
|
|
@ -219,9 +219,18 @@ func TestMerge(t *testing.T) {
|
||||||
|
|
||||||
require.Equal(t, c.success, p.Seek(c.seek))
|
require.Equal(t, c.success, p.Seek(c.seek))
|
||||||
|
|
||||||
res, err := expandPostings(p)
|
if c.success {
|
||||||
require.NoError(t, err)
|
// check the current element and then proceed to check the rest.
|
||||||
require.Equal(t, c.res, res)
|
i := 0
|
||||||
|
require.Equal(t, c.res[i], p.At())
|
||||||
|
|
||||||
|
for p.Next() {
|
||||||
|
i++
|
||||||
|
require.Equal(t, int(c.res[i]), int(p.At()))
|
||||||
|
}
|
||||||
|
|
||||||
|
require.Equal(t, len(c.res)-1, i)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue