/// <summary> /// Fetches the page by index. /// </summary> /// <param name="pageIndex">An index of page</param> /// <returns>The fetched page</returns> public IPage FetchPage(long pageIndex) { CheckDisposed(); Lock(); try { CheckStorage(); if (_deferredUpdatesMode) { if (_recoveryFile.IsPageUpdated(pageIndex)) { return(new Page(this, pageIndex, _recoveryFile.GetUpdatedPageContent(pageIndex))); } if (_recoveryFile.DeletedPageIndexes.Contains(pageIndex)) { throw new PageMapException($"Page {pageIndex} is removed"); } } long pageAllocation = _pagemap.GetPageAllocation(pageIndex); if (pageAllocation == -1) { throw new PageMapException("Page is removed"); } CheckRemovalMarker(pageIndex); _storageStream.Seek(pageAllocation, SeekOrigin.Begin); var pageContent = new byte[_pageSize]; _storageStream.BlockingRead(pageContent); return(new Page(this, pageIndex, pageContent)); } finally { Unlock(); } }