| 3326 | } |
| 3327 | |
| 3328 | Future<Reference<ArenaPage>> readExtent(LogicalPageID pageID) override { |
| 3329 | debug_printf("DWALPager(%s) op=readExtent %s\n", filename.c_str(), toString(pageID).c_str()); |
| 3330 | PageCacheEntry* pCacheEntry = extentCache.getIfExists(pageID); |
| 3331 | auto& eventReasons = g_redwoodMetrics.level(nonBtreeLevel).metrics.events; |
| 3332 | if (pCacheEntry != nullptr) { |
| 3333 | eventReasons.addEventReason(PagerEvents::CacheLookup, PagerEventReasons::MetaData); |
| 3334 | debug_printf("DWALPager(%s) Cache Entry exists for %s\n", filename.c_str(), toString(pageID).c_str()); |
| 3335 | return pCacheEntry->readFuture; |
| 3336 | } |
| 3337 | eventReasons.addEventReason(PagerEvents::CacheLookup, PagerEventReasons::MetaData); |
| 3338 | |
| 3339 | LogicalPageID headPageID = header.remapQueue.headPageID; |
| 3340 | LogicalPageID tailPageID = header.remapQueue.tailPageID; |
| 3341 | int readSize = physicalExtentSize; |
| 3342 | bool headExt = false; |
| 3343 | bool tailExt = false; |
| 3344 | debug_printf("DWALPager(%s) #extentPages: %d, headPageID: %s, tailPageID: %s\n", |
| 3345 | filename.c_str(), |
| 3346 | pagesPerExtent, |
| 3347 | toString(headPageID).c_str(), |
| 3348 | toString(tailPageID).c_str()); |
| 3349 | |
| 3350 | if (headPageID >= pageID && ((headPageID - pageID) < pagesPerExtent)) |
| 3351 | headExt = true; |
| 3352 | if ((tailPageID - pageID) < pagesPerExtent) |
| 3353 | tailExt = true; |
| 3354 | if (headExt && tailExt) { |
| 3355 | readSize = (tailPageID - headPageID + 1) * physicalPageSize; |
| 3356 | } else if (headExt) { |
| 3357 | readSize = (pagesPerExtent - (headPageID - pageID)) * physicalPageSize; |
| 3358 | } else if (tailExt) { |
| 3359 | readSize = (tailPageID - pageID + 1) * physicalPageSize; |
| 3360 | } |
| 3361 | |
| 3362 | PageCacheEntry& cacheEntry = extentCache.get(pageID, 1); |
| 3363 | if (!cacheEntry.initialized()) { |
| 3364 | cacheEntry.writeFuture = Void(); |
| 3365 | cacheEntry.readFuture = |
| 3366 | forwardError(readPhysicalExtent(this, (PhysicalPageID)pageID, readSize), errorPromise); |
| 3367 | debug_printf("DWALPager(%s) Set the cacheEntry readFuture for page: %s\n", |
| 3368 | filename.c_str(), |
| 3369 | toString(pageID).c_str()); |
| 3370 | |
| 3371 | ++g_redwoodMetrics.metric.pagerCacheMiss; |
| 3372 | eventReasons.addEventReason(PagerEvents::CacheMiss, PagerEventReasons::MetaData); |
| 3373 | eventReasons.addEventReason(PagerEvents::CacheLookup, PagerEventReasons::MetaData); |
| 3374 | } else { |
| 3375 | ++g_redwoodMetrics.metric.pagerCacheHit; |
| 3376 | eventReasons.addEventReason(PagerEvents::CacheHit, PagerEventReasons::MetaData); |
| 3377 | eventReasons.addEventReason(PagerEvents::CacheLookup, PagerEventReasons::MetaData); |
| 3378 | } |
| 3379 | return cacheEntry.readFuture; |
| 3380 | } |
| 3381 | |
| 3382 | // Get snapshot as of the most recent committed version of the pager |
| 3383 | Reference<IPagerSnapshot> getReadSnapshot(Version v) override; |
nothing calls this directly
no test coverage detected