Skip to content

Commit

Permalink
iterator: use i.pos in sampling
Browse files Browse the repository at this point in the history
Previously, this used `mergingiter.dir` which does not follow the same
`iterPos` type as `iterator.pos`. This fixes it to use `iterator.pos`.
Follow up PR from cockroachdb#1031.
  • Loading branch information
aadityasondhi committed Dec 23, 2020
1 parent 9f77cf3 commit f614b5a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ func (i *Iterator) sampleRead() {
// be tested in benchmarks.
if file := li.files.Current(); file != nil {
var containsKey bool
if mi.dir == int(iterPosNext) || mi.dir == int(iterPosCurForward) {
if i.pos == iterPosNext || i.pos == iterPosCurForward {
containsKey = i.cmp(file.Smallest.UserKey, i.key) <= 0
} else if mi.dir == int(iterPosPrev) || mi.dir == int(iterPosCurReverse) {
} else if i.pos == iterPosPrev || i.pos == iterPosCurReverse {
containsKey = i.cmp(file.Largest.UserKey, i.key) >= 0
}
if containsKey {
Expand Down

0 comments on commit f614b5a

Please sign in to comment.