MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / equals

Method equals

src/storage/overflow_file.cpp:47–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47bool OverflowFileHandle::equals(TransactionType trxType, std::string_view keyToLookup,
48 const string_t& keyInEntry) const {
49 PageCursor cursor;
50 TypeUtils::decodeOverflowPtr(keyInEntry.overflowPtr, cursor.pageIdx, cursor.elemPosInPage);
51 auto lengthRead = 0u;
52 while (lengthRead < keyInEntry.len) {
53 auto numBytesToCheckInPage = std::min(static_cast<page_idx_t>(keyInEntry.len) - lengthRead,
54 END_OF_PAGE - cursor.elemPosInPage);
55 bool equal = true;
56 read(trxType, cursor.pageIdx, [&](auto* frame) {
57 equal = memcmp(keyToLookup.data() + lengthRead, frame + cursor.elemPosInPage,
58 numBytesToCheckInPage) == 0;
59 // Update the next page index
60 cursor.pageIdx = *reinterpret_cast<page_idx_t*>(frame + END_OF_PAGE);
61 });
62 if (!equal) {
63 return false;
64 }
65 cursor.elemPosInPage = 0;
66 lengthRead += numBytesToCheckInPage;
67 }
68 return true;
69}
70
71uint8_t* OverflowFileHandle::addANewPage(PageAllocator* pageAllocator) {
72 page_idx_t newPageIdx = overflowFile.getNewPageIdx(pageAllocator);

Callers

nothing calls this directly

Calls 3

decodeOverflowPtrFunction · 0.85
readFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected