#include <VersionedSegment.h>
Inheritance diagram for VersionedSegment:
Public Types | |
enum | AllocationOrder { RANDOM_ALLOCATION, ASCENDING_ALLOCATION, CONSECUTIVE_ALLOCATION, LINEAR_ALLOCATION } |
Enumeration of the possible orderings of PageIds returned from allocatePageId. More... | |
Public Member Functions | |
virtual | ~VersionedSegment () |
void | recover (SharedSegment pDelegatingSegment, PageId firstLogPageId, SegVersionNum versionNumber=MAXU) |
Recovers to a specific version from the log. | |
void | recover (SharedSegment pDelegatingSegment, PageId firstLogPageId, SegVersionNum versionNumber, PseudoUuid const &onlineUuid) |
Recovers to a specific version from the log and resets the online uuid. | |
void | prepareOnlineRecovery () |
Prepares for "online" recovery, meaning a revert back to the last checkpointed version. | |
PageId | getRecoveryPageId () const |
| |
PageId | getOnlineRecoveryPageId () const |
| |
SegVersionNum | getPageVersion (CachePage &page) |
Gets the version number of a locked page. | |
SegVersionNum | getVersionNumber () const |
| |
SharedSegment | getLogSegment () const |
| |
void | deallocateCheckpointedLog (CheckpointType checkpointType) |
Deallocates any old log pages which have become irrelevant after a checkpoint. | |
virtual void | deallocatePageRange (PageId startPageId, PageId endPageId) |
Deallocates a range of pages allocated from this segment. | |
virtual void | delegatedCheckpoint (Segment &delegatingSegment, CheckpointType checkpointType) |
Helper for DelegatingSegment. | |
virtual void | notifyPageDirty (CachePage &page, bool bDataValid) |
Receives notification from CacheImpl the first time a page becomes dirty after it has been mapped (but before the contents have changed). | |
virtual bool | canFlushPage (CachePage &page) |
Informs CacheImpl whether a dirty page can safely be flushed to disk. | |
SharedSegment const & | getDelegateSegment () const |
virtual BlockNum | getAllocatedSizeInPages () |
| |
virtual BlockNum | getNumPagesOccupiedHighWater () |
Returns the max number of pages occupied by this segment instance. | |
virtual BlockNum | getNumPagesExtended () |
| |
virtual PageId | getPageSuccessor (PageId pageId) |
Determines the successor of a given PageId. | |
virtual void | setPageSuccessor (PageId pageId, PageId successorId) |
Sets the successor of a given PageId. | |
virtual BlockId | translatePageId (PageId) |
Maps from a PageId in this segment to a BlockId. | |
virtual PageId | translateBlockId (BlockId) |
Maps from a BlockId to a PageId in this segment. | |
virtual PageId | allocatePageId (PageOwnerId ownerId=ANON_PAGE_OWNER_ID) |
Allocates a page without locking it into memory. | |
virtual bool | ensureAllocatedSize (BlockNum nPages) |
Allocates pages as needed to make getAllocatedSizeInPages() meet a lower bound. | |
virtual bool | isPageIdAllocated (PageId pageId) |
Tests whether a PageId is allocated. | |
virtual AllocationOrder | getAllocationOrder () const |
| |
virtual PageId | updatePage (PageId pageId, bool needsTranslation=false) |
Determines whether a page can be updated in-place, and if so, prepares the page for update. | |
virtual void | notifyPageMap (CachePage &page) |
Receives notification from CacheImpl as soon as a page is mapped, before any I/O is initiated to retrieve the page contents. | |
virtual void | notifyPageUnmap (CachePage &page) |
Receives notification from CacheImpl just before a page is unmapped. | |
virtual void | notifyAfterPageRead (CachePage &page) |
Receives notification from CacheImpl after a page read completes. | |
virtual void | notifyBeforePageFlush (CachePage &page) |
Receives notification from CacheImpl just before a dirty page is flushed to disk. | |
virtual void | notifyAfterPageFlush (CachePage &page) |
Receives notification from CacheImpl when a page flush completes successfully. | |
SharedCache | getCache () const |
| |
uint | getFullPageSize () const |
| |
uint | getUsablePageSize () const |
| |
virtual void | initForUse () |
Performs additional initialization required on the segment after it has been properly formatted. | |
SharedSegment | getTracingSegment () |
| |
void | setTracingSegment (WeakSegment pTracingSegmentInit) |
Sets the tracing segment associated with this segment. | |
void | checkpoint (CheckpointType checkpointType=CHECKPOINT_FLUSH_ALL) |
Checkpoints this segment. | |
virtual MappedPageListener * | getMappedPageListener (BlockId blockId) |
Returns the mapped page listener corresponding to a page. | |
virtual bool | isWriteVersioned () |
| |
virtual MappedPageListener * | getTracingListener () |
Retrieves the tracing wrapper corresponding to this listener if tracing is turned on. | |
virtual MappedPageListener * | notifyAfterPageCheckpointFlush (CachePage &page) |
Receives notification that a page has been flushed during a checkpoint. | |
bool | isClosed () const |
| |
void | close () |
Closes this object, releasing any unallocated resources. | |
Static Public Member Functions | |
static PageId | getLinearPageId (BlockNum iPage) |
Constructs a linear PageId based on a linear page number. | |
static BlockNum | getLinearBlockNum (PageId pageId) |
Obtains the linear page number from a linear PageId. | |
Protected Types | |
typedef std::hash_map< PageId, PageId > | PageMap |
typedef PageMap::const_iterator | PageMapConstIter |
Protected Member Functions | |
void | setUsablePageSize (uint) |
PConstBuffer | getReadableFooter (CachePage &page) |
PBuffer | getWritableFooter (CachePage &page) |
PageId | getLinearPageSuccessor (PageId pageId) |
An implementation of getPageSuccessor suitable for LINEAR_ALLOCATION. | |
void | setLinearPageSuccessor (PageId pageId, PageId successorId) |
An implementation of setPageSuccessor suitable for LINEAR_ALLOCATION. | |
bool | isLinearPageIdAllocated (PageId pageId) |
An implementation of isPageIdAllocated suitable for LINEAR_ALLOCATION when deallocation holes are disallowed. | |
Protected Attributes | |
SharedCache | pCache |
Cache managing pages of this segment. | |
WeakSegment | pTracingSegment |
The tracing segment associated with this segment, if tracing is turned on. | |
bool | needsClose |
Private Member Functions | |
VersionedSegment (SharedSegment dataSegment, SharedSegment logSegment, PseudoUuid const &onlineUuid, SegVersionNum versionNumber) | |
uint64_t | computeChecksum (void const *pPageData) |
Private Attributes | |
bool | inRecovery |
PseudoUuid | onlineUuid |
SegVersionNum | versionNumber |
PageId | oldestLogPageId |
PageId | newestLogPageId |
PageId | lastCheckpointLogPageId |
StrictMutex | mutex |
SharedSegment | logSegment |
WALSegment * | pWALSegment |
FuzzyCheckpointSet | fuzzyCheckpointSet |
boost::crc_32_type | crcComputer |
PageMap | dataToLogMap |
Friends | |
class | SegmentFactory |
See the design docs for more detail.
Definition at line 44 of file VersionedSegment.h.
typedef std::hash_map<PageId,PageId> Segment::PageMap [protected, inherited] |
typedef PageMap::const_iterator Segment::PageMapConstIter [protected, inherited] |
enum Segment::AllocationOrder [inherited] |
Enumeration of the possible orderings of PageIds returned from allocatePageId.
The enumeration is from weakest to strongest ordering, and should not be changed.
Definition at line 105 of file Segment.h.
00105 { 00109 RANDOM_ALLOCATION, 00110 00115 ASCENDING_ALLOCATION, 00116 00121 CONSECUTIVE_ALLOCATION, 00122 00128 LINEAR_ALLOCATION 00129 };
VersionedSegment::VersionedSegment | ( | SharedSegment | dataSegment, | |
SharedSegment | logSegment, | |||
PseudoUuid const & | onlineUuid, | |||
SegVersionNum | versionNumber | |||
) | [explicit, private] |
Definition at line 68 of file VersionedSegment.cpp.
References Segment::getUsablePageSize(), inRecovery, lastCheckpointLogPageId, logSegment, newestLogPageId, NULL_PAGE_ID, oldestLogPageId, onlineUuid, pWALSegment, Segment::setUsablePageSize(), and versionNumber.
00073 : DelegatingSegment(dataSegmentInit) 00074 { 00075 logSegment = logSegmentInit; 00076 pWALSegment = SegmentFactory::dynamicCast<WALSegment *>(logSegment); 00077 assert(pWALSegment); 00078 00079 setUsablePageSize( 00080 DelegatingSegment::getUsablePageSize() 00081 - sizeof(VersionedPageFooter)); 00082 00083 onlineUuid = onlineUuidInit; 00084 versionNumber = versionNumberInit; 00085 oldestLogPageId = NULL_PAGE_ID; 00086 newestLogPageId = NULL_PAGE_ID; 00087 lastCheckpointLogPageId = NULL_PAGE_ID; 00088 inRecovery = false; 00089 }
VersionedSegment::~VersionedSegment | ( | ) | [virtual] |
Definition at line 91 of file VersionedSegment.cpp.
References dataToLogMap, and pWALSegment.
00092 { 00093 pWALSegment = NULL; 00094 assert(dataToLogMap.empty()); 00095 }
SegVersionNum VersionedSegment::computeChecksum | ( | void const * | pPageData | ) | [private] |
Definition at line 231 of file VersionedSegment.cpp.
References crcComputer, and Segment::getUsablePageSize().
Referenced by notifyPageDirty(), and recover().
00232 { 00233 crcComputer.reset(); 00234 crcComputer.process_bytes(pPageData,getUsablePageSize()); 00235 return crcComputer.checksum(); 00236 }
void VersionedSegment::recover | ( | SharedSegment | pDelegatingSegment, | |
PageId | firstLogPageId, | |||
SegVersionNum | versionNumber = MAXU | |||
) |
Recovers to a specific version from the log.
pDelegatingSegment | segment from which pages to recover originate | |
firstLogPageId | starting PageId in log segment | |
versionNumber | version number to recover to, or MAXU to use current version number |
Definition at line 284 of file VersionedSegment.cpp.
References VersionedPageFooter::checksum, computeChecksum(), VersionedPageFooter::dataPageId, dataToLogMap, Segment::getFullPageSize(), WALSegment::getMinDirtyPageId(), SegPageLock::getPage(), Segment::getReadableFooter(), CachePage::getWritableData(), inRecovery, isMAXU(), SegPageLock::lockExclusive(), logSegment, NULL_PAGE_ID, onlineUuid, VersionedPageFooter::onlineUuid, Segment::pCache, pWALSegment, VersionedPageFooter::versionNumber, and versionNumber.
Referenced by recover(), Database::recoverPhysical(), Database::restoreFromBackup(), and VersionedSegmentTest::testRecovery().
00288 { 00289 assert(dataToLogMap.empty()); 00290 assert(pWALSegment->getMinDirtyPageId() == NULL_PAGE_ID); 00291 00292 inRecovery = true; 00293 00294 if (!isMAXU(versionNumberInit)) { 00295 versionNumber = versionNumberInit; 00296 } 00297 00298 // The conventional thing to do is to scan forward to find the log end, and 00299 // then recover backwards, guaranteeing that earlier shadows replace later 00300 // shadows (in case of a fuzzy checkpoint). Instead, we keep track of 00301 // which pages have already been recovered and skip them if they are 00302 // encountered again. 00303 std::hash_set<PageId> recoveredPageSet; 00304 00305 // TODO: use PageIters 00306 00307 // TODO: what about when one shadow log stores pages for multiple 00308 // VersionedSegments? 00309 SegmentAccessor logSegmentAccessor(logSegment,pCache); 00310 SegmentAccessor dataSegmentAccessor(pDelegatingSegment,pCache); 00311 for (; firstLogPageId != NULL_PAGE_ID; 00312 firstLogPageId = logSegment->getPageSuccessor(firstLogPageId)) 00313 { 00314 SegPageLock logPageLock(logSegmentAccessor); 00315 logPageLock.lockShared(firstLogPageId); 00316 if (!logPageLock.getPage().isDataValid()) { 00317 break; 00318 } 00319 PConstBuffer pLogPageBuffer = logPageLock.getPage().getReadableData(); 00320 VersionedPageFooter const *pLogFooter = 00321 reinterpret_cast<VersionedPageFooter const *>( 00322 getReadableFooter(logPageLock.getPage())); 00323 if (pLogFooter->checksum != computeChecksum(pLogPageBuffer)) { 00324 break; 00325 } 00326 if (pLogFooter->onlineUuid != onlineUuid) { 00327 break; 00328 } 00329 assert(pLogFooter->versionNumber < (versionNumber + 2)); 00330 if (pLogFooter->versionNumber < versionNumber) { 00331 continue; 00332 } 00333 if (recoveredPageSet.find(pLogFooter->dataPageId) 00334 != recoveredPageSet.end()) 00335 { 00336 assert(pLogFooter->versionNumber > versionNumber); 00337 continue; 00338 } 00339 00340 SegPageLock dataPageLock(dataSegmentAccessor); 00341 dataPageLock.lockExclusive(pLogFooter->dataPageId); 00342 memcpy( 00343 dataPageLock.getPage().getWritableData(), 00344 pLogPageBuffer, 00345 getFullPageSize()); 00346 recoveredPageSet.insert(pLogFooter->dataPageId); 00347 } 00348 00349 inRecovery = false; 00350 }
void VersionedSegment::recover | ( | SharedSegment | pDelegatingSegment, | |
PageId | firstLogPageId, | |||
SegVersionNum | versionNumber, | |||
PseudoUuid const & | onlineUuid | |||
) |
Recovers to a specific version from the log and resets the online uuid.
pDelegatingSegment | segment from which pages to recover originate | |
firstLogPageId | starting PageId in log segment | |
versionNumber | version number to recover to | |
onlineUuid | online uuid corresponding to the recovered instance |
Definition at line 274 of file VersionedSegment.cpp.
References onlineUuid, and recover().
00279 { 00280 onlineUuid = onlineUuidInit; 00281 recover(pDelegatingSegment, firstLogPageId, versionNumberInit); 00282 }
void VersionedSegment::prepareOnlineRecovery | ( | ) |
Prepares for "online" recovery, meaning a revert back to the last checkpointed version.
Call getOnlineRecoveryPageId() first.
Definition at line 262 of file VersionedSegment.cpp.
References CHECKPOINT_FLUSH_ALL, dataToLogMap, logSegment, mutex, NULL_PAGE_ID, and oldestLogPageId.
Referenced by Database::recoverOnline().
00263 { 00264 // For simplicity, force entire log out to disk first, but don't discard 00265 // it, since we're about to read it during recovery. 00266 logSegment->checkpoint(CHECKPOINT_FLUSH_ALL); 00267 00268 StrictMutexGuard mutexGuard(mutex); 00269 00270 dataToLogMap.clear(); 00271 oldestLogPageId = NULL_PAGE_ID; 00272 }
PageId VersionedSegment::getRecoveryPageId | ( | ) | const |
Definition at line 375 of file VersionedSegment.cpp.
References FIRST_LINEAR_PAGE_ID, NULL_PAGE_ID, and oldestLogPageId.
Referenced by Database::checkpointImpl().
00376 { 00377 if (oldestLogPageId == NULL_PAGE_ID) { 00378 // if we've truncated the log, then recovery should start from the 00379 // first new shadow page after a crash 00380 return FIRST_LINEAR_PAGE_ID; 00381 } else { 00382 return oldestLogPageId; 00383 } 00384 }
PageId VersionedSegment::getOnlineRecoveryPageId | ( | ) | const |
Definition at line 370 of file VersionedSegment.cpp.
References oldestLogPageId.
Referenced by Database::checkpointImpl(), and Database::recoverOnline().
00371 { 00372 return oldestLogPageId; 00373 }
SegVersionNum VersionedSegment::getPageVersion | ( | CachePage & | page | ) |
Gets the version number of a locked page.
page | the locked page |
Definition at line 352 of file VersionedSegment.cpp.
References Segment::getReadableFooter(), and VersionedPageFooter::versionNumber.
Referenced by VersionedSegmentTest::verifyPage().
00353 { 00354 VersionedPageFooter const *pFooter = 00355 reinterpret_cast<VersionedPageFooter const *>( 00356 getReadableFooter(page)); 00357 return pFooter->versionNumber; 00358 }
SegVersionNum VersionedSegment::getVersionNumber | ( | ) | const |
Definition at line 360 of file VersionedSegment.cpp.
References versionNumber.
Referenced by Database::checkpointImpl(), Database::recoverPhysical(), and VersionedSegmentTest::testCheckpoint().
00361 { 00362 return versionNumber; 00363 }
SharedSegment VersionedSegment::getLogSegment | ( | ) | const |
Definition at line 365 of file VersionedSegment.cpp.
References logSegment.
00366 { 00367 return logSegment; 00368 }
void VersionedSegment::deallocateCheckpointedLog | ( | CheckpointType | checkpointType | ) |
Deallocates any old log pages which have become irrelevant after a checkpoint.
Divorced from the checkpoint operation itself to make possible atomicity as part of compound checkpoint sequences.
checkpointType | the CheckpointType passed to the last checkpoint() call |
Definition at line 135 of file VersionedSegment.cpp.
References CHECKPOINT_FLUSH_FUZZY, lastCheckpointLogPageId, logSegment, newestLogPageId, and NULL_PAGE_ID.
Referenced by Database::checkpointImpl(), Database::recoverPhysical(), and VersionedSegmentTest::testCheckpoint().
00136 { 00137 if (checkpointType == CHECKPOINT_FLUSH_FUZZY) { 00138 if (lastCheckpointLogPageId != NULL_PAGE_ID) { 00139 logSegment->deallocatePageRange( 00140 NULL_PAGE_ID,lastCheckpointLogPageId); 00141 if (lastCheckpointLogPageId == newestLogPageId) { 00142 newestLogPageId = NULL_PAGE_ID; 00143 } 00144 } 00145 } else { 00146 logSegment->deallocatePageRange(NULL_PAGE_ID,NULL_PAGE_ID); 00147 newestLogPageId = NULL_PAGE_ID; 00148 } 00149 lastCheckpointLogPageId = newestLogPageId; 00150 }
void VersionedSegment::deallocatePageRange | ( | PageId | startPageId, | |
PageId | endPageId | |||
) | [virtual] |
Deallocates a range of pages allocated from this segment.
Some segment implementations may impose restrictions on the range (e.g. individual pages only, entire segment truncation only, start-ranges, or end-ranges). The interpretation of the range may also vary by segment (e.g. for a LINEAR_ALLOCATION segment, it's a simple linear PageId range, while for a RANDOM_ALLOCATION segment, successors could be used).
Depending on the circumstances, it may be the responsibility of the segment to discard the corresponding blocks from the cache. The details vary by segment implementation.
startPageId | inclusive start of PageId range to deallocate, or default NULL_PAGE_ID for beginning of segment | |
endPageId | inclusive end of PageId range to deallocate, or default NULL_PAGE_ID for end of segment |
Reimplemented from DelegatingSegment.
Definition at line 152 of file VersionedSegment.cpp.
References DelegatingSegment::deallocatePageRange(), and NULL_PAGE_ID.
00154 { 00155 // TODO: support real truncations? 00156 assert(startPageId == endPageId); 00157 assert(startPageId != NULL_PAGE_ID); 00158 00159 // TODO: need to log copy of deallocated page 00160 DelegatingSegment::deallocatePageRange(startPageId,endPageId); 00161 }
void VersionedSegment::delegatedCheckpoint | ( | Segment & | delegatingSegment, | |
CheckpointType | checkpointType | |||
) | [virtual] |
Helper for DelegatingSegment.
delegatingSegment | the Segment on which checkpoint was originally called | |
checkpointType | type of checkpoint requested |
Reimplemented from DelegatingSegment.
Definition at line 99 of file VersionedSegment.cpp.
References CHECKPOINT_DISCARD, CHECKPOINT_FLUSH_FUZZY, FuzzyCheckpointSet::clear(), dataToLogMap, DelegatingSegment::delegatedCheckpoint(), FuzzyCheckpointSet::finishCheckpoint(), fuzzyCheckpointSet, WALSegment::getMinDirtyPageId(), lastCheckpointLogPageId, logSegment, mutex, NULL_PAGE_ID, oldestLogPageId, Segment::pCache, pWALSegment, FuzzyCheckpointSet::setDelegatePagePredicate(), and versionNumber.
00101 { 00102 if (checkpointType != CHECKPOINT_DISCARD) { 00103 // TODO: for a fuzzy checkpoint, only need to force the log pages for 00104 // data pages that are going to be flushed 00105 logSegment->checkpoint(checkpointType); 00106 assert(pWALSegment->getMinDirtyPageId() == NULL_PAGE_ID); 00107 } 00108 if (checkpointType == CHECKPOINT_FLUSH_FUZZY) { 00109 MappedPageListenerPredicate pagePredicate(delegatingSegment); 00110 fuzzyCheckpointSet.setDelegatePagePredicate(pagePredicate); 00111 pCache->checkpointPages(fuzzyCheckpointSet,checkpointType); 00112 fuzzyCheckpointSet.finishCheckpoint(); 00113 if (lastCheckpointLogPageId != NULL_PAGE_ID) { 00114 oldestLogPageId = logSegment->getPageSuccessor( 00115 lastCheckpointLogPageId); 00116 } else { 00117 oldestLogPageId = NULL_PAGE_ID; 00118 } 00119 } else { 00120 DelegatingSegment::delegatedCheckpoint( 00121 delegatingSegment,checkpointType); 00122 fuzzyCheckpointSet.clear(); 00123 oldestLogPageId = NULL_PAGE_ID; 00124 } 00125 00126 if (checkpointType == CHECKPOINT_DISCARD) { 00127 logSegment->checkpoint(checkpointType); 00128 } 00129 00130 StrictMutexGuard mutexGuard(mutex); 00131 ++versionNumber; 00132 dataToLogMap.clear(); 00133 }
void VersionedSegment::notifyPageDirty | ( | CachePage & | page, | |
bool | bDataValid | |||
) | [virtual] |
Receives notification from CacheImpl the first time a page becomes dirty after it has been mapped (but before the contents have changed).
Allows some logging action to be taken; for example, making a backup copy of the unmodified page contents. Note that when called for a newly allocated page, the page contents are invalid. Because it is implied that the calling thread already has an exclusive lock on the page, no cache locks are held when called.
page | the page being modified | |
bDataValid | if true, the page data was already valid; if false, the data was invalid, but has now been marked valid since it's about to be written |
Reimplemented from DelegatingSegment.
Definition at line 163 of file VersionedSegment.cpp.
References SegPageLock::allocatePage(), VersionedPageFooter::checksum, computeChecksum(), VersionedPageFooter::dataPageId, dataToLogMap, PseudoUuid::generateInvalid(), CachePage::getBlockId(), SegPageLock::getPage(), CachePage::getReadableData(), Segment::getUsablePageSize(), CachePage::getWritableData(), Segment::getWritableFooter(), inRecovery, logSegment, mutex, newestLogPageId, DelegatingSegment::notifyPageDirty(), NULL_PAGE_ID, oldestLogPageId, onlineUuid, VersionedPageFooter::onlineUuid, Segment::pCache, DelegatingSegment::translateBlockId(), versionNumber, and VersionedPageFooter::versionNumber.
00164 { 00165 DelegatingSegment::notifyPageDirty(page,bDataValid); 00166 00167 if (inRecovery) { 00168 // REVIEW jvs 8-Aug-2006: It would be nice to assert instead. But we 00169 // can get here in online recovery when we replace pages which were 00170 // abandoned but not discarded. 00171 return; 00172 } 00173 00174 VersionedPageFooter *pDataFooter = reinterpret_cast<VersionedPageFooter *>( 00175 getWritableFooter(page)); 00176 00177 if (!bDataValid) { 00178 // newly allocated page 00179 pDataFooter->dataPageId = NULL_PAGE_ID; 00180 pDataFooter->onlineUuid.generateInvalid(); 00181 pDataFooter->versionNumber = versionNumber; 00182 pDataFooter->checksum = 0; 00183 return; 00184 } 00185 00186 assert(pDataFooter->versionNumber <= versionNumber); 00187 if (pDataFooter->versionNumber == versionNumber) { 00188 // already logged this page 00189 return; 00190 } 00191 00192 // write before-image to the log 00193 SegmentAccessor logSegmentAccessor(logSegment,pCache); 00194 SegPageLock logPageLock(logSegmentAccessor); 00195 PageId logPageId = logPageLock.allocatePage(); 00196 00197 // REVIEW: what if there's other footer information to copy? 00198 00199 // TODO: remember logPageId in version map 00200 PBuffer pLogPageBuffer = logPageLock.getPage().getWritableData(); 00201 memcpy( 00202 pLogPageBuffer, 00203 page.getReadableData(), 00204 getUsablePageSize()); 00205 VersionedPageFooter *pLogFooter = reinterpret_cast<VersionedPageFooter *>( 00206 getWritableFooter(logPageLock.getPage())); 00207 pLogFooter->versionNumber = versionNumber - 1; 00208 pLogFooter->onlineUuid = onlineUuid; 00209 PageId dataPageId = DelegatingSegment::translateBlockId( 00210 page.getBlockId()); 00211 pLogFooter->dataPageId = dataPageId; 00212 00213 pLogFooter->checksum = computeChecksum(pLogPageBuffer); 00214 00215 // record new version number for soon-to-be-modified data page 00216 pDataFooter->versionNumber = versionNumber; 00217 00218 // tell the cache that the log page is a good candidate for victimization 00219 pCache->nicePage(logPageLock.getPage()); 00220 00221 StrictMutexGuard mutexGuard(mutex); 00222 dataToLogMap[dataPageId] = logPageId; 00223 if ((newestLogPageId == NULL_PAGE_ID) || (logPageId > newestLogPageId)) { 00224 newestLogPageId = logPageId; 00225 } 00226 if ((oldestLogPageId == NULL_PAGE_ID) || (logPageId < oldestLogPageId)) { 00227 oldestLogPageId = logPageId; 00228 } 00229 }
bool VersionedSegment::canFlushPage | ( | CachePage & | page | ) | [virtual] |
Informs CacheImpl whether a dirty page can safely be flushed to disk.
Called with the page mutex held, so the implementation must take care to avoid deadlock.
page | the page to be flushed |
Reimplemented from DelegatingSegment.
Definition at line 238 of file VersionedSegment.cpp.
References DelegatingSegment::canFlushPage(), dataToLogMap, CachePage::getBlockId(), WALSegment::getMinDirtyPageId(), mutex, NULL_PAGE_ID, pWALSegment, and DelegatingSegment::translateBlockId().
00239 { 00240 // this implements the WAL constraint 00241 00242 PageId minLogPageId = pWALSegment->getMinDirtyPageId(); 00243 if (minLogPageId == NULL_PAGE_ID) { 00244 return DelegatingSegment::canFlushPage(page); 00245 } 00246 00247 StrictMutexGuard mutexGuard(mutex); 00248 PageId dataPageId = DelegatingSegment::translateBlockId( 00249 page.getBlockId()); 00250 PageMapConstIter pLogPageId = dataToLogMap.find(dataPageId); 00251 if (pLogPageId == dataToLogMap.end()) { 00252 // newly allocated page 00253 return DelegatingSegment::canFlushPage(page); 00254 } 00255 PageId logPageId = pLogPageId->second; 00256 if (logPageId >= minLogPageId) { 00257 return false; 00258 } 00259 return DelegatingSegment::canFlushPage(page); 00260 }
SharedSegment const& DelegatingSegment::getDelegateSegment | ( | ) | const [inline, inherited] |
Definition at line 53 of file DelegatingSegment.h.
Referenced by SegmentFactory::dynamicCast(), TracingSegment::getMappedPageListener(), TracingSegment::isWriteVersioned(), and TracingSegment::notifyAfterPageCheckpointFlush().
00054 { 00055 return pDelegateSegment; 00056 }
BlockNum DelegatingSegment::getAllocatedSizeInPages | ( | ) | [virtual, inherited] |
Implements Segment.
Reimplemented in CircularSegment, LinearViewSegment, and RandomAllocationSegmentBase.
Definition at line 47 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
Referenced by CircularSegment::CircularSegment(), RandomAllocationSegmentBase::format(), and RandomAllocationSegmentBase::inferSegAllocCount().
00048 { 00049 return pDelegateSegment->getAllocatedSizeInPages(); 00050 }
BlockNum DelegatingSegment::getNumPagesOccupiedHighWater | ( | ) | [virtual, inherited] |
Returns the max number of pages occupied by this segment instance.
In other words, pages that are allocated but subsequently deallocated, are included in this count. Also, the count includes all pages used by the segment, including metadata pages.
Implements Segment.
Reimplemented in RandomAllocationSegmentBase.
Definition at line 52 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
00053 { 00054 return pDelegateSegment->getNumPagesOccupiedHighWater(); 00055 }
BlockNum DelegatingSegment::getNumPagesExtended | ( | ) | [virtual, inherited] |
Implements Segment.
Definition at line 57 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
00058 { 00059 return pDelegateSegment->getNumPagesExtended(); 00060 }
PageId DelegatingSegment::getPageSuccessor | ( | PageId | pageId | ) | [virtual, inherited] |
Determines the successor of a given PageId.
This is an optional interface only supported by segments with some concept of page ordering.
pageId | PageId for which the successor is to be found |
Implements Segment.
Reimplemented in CircularSegment, LinearViewSegment, RandomAllocationSegment, SnapshotRandomAllocationSegment, and VersionedRandomAllocationSegment.
Definition at line 62 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
Referenced by SnapshotRandomAllocationSegment::getPageSuccessor(), and LinearViewSegment::LinearViewSegment().
00063 { 00064 return pDelegateSegment->getPageSuccessor(pageId); 00065 }
void DelegatingSegment::setPageSuccessor | ( | PageId | pageId, | |
PageId | successorId | |||
) | [virtual, inherited] |
Sets the successor of a given PageId.
This is an optional interface only supported by segments with some concept of modifiable ordering.
pageId | PageId for which the successor is to be set | |
successorId | PageId of successor |
Implements Segment.
Reimplemented in CircularSegment, LinearViewSegment, RandomAllocationSegment, SnapshotRandomAllocationSegment, TracingSegment, and VersionedRandomAllocationSegment.
Definition at line 67 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
Referenced by LinearViewSegment::allocatePageId(), TracingSegment::setPageSuccessor(), and SnapshotRandomAllocationSegment::setPageSuccessor().
00068 { 00069 pDelegateSegment->setPageSuccessor(pageId,successorId); 00070 }
BlockId DelegatingSegment::translatePageId | ( | PageId | ) | [virtual, inherited] |
Maps from a PageId in this segment to a BlockId.
Implements Segment.
Reimplemented in CircularSegment, LinearViewSegment, RandomAllocationSegmentBase, SnapshotRandomAllocationSegment, and TracingSegment.
Definition at line 72 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
Referenced by RandomAllocationSegmentBase::deallocatePageId(), TracingSegment::translatePageId(), SnapshotRandomAllocationSegment::translatePageId(), RandomAllocationSegmentBase::translatePageId(), LinearViewSegment::translatePageId(), and CircularSegment::translatePageId().
00073 { 00074 return pDelegateSegment->translatePageId(pageId); 00075 }
PageId DelegatingSegment::translateBlockId | ( | BlockId | ) | [virtual, inherited] |
Maps from a BlockId to a PageId in this segment.
Implements Segment.
Reimplemented in CircularSegment, LinearViewSegment, and TracingSegment.
Definition at line 77 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
Referenced by canFlushPage(), SnapshotRandomAllocationSegment::getMappedPageListener(), WALSegment::notifyAfterPageFlush(), WALSegment::notifyPageDirty(), notifyPageDirty(), TracingSegment::translateBlockId(), LinearViewSegment::translateBlockId(), and CircularSegment::translateBlockId().
00078 { 00079 return pDelegateSegment->translateBlockId(blockId); 00080 }
PageId DelegatingSegment::allocatePageId | ( | PageOwnerId | ownerId = ANON_PAGE_OWNER_ID |
) | [virtual, inherited] |
Allocates a page without locking it into memory.
ownerId | the PageOwnerId of the object which will own this page, or ANON_PAGE_OWNER_ID for pages unassociated with an owner |
Implements Segment.
Reimplemented in CircularSegment, LinearViewSegment, RandomAllocationSegment, SnapshotRandomAllocationSegment, TracingSegment, and VersionedRandomAllocationSegment.
Definition at line 82 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
Referenced by TracingSegment::allocatePageId(), SnapshotRandomAllocationSegment::allocatePageId(), and LinearViewSegment::allocatePageId().
00083 { 00084 return pDelegateSegment->allocatePageId(ownerId); 00085 }
bool DelegatingSegment::ensureAllocatedSize | ( | BlockNum | nPages | ) | [virtual, inherited] |
Allocates pages as needed to make getAllocatedSizeInPages() meet a lower bound.
The PageId's of the allocated pages are not returned, so this is mostly only meaningful for linear segments.
nPages | lower bound for getAllocatedSizeInPages() |
Reimplemented from Segment.
Reimplemented in TracingSegment.
Definition at line 87 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
Referenced by RandomAllocationSegmentBase::allocatePageIdFromSegment(), TracingSegment::ensureAllocatedSize(), RandomAllocationSegmentBase::format(), and VersionedRandomAllocationSegment::restoreFromBackup().
00088 { 00089 return pDelegateSegment->ensureAllocatedSize(nPages); 00090 }
bool DelegatingSegment::isPageIdAllocated | ( | PageId | pageId | ) | [virtual, inherited] |
Tests whether a PageId is allocated.
pageId | the PageId of interest |
Implements Segment.
Reimplemented in CircularSegment, LinearViewSegment, RandomAllocationSegmentBase, and VersionedRandomAllocationSegment.
Definition at line 97 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
Referenced by RandomAllocationSegmentBase::testPageId().
00098 { 00099 return pDelegateSegment->isPageIdAllocated(pageId); 00100 }
Segment::AllocationOrder DelegatingSegment::getAllocationOrder | ( | ) | const [virtual, inherited] |
Implements Segment.
Reimplemented in CircularSegment, LinearViewSegment, and RandomAllocationSegmentBase.
Definition at line 102 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
Referenced by RandomAllocationSegmentBase::RandomAllocationSegmentBase(), and WALSegment::WALSegment().
00103 { 00104 return pDelegateSegment->getAllocationOrder(); 00105 }
PageId DelegatingSegment::updatePage | ( | PageId | pageId, | |
bool | needsTranslation = false | |||
) | [virtual, inherited] |
Determines whether a page can be updated in-place, and if so, prepares the page for update.
pageId | pageId of the page being modified | |
needsTranslation | true if the pageId needs to be mapped to the appropriate update page; defaults to false |
Reimplemented from Segment.
Reimplemented in LinearViewSegment, and SnapshotRandomAllocationSegment.
Definition at line 148 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
Referenced by LinearViewSegment::updatePage().
00149 { 00150 return pDelegateSegment->updatePage(pageId, needsTranslation); 00151 }
void DelegatingSegment::notifyPageMap | ( | CachePage & | page | ) | [virtual, inherited] |
Receives notification from CacheImpl as soon as a page is mapped, before any I/O is initiated to retrieve the page contents.
Called with the page mutex held, so the implementation must take care to avoid deadlock.
page | the page being mapped |
Reimplemented from MappedPageListener.
Reimplemented in TracingSegment.
Definition at line 107 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
Referenced by TracingSegment::notifyPageMap().
00108 { 00109 pDelegateSegment->notifyPageMap(page); 00110 }
void DelegatingSegment::notifyPageUnmap | ( | CachePage & | page | ) | [virtual, inherited] |
Receives notification from CacheImpl just before a page is unmapped.
Called with the page mutex held, so the implementation must take care to avoid deadlock.
page | the page being unmapped |
Reimplemented from MappedPageListener.
Reimplemented in TracingSegment, and WALSegment.
Definition at line 112 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
Referenced by TracingSegment::notifyPageUnmap().
00113 { 00114 pDelegateSegment->notifyPageUnmap(page); 00115 }
void DelegatingSegment::notifyAfterPageRead | ( | CachePage & | page | ) | [virtual, inherited] |
Receives notification from CacheImpl after a page read completes.
Called with the page mutex held, so the implementation must take care to avoid deadlock.
page | the page read |
Reimplemented from MappedPageListener.
Reimplemented in TracingSegment.
Definition at line 117 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
Referenced by TracingSegment::notifyAfterPageRead().
00118 { 00119 pDelegateSegment->notifyAfterPageRead(page); 00120 }
void DelegatingSegment::notifyBeforePageFlush | ( | CachePage & | page | ) | [virtual, inherited] |
Receives notification from CacheImpl just before a dirty page is flushed to disk.
Allows some logging action to be taken; for example, flushing corresponding write-ahead log pages, or storing a checksum in the page header. Called with the page mutex held, so the implementation must take care to avoid deadlock.
page | the page to be flushed |
Reimplemented from MappedPageListener.
Reimplemented in TracingSegment.
Definition at line 127 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
Referenced by TracingSegment::notifyBeforePageFlush().
00128 { 00129 pDelegateSegment->notifyBeforePageFlush(page); 00130 }
void DelegatingSegment::notifyAfterPageFlush | ( | CachePage & | page | ) | [virtual, inherited] |
Receives notification from CacheImpl when a page flush completes successfully.
Called with the page mutex held, so the implementation must take care to avoid deadlock.
page | the page that was flushed |
Reimplemented from MappedPageListener.
Reimplemented in TracingSegment, and WALSegment.
Definition at line 132 of file DelegatingSegment.cpp.
References DelegatingSegment::pDelegateSegment.
Referenced by WALSegment::notifyAfterPageFlush(), and TracingSegment::notifyAfterPageFlush().
00133 { 00134 pDelegateSegment->notifyAfterPageFlush(page); 00135 }
void Segment::setUsablePageSize | ( | uint | ) | [protected, inherited] |
Definition at line 70 of file Segment.cpp.
References Segment::cbUsablePerPage.
Referenced by DelegatingSegment::DelegatingSegment(), DynamicDelegatingSegment::DynamicDelegatingSegment(), Segment::Segment(), and VersionedSegment().
00071 { 00072 cbUsablePerPage = cb; 00073 }
PConstBuffer Segment::getReadableFooter | ( | CachePage & | page | ) | [protected, inherited] |
Definition at line 75 of file Segment.cpp.
References CachePage::getReadableData(), and Segment::getUsablePageSize().
Referenced by getPageVersion(), and recover().
00076 { 00077 return page.getReadableData() + getUsablePageSize(); 00078 }
Definition at line 80 of file Segment.cpp.
References Segment::getUsablePageSize(), and CachePage::getWritableData().
Referenced by notifyPageDirty().
00081 { 00082 return page.getWritableData() + getUsablePageSize(); 00083 }
PageId Segment::getLinearPageSuccessor | ( | PageId | pageId | ) | [protected, inherited] |
An implementation of getPageSuccessor suitable for LINEAR_ALLOCATION.
Definition at line 85 of file Segment.cpp.
References Segment::isPageIdAllocated(), and NULL_PAGE_ID.
Referenced by ScratchSegment::getPageSuccessor(), LinearViewSegment::getPageSuccessor(), LinearDeviceSegment::getPageSuccessor(), and CircularSegment::getPageSuccessor().
00086 { 00087 assert(isPageIdAllocated(pageId)); 00088 ++pageId; 00089 if (!isPageIdAllocated(pageId)) { 00090 return NULL_PAGE_ID; 00091 } 00092 return pageId; 00093 }
void Segment::setLinearPageSuccessor | ( | PageId | pageId, | |
PageId | successorId | |||
) | [protected, inherited] |
An implementation of setPageSuccessor suitable for LINEAR_ALLOCATION.
Definition at line 95 of file Segment.cpp.
References Segment::getLinearBlockNum(), and Segment::isPageIdAllocated().
Referenced by ScratchSegment::setPageSuccessor(), LinearViewSegment::setPageSuccessor(), LinearDeviceSegment::setPageSuccessor(), and CircularSegment::setPageSuccessor().
00096 { 00097 assert(isPageIdAllocated(pageId)); 00098 assert(isPageIdAllocated(successorId)); 00099 assert(getLinearBlockNum(successorId) 00100 == getLinearBlockNum(pageId) + 1); 00101 }
bool Segment::isLinearPageIdAllocated | ( | PageId | pageId | ) | [protected, inherited] |
An implementation of isPageIdAllocated suitable for LINEAR_ALLOCATION when deallocation holes are disallowed.
Definition at line 103 of file Segment.cpp.
References Segment::getAllocatedSizeInPages(), and Segment::getLinearBlockNum().
Referenced by ScratchSegment::isPageIdAllocated(), LinearViewSegment::isPageIdAllocated(), and LinearDeviceSegment::isPageIdAllocated().
00104 { 00105 if (getLinearBlockNum(pageId) >= getAllocatedSizeInPages()) { 00106 return false; 00107 } 00108 return true; 00109 }
SharedCache Segment::getCache | ( | ) | const [inline, inherited] |
Definition at line 358 of file Segment.h.
References Segment::pCache.
Referenced by ScratchSegment::getCache(), and TempSegDestructor::operator()().
00359 { 00360 return pCache; 00361 }
uint Segment::getFullPageSize | ( | ) | const [inherited] |
Definition at line 133 of file Segment.cpp.
References Segment::pCache.
Referenced by LinearDeviceSegment::ensureAllocatedSize(), LinearDeviceSegment::getAvailableDevicePages(), LinearDeviceSegment::LinearDeviceSegment(), VersionedRandomAllocationSegment::locateDataPages(), recover(), Segment::Segment(), and SegPageLock::swapBuffers().
00134 { 00135 return pCache->getPageSize(); 00136 }
uint Segment::getUsablePageSize | ( | ) | const [inline, inherited] |
Definition at line 363 of file Segment.h.
References Segment::cbUsablePerPage.
Referenced by computeChecksum(), DynamicDelegatingSegment::DynamicDelegatingSegment(), Segment::getReadableFooter(), Segment::getWritableFooter(), notifyPageDirty(), RandomAllocationSegment::RandomAllocationSegment(), RandomAllocationSegmentBase::RandomAllocationSegmentBase(), SegPageLock::swapBuffers(), VersionedRandomAllocationSegment::VersionedRandomAllocationSegment(), and VersionedSegment().
00364 { 00365 return cbUsablePerPage; 00366 }
void Segment::initForUse | ( | ) | [virtual, inherited] |
Performs additional initialization required on the segment after it has been properly formatted.
Reimplemented in RandomAllocationSegmentBase, and VersionedRandomAllocationSegment.
Definition at line 163 of file Segment.cpp.
SharedSegment Segment::getTracingSegment | ( | ) | [inherited] |
Definition at line 50 of file Segment.cpp.
References Segment::pTracingSegment.
Referenced by VersionedRandomAllocationSegment::allocateAllocNodes(), RandomAllocationSegment::allocateFromExtent(), RandomAllocationSegment::allocateFromNewExtent(), RandomAllocationSegment::allocatePageId(), VersionedRandomAllocationSegment::backupAllocationNodes(), VersionedRandomAllocationSegment::chainPageEntries(), SnapshotRandomAllocationSegment::commitChanges(), VersionedRandomAllocationSegment::copyPageEntryFromTemp(), VersionedRandomAllocationSegment::copyPageEntryToTemp(), RandomAllocationSegmentBase::deallocatePageId(), VersionedRandomAllocationSegment::findAllocPageIdForRead(), RandomAllocationSegmentBase::format(), RandomAllocationSegmentBase::formatPageExtentsTemplate(), RandomAllocationSegmentBase::freePageEntryTemplate(), RandomAllocationSegment::getExtAllocPageIdForRead(), VersionedRandomAllocationSegment::getOldestTxnId(), VersionedRandomAllocationSegment::getOldPageIds(), RandomAllocationSegmentBase::getPageEntryCopyTemplate(), RandomAllocationSegment::getSegAllocPageIdForRead(), VersionedRandomAllocationSegment::getTempAllocNodePage(), Segment::getTracingListener(), VersionedRandomAllocationSegment::locateDataPages(), VersionedRandomAllocationSegment::restoreFromBackup(), SnapshotRandomAllocationSegment::rollbackChanges(), RandomAllocationSegment::setPageSuccessor(), VersionedRandomAllocationSegment::updateExtentEntry(), and VersionedRandomAllocationSegment::validateFreePageCount().
00051 { 00052 SharedSegment sharedPtr = pTracingSegment.lock(); 00053 if (sharedPtr && sharedPtr.get()) { 00054 return sharedPtr; 00055 } else { 00056 return shared_from_this(); 00057 } 00058 }
void Segment::setTracingSegment | ( | WeakSegment | pTracingSegmentInit | ) | [inherited] |
Sets the tracing segment associated with this segment.
pTracingSegmentInit | the tracing segment |
Definition at line 60 of file Segment.cpp.
References Segment::pTracingSegment.
00061 { 00062 pTracingSegment = pTracingSegmentInit; 00063 }
void Segment::checkpoint | ( | CheckpointType | checkpointType = CHECKPOINT_FLUSH_ALL |
) | [inherited] |
Checkpoints this segment.
checkpointType | type of checkpoint to execute |
Definition at line 111 of file Segment.cpp.
References Segment::delegatedCheckpoint(), and Segment::pTracingSegment.
Referenced by Segment::closeImpl(), BackupRestoreTest::createSnapshotData(), BackupRestoreTest::executeSnapshotTxn(), and LcsClusterReplaceExecStreamTest::testClusterReplace().
00112 { 00113 // Note that we can't use getTracingSegment() here because that method 00114 // references the shared ptr associated with this segment, and the 00115 // shared segment may have already been freed during shutdown by the 00116 // time this method is called. 00117 SharedSegment sharedPtr = pTracingSegment.lock(); 00118 if (sharedPtr && sharedPtr.get()) { 00119 delegatedCheckpoint(*(sharedPtr.get()),checkpointType); 00120 } else { 00121 delegatedCheckpoint(*this,checkpointType); 00122 } 00123 }
MappedPageListener * Segment::getMappedPageListener | ( | BlockId | blockId | ) | [virtual, inherited] |
Returns the mapped page listener corresponding to a page.
blockId | blockId of the page whose page listener we are returning |
Reimplemented in DynamicDelegatingSegment, SnapshotRandomAllocationSegment, and TracingSegment.
Definition at line 153 of file Segment.cpp.
bool Segment::isWriteVersioned | ( | ) | [virtual, inherited] |
Reimplemented in DynamicDelegatingSegment, SnapshotRandomAllocationSegment, and TracingSegment.
Definition at line 158 of file Segment.cpp.
PageId Segment::getLinearPageId | ( | BlockNum | iPage | ) | [inline, static, inherited] |
Constructs a linear PageId based on a linear page number.
Definition at line 348 of file Segment.h.
Referenced by RandomAllocationSegmentBase::allocateFromLockedExtentTemplate(), ScratchSegment::allocatePageId(), LinearViewSegment::allocatePageId(), LinearDeviceSegment::allocatePageId(), CircularSegment::allocatePageId(), RandomAllocationSegmentBase::getExtentAllocPageId(), VersionedRandomAllocationSegment::getOldPageIds(), RandomAllocationSegmentBase::getSegAllocPageId(), Database::init(), VersionedRandomAllocationSegment::locateDataPages(), SegmentTestBase::lockPage(), SegmentTestBase::prefetchPage(), SegPageIterTest::testBoundedIter(), SegPageEntryIterTest::testBoundedIter(), ScratchSegment::translateBlockId(), LinearViewSegment::translateBlockId(), LinearDeviceSegment::translateBlockId(), CircularSegment::translateBlockId(), and CircularSegment::translatePageId().
BlockNum Segment::getLinearBlockNum | ( | PageId | pageId | ) | [inline, static, inherited] |
Obtains the linear page number from a linear PageId.
Definition at line 353 of file Segment.h.
References opaqueToInt().
Referenced by CircularSegment::CircularSegment(), LinearDeviceSegment::deallocatePageRange(), CircularSegment::deallocatePageRange(), Segment::isLinearPageIdAllocated(), CircularSegment::isPageIdAllocated(), SegmentTestBase::lockPage(), SegInputStream::readPrevBuffer(), Segment::setLinearPageSuccessor(), RandomAllocationSegmentBase::splitPageId(), CircularSegment::translateBlockId(), ScratchSegment::translatePageId(), LinearViewSegment::translatePageId(), LinearDeviceSegment::translatePageId(), CircularSegment::translatePageId(), and LinearViewSegment::updatePage().
00354 { 00355 return opaqueToInt(pageId); 00356 }
MappedPageListener * Segment::getTracingListener | ( | ) | [virtual, inherited] |
Retrieves the tracing wrapper corresponding to this listener if tracing is turned on.
Otherwise, returns this listener itself.
Implements MappedPageListener.
Definition at line 65 of file Segment.cpp.
References Segment::getTracingSegment().
00066 { 00067 return getTracingSegment().get(); 00068 }
MappedPageListener * MappedPageListener::notifyAfterPageCheckpointFlush | ( | CachePage & | page | ) | [virtual, inherited] |
Receives notification that a page has been flushed during a checkpoint.
Also determines if the listener on the page needs to be reset.
Note that if the page listener is reset, that page may not be unmapped during a CHECKPOINT_FLUSH_AND_UNMAP checkpoint call.
This method should be called immediately after the page flush has completed while the checkpoint is still in progress.
page | the page that was flushed |
Reimplemented in SnapshotRandomAllocationSegment, and TracingSegment.
Definition at line 62 of file MappedPageListener.cpp.
bool ClosableObject::isClosed | ( | ) | const [inline, inherited] |
Definition at line 58 of file ClosableObject.h.
00059 { 00060 return !needsClose; 00061 }
void ClosableObject::close | ( | ) | [inherited] |
Closes this object, releasing any unallocated resources.
Reimplemented in CollectExecStream, CorrelationJoinExecStream, LcsClusterAppendExecStream, and LcsClusterReplaceExecStream.
Definition at line 39 of file ClosableObject.cpp.
References ClosableObject::closeImpl(), and ClosableObject::needsClose.
Referenced by CacheImpl< PageT, VictimPolicyT >::allocatePages(), LcsRowScanBaseExecStream::closeImpl(), ExecStreamGraphImpl::closeImpl(), FlatFileBuffer::open(), ClosableObjectDestructor::operator()(), and Segment::~Segment().
00040 { 00041 if (!needsClose) { 00042 return; 00043 } 00044 needsClose = false; 00045 closeImpl(); 00046 }
friend class SegmentFactory [friend] |
Definition at line 47 of file VersionedSegment.h.
bool VersionedSegment::inRecovery [private] |
Definition at line 49 of file VersionedSegment.h.
Referenced by notifyPageDirty(), recover(), and VersionedSegment().
PseudoUuid VersionedSegment::onlineUuid [private] |
Definition at line 50 of file VersionedSegment.h.
Referenced by notifyPageDirty(), recover(), and VersionedSegment().
SegVersionNum VersionedSegment::versionNumber [private] |
Definition at line 51 of file VersionedSegment.h.
Referenced by delegatedCheckpoint(), getVersionNumber(), notifyPageDirty(), recover(), and VersionedSegment().
PageId VersionedSegment::oldestLogPageId [private] |
Definition at line 52 of file VersionedSegment.h.
Referenced by delegatedCheckpoint(), getOnlineRecoveryPageId(), getRecoveryPageId(), notifyPageDirty(), prepareOnlineRecovery(), and VersionedSegment().
PageId VersionedSegment::newestLogPageId [private] |
Definition at line 53 of file VersionedSegment.h.
Referenced by deallocateCheckpointedLog(), notifyPageDirty(), and VersionedSegment().
PageId VersionedSegment::lastCheckpointLogPageId [private] |
Definition at line 54 of file VersionedSegment.h.
Referenced by deallocateCheckpointedLog(), delegatedCheckpoint(), and VersionedSegment().
StrictMutex VersionedSegment::mutex [private] |
Definition at line 55 of file VersionedSegment.h.
Referenced by canFlushPage(), delegatedCheckpoint(), notifyPageDirty(), and prepareOnlineRecovery().
SharedSegment VersionedSegment::logSegment [private] |
Definition at line 56 of file VersionedSegment.h.
Referenced by deallocateCheckpointedLog(), delegatedCheckpoint(), getLogSegment(), notifyPageDirty(), prepareOnlineRecovery(), recover(), and VersionedSegment().
WALSegment* VersionedSegment::pWALSegment [private] |
Definition at line 57 of file VersionedSegment.h.
Referenced by canFlushPage(), delegatedCheckpoint(), recover(), VersionedSegment(), and ~VersionedSegment().
boost::crc_32_type VersionedSegment::crcComputer [private] |
PageMap VersionedSegment::dataToLogMap [private] |
Definition at line 63 of file VersionedSegment.h.
Referenced by canFlushPage(), delegatedCheckpoint(), notifyPageDirty(), prepareOnlineRecovery(), recover(), and ~VersionedSegment().
SharedCache Segment::pCache [protected, inherited] |
Cache managing pages of this segment.
Definition at line 62 of file Segment.h.
Referenced by VersionedRandomAllocationSegment::allocateAllocNodes(), RandomAllocationSegmentBase::allocateFromExtentTemplate(), RandomAllocationSegmentBase::allocateFromNewExtentTemplate(), RandomAllocationSegmentBase::allocatePageIdFromSegment(), VersionedRandomAllocationSegment::backupAllocationNodes(), VersionedRandomAllocationSegment::chainPageEntries(), VersionedRandomAllocationSegment::copyPageEntryFromTemp(), VersionedRandomAllocationSegment::copyPageEntryToTemp(), RandomAllocationSegmentBase::deallocatePageId(), VersionedRandomAllocationSegment::deallocateSinglePage(), VersionedRandomAllocationSegment::deferDeallocation(), delegatedCheckpoint(), SnapshotRandomAllocationSegment::delegatedCheckpoint(), Segment::delegatedCheckpoint(), RandomAllocationSegmentBase::format(), RandomAllocationSegmentBase::formatPageExtentsTemplate(), RandomAllocationSegmentBase::freePageEntryTemplate(), Segment::getCache(), Segment::getFullPageSize(), VersionedRandomAllocationSegment::getOldestTxnId(), VersionedRandomAllocationSegment::getOldPageIds(), RandomAllocationSegmentBase::getPageEntryCopyTemplate(), VersionedRandomAllocationSegment::getTempAllocNodePage(), VersionedRandomAllocationSegment::initPageEntry(), VersionedRandomAllocationSegment::locateDataPages(), notifyPageDirty(), recover(), VersionedRandomAllocationSegment::restoreFromBackup(), RandomAllocationSegmentBase::setPageSuccessorTemplate(), RandomAllocationSegmentBase::tallySegAllocNodePages(), VersionedRandomAllocationSegment::uncommittedDeallocation(), VersionedRandomAllocationSegment::updateExtentEntry(), VersionedRandomAllocationSegment::updatePageEntry(), VersionedRandomAllocationSegment::updateTempPageEntry(), and VersionedRandomAllocationSegment::validateFreePageCount().
WeakSegment Segment::pTracingSegment [protected, inherited] |
The tracing segment associated with this segment, if tracing is turned on.
A weak_ptr is used due to the circular shared pointers between this segment and its tracing segment.
Definition at line 69 of file Segment.h.
Referenced by Segment::checkpoint(), Segment::getTracingSegment(), and Segment::setTracingSegment().
bool ClosableObject::needsClose [protected, inherited] |
Definition at line 44 of file ClosableObject.h.
Referenced by SegStreamAllocation::beginWrite(), ExecStreamGraphImpl::clear(), ClosableObject::ClosableObject(), ClosableObject::close(), FlatFileBuffer::open(), ExecStreamGraphImpl::open(), ExecStream::open(), and ClosableObject::~ClosableObject().