| 83 | } |
| 84 | |
| 85 | void DiskArrayInternal::get(uint64_t idx, const Transaction* transaction, |
| 86 | std::span<std::byte> val) { |
| 87 | std::shared_lock sLck{diskArraySharedMtx}; |
| 88 | DASSERT(checkOutOfBoundAccess(transaction->getType(), idx)); |
| 89 | auto apCursor = getAPIdxAndOffsetInAP(storageInfo, idx); |
| 90 | page_idx_t apPageIdx = getAPPageIdxNoLock(apCursor.pageIdx, transaction->getType()); |
| 91 | if (transaction->getType() != TransactionType::CHECKPOINT || !hasTransactionalUpdates || |
| 92 | apPageIdx > lastPageOnDisk || |
| 93 | !shadowFile->hasShadowPage(fileHandle.getFileIndex(), apPageIdx)) { |
| 94 | fileHandle.optimisticReadPage(apPageIdx, [&](const uint8_t* frame) -> void { |
| 95 | memcpy(val.data(), frame + apCursor.elemPosInPage, val.size()); |
| 96 | }); |
| 97 | } else { |
| 98 | ShadowUtils::readShadowVersionOfPage(fileHandle, apPageIdx, *shadowFile, |
| 99 | [&val, &apCursor](const uint8_t* frame) -> void { |
| 100 | memcpy(val.data(), frame + apCursor.elemPosInPage, val.size()); |
| 101 | }); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | void DiskArrayInternal::updatePage(uint64_t pageIdx, bool isNewPage, |
| 106 | std::function<void(uint8_t*)> updateOp) { |