From f614b5ad0faa88f794548581b80ad05f99e044ba Mon Sep 17 00:00:00 2001 From: Aaditya Sondhi Date: Wed, 23 Dec 2020 10:32:34 -0500 Subject: [PATCH] iterator: use i.pos in sampling 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 https://github.com/cockroachdb/pebble/pull/1031. --- iterator.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iterator.go b/iterator.go index 33b10a620b..3ff100aec5 100644 --- a/iterator.go +++ b/iterator.go @@ -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 {