MCPcopy Create free account
hub / github.com/apple/foundationdb / seek_impl

Method seek_impl

fdbserver/VersionedBTree.actor.cpp:7513–7545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7511 // If non-zero is returned then the cursor is valid and the return value is logically equivalent
7512 // to query.compare(cursor.get())
7513 ACTOR Future<int> seek_impl(BTreeCursor* self, RedwoodRecordRef query) {
7514 state RedwoodRecordRef internalPageQuery = query.withMaxPageID();
7515 self->path.resize(1);
7516 debug_printf("seek(%s) start cursor = %s\n", query.toString().c_str(), self->toString().c_str());
7517
7518 loop {
7519 auto& entry = self->path.back();
7520 if (entry.btPage()->isLeaf()) {
7521 int cmp = entry.cursor.seek(query);
7522 self->valid = entry.cursor.valid() && !entry.cursor.isErased();
7523 debug_printf("seek(%s) loop exit cmp=%d cursor=%s\n",
7524 query.toString().c_str(),
7525 cmp,
7526 self->toString().c_str());
7527 return self->valid ? cmp : 0;
7528 }
7529
7530 // Internal page, so seek to the branch where query must be
7531 // Currently, after a subtree deletion internal page boundaries are still strictly adhered
7532 // to and will be updated if anything is inserted into the cleared range, so if the seek fails
7533 // or it finds an entry with a null child page then query does not exist in the BTree.
7534 if (entry.cursor.seekLessThan(internalPageQuery) && entry.cursor.get().value.present()) {
7535 debug_printf(
7536 "seek(%s) loop seek success cursor=%s\n", query.toString().c_str(), self->toString().c_str());
7537 Future<Void> f = self->pushPage(entry.cursor);
7538 wait(f);
7539 } else {
7540 self->valid = false;
7541 debug_printf(
7542 "seek(%s) loop exit cmp=0 cursor=%s\n", query.toString().c_str(), self->toString().c_str());
7543 return 0;
7544 }
7545 }
7546 }
7547
7548 Future<int> seek(RedwoodRecordRef query) { return path.empty() ? 0 : seek_impl(this, query); }

Callers

nothing calls this directly

Calls 15

toStringMethod · 0.95
pushPageMethod · 0.95
withMaxPageIDMethod · 0.80
isErasedMethod · 0.80
getMethod · 0.65
resizeMethod · 0.45
c_strMethod · 0.45
toStringMethod · 0.45
backMethod · 0.45
isLeafMethod · 0.45
btPageMethod · 0.45
seekMethod · 0.45

Tested by

no test coverage detected