Skip to content

Commit fd959dd

Browse files
committed
sstable: fix issue with comparing suffix during SeekPrefixGE lazy positioning
During a RangeDelIter the prefix passed might not be the same the prefix of the key therefore we need to split the prefix from the given key. Part of #2002 Previous #5256
1 parent 5e3f038 commit fd959dd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

sstable/reader_iter_single_lvl.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,8 @@ func (i *singleLevelIterator[I, PI, D, PD]) SeekPrefixGE(
863863
// table's max suffix, return a synthetic key with that max suffix.
864864
// We'll only actually perform the seek if the synthetic key rises to
865865
// the top of the iterator's heap, and the iterator is Nexted.
866-
if ok && maxSuffix != nil && i.cmp(key[len(prefix):], maxSuffix) < 0 {
866+
// During a RangeDelIter, the prefix passed and the prefix in the key might not be the same.
867+
if ok && maxSuffix != nil && i.reader.Comparer.ComparePointSuffixes(key[i.reader.Comparer.Split(key):], maxSuffix) < 0 {
867868
smallest := i.readEnv.InternalBounds.SmallestUserKey()
868869
smallest = i.reader.Comparer.Split.Prefix(smallest)
869870
largest := i.readEnv.InternalBounds.LargestUserKey()

sstable/reader_iter_two_lvl.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,8 @@ func (i *twoLevelIterator[I, PI, D, PD]) SeekPrefixGE(
466466
// table's max suffix, return a synthetic key with that max suffix.
467467
// We'll only actually perform the seek if the synthetic key rises to
468468
// the top of the iterator's heap, and the iterator is Nexted.
469-
if ok && maxSuffix != nil && i.secondLevel.cmp(key[len(prefix):], maxSuffix) < 0 {
469+
// During a RangeDelIter, the prefix passed and the prefix in the key might not be the same.
470+
if ok && maxSuffix != nil && i.secondLevel.reader.Comparer.ComparePointSuffixes(key[i.secondLevel.reader.Comparer.Split(key):], maxSuffix) < 0 {
470471
smallest := i.secondLevel.readEnv.InternalBounds.SmallestUserKey()
471472
smallest = i.secondLevel.reader.Comparer.Split.Prefix(smallest)
472473
largest := i.secondLevel.readEnv.InternalBounds.LargestUserKey()

0 commit comments

Comments
 (0)