Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

Commit a383c57

Browse files
committed
SERVER-21563 fix RocksDB implementation of SortedDataInterface::Cursor to comply with changes to restore semantics
This applies the same change to RocksDB as made for other storage engines in 957f4ddf7cfb060.
1 parent 478a282 commit a383c57

File tree

1 file changed

+3
-31
lines changed

1 file changed

+3
-31
lines changed

src/rocks_index.cpp

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ namespace mongo {
149149
// unique vs non-unique key formats since both start with the key.
150150
_query.resetToKey(finalKey, _order, discriminator);
151151

152-
_locate(_query, RecordId());
152+
seekCursor(_query);
153153
updatePosition();
154154
return curr(parts);
155155
}
@@ -163,7 +163,7 @@ namespace mongo {
163163
const auto discriminator = _forward ? KeyString::kExclusiveBefore
164164
: KeyString::kExclusiveAfter;
165165
_query.resetToKey(key, _order, discriminator);
166-
_locate(_query, RecordId());
166+
seekCursor(_query);
167167
updatePosition();
168168
return curr(parts);
169169
}
@@ -186,7 +186,7 @@ namespace mongo {
186186
_currentSequenceNumber = ru->snapshot()->GetSequenceNumber();
187187

188188
if (!_savedEOF) {
189-
_lastMoveWasRestore = !_locate(_key, _loc);
189+
_lastMoveWasRestore = !seekCursor(_key);
190190
}
191191
}
192192
}
@@ -202,9 +202,6 @@ namespace mongo {
202202
}
203203

204204
protected:
205-
// Returns true if an exact match is found.
206-
virtual bool _locate(const KeyString& query, RecordId loc) = 0;
207-
208205
// Called after _key has been filled in. Must not throw WriteConflictException.
209206
virtual void updateLocAndTypeBits() = 0;
210207

@@ -361,11 +358,6 @@ namespace mongo {
361358
iterator();
362359
}
363360

364-
virtual bool _locate(const KeyString& query, RecordId loc) {
365-
// loc already encoded in _key
366-
return seekCursor(query);
367-
}
368-
369361
virtual void updateLocAndTypeBits() {
370362
_loc = KeyString::decodeRecordIdAtEnd(_key.getBuffer(), _key.getSize());
371363
BufReader br(_valueSlice().data(), _valueSlice().size());
@@ -399,26 +391,6 @@ namespace mongo {
399391
return curr(parts);
400392
}
401393

402-
virtual bool _locate(const KeyString& query, RecordId loc) {
403-
if (!seekCursor(query)) {
404-
// If didn't seek to exact key, start at beginning of wherever we ended up.
405-
return false;
406-
}
407-
dassert(!_eof);
408-
409-
// If we get here we need to look at the actual RecordId for this key and make sure
410-
// we are supposed to see it.
411-
BufReader br(_valueSlice().data(), _valueSlice().size());
412-
RecordId locInIndex = KeyString::decodeRecordId(&br);
413-
414-
if ((_forward && (locInIndex < loc)) || (!_forward && (locInIndex > loc))) {
415-
advanceCursor();
416-
return false;
417-
}
418-
419-
return loc == locInIndex;
420-
}
421-
422394
void updateLocAndTypeBits() {
423395
// We assume that cursors can only ever see unique indexes in their "pristine"
424396
// state,

0 commit comments

Comments
 (0)