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

Method readString

src/storage/overflow_file.cpp:19–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17namespace storage {
18
19std::string OverflowFileHandle::readString(TransactionType trxType, const string_t& str) const {
20 if (string_t::isShortString(str.len)) {
21 return str.getAsShortString();
22 }
23 PageCursor cursor;
24 TypeUtils::decodeOverflowPtr(str.overflowPtr, cursor.pageIdx, cursor.elemPosInPage);
25 std::string retVal;
26 retVal.reserve(str.len);
27 int32_t remainingLength = str.len;
28 while (remainingLength > 0) {
29 auto numBytesToReadInPage =
30 std::min(static_cast<uint32_t>(remainingLength), END_OF_PAGE - cursor.elemPosInPage);
31 auto startPosInSrc = retVal.size();
32 read(trxType, cursor.pageIdx, [&](uint8_t* frame) {
33 // Replace rather than append, since optimistic read may call the function multiple
34 // times
35 retVal.replace(startPosInSrc, numBytesToReadInPage,
36 std::string_view(reinterpret_cast<const char*>(frame) + cursor.elemPosInPage,
37 numBytesToReadInPage));
38 cursor.pageIdx = *reinterpret_cast<page_idx_t*>(frame + END_OF_PAGE);
39 });
40 remainingLength -= numBytesToReadInPage;
41 // After the first page we always start reading from the beginning of the page.
42 cursor.elemPosInPage = 0;
43 }
44 return retVal;
45}
46
47bool OverflowFileHandle::equals(TransactionType trxType, std::string_view keyToLookup,
48 const string_t& keyInEntry) const {

Callers 1

hashStoredMethod · 0.80

Calls 7

isShortStringFunction · 0.85
decodeOverflowPtrFunction · 0.85
readFunction · 0.85
getAsShortStringMethod · 0.80
replaceMethod · 0.80
reserveMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected