public IPage Retrieve(ulong pageId, BrightstarProfiler profiler) { using (profiler.Step("BinaryFilePageStore.GetPage")) { // Look in the page cache IPage page = PageCache.Instance.Lookup(_partitionId, pageId) as BinaryFilePage; if (page != null) { profiler.Incr("PageCache Hit"); return(page); } // See if the page is queued for writing if (_backgroundPageWriter != null && _backgroundPageWriter.TryGetPage(pageId, out page)) { profiler.Incr("BackgroundWriter Queue Hit"); return(page); } // Not found in memory, so go to the disk profiler.Incr("PageCache Miss"); using (profiler.Step("Load Page")) { page = _modifiedPages.ContainsKey(pageId) ? new BinaryFilePage(_inputStream, pageId, _nominalPageSize, _writeTxnId, true) : new BinaryFilePage(_inputStream, pageId, _nominalPageSize, _readTxnId, false); PageCache.Instance.InsertOrUpdate(_partitionId, page); return(page); } } }
public IPage Retrieve(ulong pageId, BrightstarProfiler profiler) { using (profiler.Step("PageStore.Retrieve")) { if (!_readonly && pageId >= _newPageOffset) { var newPageRef = _newPages[(int)(pageId - _newPageOffset)]; if (newPageRef.IsAlive) { var newPage = newPageRef.Target as IPage; if (newPage != null) { return(newPage); } } } var page = PageCache.Instance.Lookup(_path, pageId) as IPage; if (page != null) { profiler.Incr("PageCache Hit"); return(page); } if (_backgroundPageWriter != null) { // See if the page is currently queued for background write if (_backgroundPageWriter.TryGetPage(pageId, out page)) { profiler.Incr("BackgroundWriter Queue Hit"); return(page); } } using (profiler.Step("Load Page")) { profiler.Incr("PageCache Miss"); using (profiler.Step("Create FilePage")) { page = new FilePage(_stream, pageId, _pageSize); if (_backgroundPageWriter != null) { _backgroundPageWriter.ResetTimestamp(pageId); } #if DEBUG_PAGESTORE Logging.LogDebug("Load {0} {1}", pageId, BitConverter.ToInt32(page.Data, 0)); #endif } using (profiler.Step("Add FilePage To Cache")) { PageCache.Instance.InsertOrUpdate(_path, page); } return(page); } } }