#include <LinearDeviceSegment.h>
Inheritance diagram for LinearDeviceSegment:
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 | ~LinearDeviceSegment () |
DeviceId | getDeviceId () const |
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) |
Allocates a page without locking it into memory. | |
virtual void | deallocatePageRange (PageId startPageId, PageId endPageId) |
Deallocates a range of pages allocated from this segment. | |
virtual bool | isPageIdAllocated (PageId pageId) |
Tests whether a PageId is allocated. | |
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 AllocationOrder | getAllocationOrder () const |
| |
virtual bool | ensureAllocatedSize (BlockNum nPages) |
Allocates pages as needed to make getAllocatedSizeInPages() meet a lower bound. | |
virtual void | delegatedCheckpoint (Segment &delegatingSegment, CheckpointType checkpointType) |
Helper for DelegatingSegment. | |
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 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 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 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 | 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. | |
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. | |
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. | |
virtual void | closeImpl () |
Must be implemented by derived class to release any resources. | |
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 | |
LinearDeviceSegment (SharedCache cache, LinearDeviceSegmentParams const &) | |
BlockNum | getAvailableDevicePages () const |
Private Attributes | |
SharedRandomAccessDevice | pDevice |
BlockId | firstBlockId |
BlockNum | nPagesMax |
BlockNum | nPagesAllocated |
BlockNum | nPagesIncrement |
BlockNum | nPagesExtended |
Friends | |
class | SegmentFactory |
See the design docs for more detail.
Individual deallocation of pages of a LinearDeviceSegment is not supported. deallocatePageRange is supported when endPageId is NULL_PAGE_ID. This does not affect the size of the underlying device (REVIEW: maybe it should?)
Definition at line 85 of file LinearDeviceSegment.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 };
LinearDeviceSegment::LinearDeviceSegment | ( | SharedCache | cache, | |
LinearDeviceSegmentParams const & | ||||
) | [explicit, private] |
Definition at line 46 of file LinearDeviceSegment.cpp.
References LinearDeviceSegmentParams::firstBlockId, firstBlockId, getAvailableDevicePages(), Segment::getFullPageSize(), isMAXU(), LinearDeviceSegmentParams::nPagesAllocated, nPagesAllocated, nPagesExtended, LinearDeviceSegmentParams::nPagesIncrement, nPagesIncrement, LinearDeviceSegmentParams::nPagesMax, nPagesMax, LinearDeviceSegmentParams::nPagesMin, and pDevice.
00049 : Segment(cache), 00050 pDevice( 00051 cache->getDevice(CompoundId::getDeviceId(params.firstBlockId))) 00052 { 00053 firstBlockId = params.firstBlockId; 00054 nPagesMax = params.nPagesMax; 00055 nPagesAllocated = params.nPagesAllocated; 00056 nPagesIncrement = params.nPagesIncrement; 00057 nPagesExtended = 0; 00058 BlockNum nPagesActual = getAvailableDevicePages(); 00059 if (nPagesActual < params.nPagesMin) { 00060 pDevice->setSizeInBytes( 00061 pDevice->getSizeInBytes() + 00062 (params.nPagesMin - nPagesActual)*getFullPageSize()); 00063 nPagesActual = params.nPagesMin; 00064 } 00065 if (isMAXU(nPagesAllocated)) { 00066 nPagesAllocated = nPagesActual; 00067 } else { 00068 assert(nPagesAllocated <= nPagesActual); 00069 } 00070 }
LinearDeviceSegment::~LinearDeviceSegment | ( | ) | [virtual] |
BlockNum LinearDeviceSegment::getAvailableDevicePages | ( | ) | const [private] |
Definition at line 40 of file LinearDeviceSegment.cpp.
References firstBlockId, CompoundId::getBlockNum(), Segment::getFullPageSize(), and pDevice.
Referenced by ensureAllocatedSize(), and LinearDeviceSegment().
00041 { 00042 return pDevice->getSizeInBytes() / getFullPageSize() - 00043 CompoundId::getBlockNum(firstBlockId); 00044 }
DeviceId LinearDeviceSegment::getDeviceId | ( | ) | const |
Definition at line 158 of file LinearDeviceSegment.cpp.
References firstBlockId, and CompoundId::getDeviceId().
Referenced by TempSegDestructor::operator()().
00159 { 00160 return CompoundId::getDeviceId(firstBlockId); 00161 }
BlockId LinearDeviceSegment::translatePageId | ( | PageId | ) | [virtual] |
Maps from a PageId in this segment to a BlockId.
Implements Segment.
Definition at line 76 of file LinearDeviceSegment.cpp.
References firstBlockId, CompoundId::getBlockNum(), Segment::getLinearBlockNum(), isPageIdAllocated(), and CompoundId::setBlockNum().
00077 { 00078 assert(isPageIdAllocated(pageId)); 00079 BlockId blockId = firstBlockId; 00080 CompoundId::setBlockNum( 00081 blockId, 00082 CompoundId::getBlockNum(firstBlockId) 00083 + getLinearBlockNum(pageId)); 00084 return blockId; 00085 }
PageId LinearDeviceSegment::translateBlockId | ( | BlockId | ) | [virtual] |
Maps from a BlockId to a PageId in this segment.
Implements Segment.
Definition at line 87 of file LinearDeviceSegment.cpp.
References firstBlockId, CompoundId::getBlockNum(), and Segment::getLinearPageId().
00088 { 00089 return getLinearPageId( 00090 CompoundId::getBlockNum(blockId) 00091 - CompoundId::getBlockNum(firstBlockId)); 00092 }
PageId LinearDeviceSegment::allocatePageId | ( | PageOwnerId | ownerId | ) | [virtual] |
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.
Definition at line 109 of file LinearDeviceSegment.cpp.
References ensureAllocatedSize(), Segment::getLinearPageId(), nPagesAllocated, and NULL_PAGE_ID.
00110 { 00111 // nothing to do with PageOwnerId 00112 00113 BlockNum newBlockNum = nPagesAllocated; 00114 00115 if (!ensureAllocatedSize(nPagesAllocated + 1)) { 00116 return NULL_PAGE_ID; 00117 } 00118 00119 return getLinearPageId(newBlockNum); 00120 }
void LinearDeviceSegment::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 |
Implements Segment.
Definition at line 122 of file LinearDeviceSegment.cpp.
References Segment::getLinearBlockNum(), nPagesAllocated, and NULL_PAGE_ID.
00124 { 00125 if (endPageId != NULL_PAGE_ID) { 00126 // REVIEW: Technically, this should assert; instead, we let it slip so 00127 // that LinearDeviceSegments can be used as really stupid logs in 00128 // tests. Should probably fix the tests and tighten this up. 00129 return; 00130 } 00131 if (startPageId == NULL_PAGE_ID) { 00132 nPagesAllocated = 0; 00133 } else { 00134 nPagesAllocated = getLinearBlockNum(startPageId); 00135 } 00136 }
bool LinearDeviceSegment::isPageIdAllocated | ( | PageId | pageId | ) | [virtual] |
Tests whether a PageId is allocated.
pageId | the PageId of interest |
Implements Segment.
Definition at line 138 of file LinearDeviceSegment.cpp.
References Segment::isLinearPageIdAllocated().
Referenced by translatePageId().
00139 { 00140 return isLinearPageIdAllocated(pageId); 00141 }
BlockNum LinearDeviceSegment::getAllocatedSizeInPages | ( | ) | [virtual] |
Implements Segment.
Definition at line 94 of file LinearDeviceSegment.cpp.
References nPagesAllocated.
Referenced by getNumPagesOccupiedHighWater().
00095 { 00096 return nPagesAllocated; 00097 }
BlockNum LinearDeviceSegment::getNumPagesOccupiedHighWater | ( | ) | [virtual] |
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.
Definition at line 99 of file LinearDeviceSegment.cpp.
References getAllocatedSizeInPages().
00100 { 00101 return getAllocatedSizeInPages(); 00102 }
BlockNum LinearDeviceSegment::getNumPagesExtended | ( | ) | [virtual] |
Implements Segment.
Definition at line 104 of file LinearDeviceSegment.cpp.
References nPagesExtended.
00105 { 00106 return nPagesExtended; 00107 }
PageId LinearDeviceSegment::getPageSuccessor | ( | PageId | pageId | ) | [virtual] |
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.
Definition at line 143 of file LinearDeviceSegment.cpp.
References Segment::getLinearPageSuccessor().
00144 { 00145 return getLinearPageSuccessor(pageId); 00146 }
void LinearDeviceSegment::setPageSuccessor | ( | PageId | pageId, | |
PageId | successorId | |||
) | [virtual] |
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.
Definition at line 148 of file LinearDeviceSegment.cpp.
References Segment::setLinearPageSuccessor().
00149 { 00150 setLinearPageSuccessor(pageId,successorId); 00151 }
Segment::AllocationOrder LinearDeviceSegment::getAllocationOrder | ( | ) | const [virtual] |
Implements Segment.
Definition at line 153 of file LinearDeviceSegment.cpp.
References Segment::LINEAR_ALLOCATION.
00154 { 00155 return LINEAR_ALLOCATION; 00156 }
bool LinearDeviceSegment::ensureAllocatedSize | ( | BlockNum | nPages | ) | [virtual] |
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.
Definition at line 163 of file LinearDeviceSegment.cpp.
References getAvailableDevicePages(), Segment::getFullPageSize(), isMAXU(), max(), nPagesAllocated, nPagesExtended, nPagesIncrement, nPagesMax, and pDevice.
Referenced by allocatePageId().
00164 { 00165 if (nPages > nPagesMax) { 00166 return false; 00167 } 00168 if (nPages <= nPagesAllocated) { 00169 return true; 00170 } 00171 BlockNum nPagesAvailable = getAvailableDevicePages(); 00172 assert(nPagesAllocated <= nPagesAvailable); 00173 if (nPages > nPagesAvailable) { 00174 if (!nPagesIncrement) { 00175 return false; 00176 } 00177 BlockNum nNewPages = std::max(nPagesIncrement,nPages - nPagesAvailable); 00178 if (!isMAXU(nPagesMax) && (nPagesAvailable + nNewPages > nPagesMax)) { 00179 nNewPages = nPagesMax - nPagesAvailable; 00180 } 00181 assert(nNewPages); 00182 nPagesExtended += nNewPages; 00183 pDevice->setSizeInBytes( 00184 pDevice->getSizeInBytes() + nNewPages*getFullPageSize()); 00185 } 00186 nPagesAllocated = nPages; 00187 return true; 00188 }
void LinearDeviceSegment::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 Segment.
Definition at line 190 of file LinearDeviceSegment.cpp.
References CHECKPOINT_DISCARD, Segment::delegatedCheckpoint(), and pDevice.
00193 { 00194 Segment::delegatedCheckpoint(delegatingSegment,checkpointType); 00195 if (checkpointType != CHECKPOINT_DISCARD) { 00196 pDevice->flush(); 00197 } 00198 }
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::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 VersionedSegment::getPageVersion(), and VersionedSegment::recover().
00076 { 00077 return page.getReadableData() + getUsablePageSize(); 00078 }
Definition at line 80 of file Segment.cpp.
References Segment::getUsablePageSize(), and CachePage::getWritableData().
Referenced by VersionedSegment::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(), 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(), 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 isPageIdAllocated().
00104 { 00105 if (getLinearBlockNum(pageId) >= getAllocatedSizeInPages()) { 00106 return false; 00107 } 00108 return true; 00109 }
void Segment::closeImpl | ( | ) | [protected, virtual, inherited] |
Must be implemented by derived class to release any resources.
Implements ClosableObject.
Reimplemented in DelegatingSegment, DynamicDelegatingSegment, and ScratchSegment.
Definition at line 45 of file Segment.cpp.
References Segment::checkpoint(), and CHECKPOINT_FLUSH_AND_UNMAP.
Referenced by DynamicDelegatingSegment::closeImpl(), and DelegatingSegment::closeImpl().
00046 { 00047 checkpoint(CHECKPOINT_FLUSH_AND_UNMAP); 00048 }
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 ensureAllocatedSize(), getAvailableDevicePages(), LinearDeviceSegment(), VersionedRandomAllocationSegment::locateDataPages(), VersionedSegment::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 VersionedSegment::computeChecksum(), DynamicDelegatingSegment::DynamicDelegatingSegment(), Segment::getReadableFooter(), Segment::getWritableFooter(), VersionedSegment::notifyPageDirty(), RandomAllocationSegment::RandomAllocationSegment(), RandomAllocationSegmentBase::RandomAllocationSegmentBase(), SegPageLock::swapBuffers(), VersionedRandomAllocationSegment::VersionedRandomAllocationSegment(), and VersionedSegment::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 }
PageId Segment::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 in DelegatingSegment, DynamicDelegatingSegment, LinearViewSegment, and SnapshotRandomAllocationSegment.
Definition at line 148 of file Segment.cpp.
References NULL_PAGE_ID.
00149 { 00150 return NULL_PAGE_ID; 00151 }
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(), 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(), 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(), deallocatePageRange(), CircularSegment::deallocatePageRange(), Segment::isLinearPageIdAllocated(), CircularSegment::isPageIdAllocated(), SegmentTestBase::lockPage(), SegInputStream::readPrevBuffer(), Segment::setLinearPageSuccessor(), RandomAllocationSegmentBase::splitPageId(), CircularSegment::translateBlockId(), ScratchSegment::translatePageId(), LinearViewSegment::translatePageId(), 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 }
void MappedPageListener::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 in DelegatingSegment, DynamicDelegatingSegment, and TracingSegment.
Definition at line 29 of file MappedPageListener.cpp.
Referenced by CacheImpl< PageT, VictimPolicyT >::mapPage().
void MappedPageListener::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 in DelegatingSegment, DynamicDelegatingSegment, TracingSegment, and WALSegment.
Definition at line 33 of file MappedPageListener.cpp.
void MappedPageListener::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 in DelegatingSegment, DynamicDelegatingSegment, and TracingSegment.
Definition at line 37 of file MappedPageListener.cpp.
Referenced by CacheImpl< PageT, VictimPolicyT >::notifyTransferCompletion().
void MappedPageListener::notifyPageDirty | ( | CachePage & | page, | |
bool | bDataValid | |||
) | [virtual, inherited] |
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 in DelegatingSegment, DynamicDelegatingSegment, SnapshotRandomAllocationSegment, TracingSegment, VersionedSegment, and WALSegment.
Definition at line 41 of file MappedPageListener.cpp.
bool MappedPageListener::canFlushPage | ( | CachePage & | page | ) | [virtual, inherited] |
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 in DelegatingSegment, DynamicDelegatingSegment, SnapshotRandomAllocationSegment, and VersionedSegment.
Definition at line 53 of file MappedPageListener.cpp.
Referenced by CacheImpl< PageT, VictimPolicyT >::flushPage().
void MappedPageListener::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 in DelegatingSegment, DynamicDelegatingSegment, and TracingSegment.
Definition at line 45 of file MappedPageListener.cpp.
void MappedPageListener::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 in DelegatingSegment, DynamicDelegatingSegment, TracingSegment, and WALSegment.
Definition at line 49 of file MappedPageListener.cpp.
Referenced by CacheImpl< PageT, VictimPolicyT >::notifyTransferCompletion().
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 88 of file LinearDeviceSegment.h.
Definition at line 90 of file LinearDeviceSegment.h.
Referenced by delegatedCheckpoint(), ensureAllocatedSize(), getAvailableDevicePages(), and LinearDeviceSegment().
BlockId LinearDeviceSegment::firstBlockId [private] |
Definition at line 91 of file LinearDeviceSegment.h.
Referenced by getAvailableDevicePages(), getDeviceId(), LinearDeviceSegment(), translateBlockId(), and translatePageId().
BlockNum LinearDeviceSegment::nPagesMax [private] |
Definition at line 92 of file LinearDeviceSegment.h.
Referenced by ensureAllocatedSize(), and LinearDeviceSegment().
BlockNum LinearDeviceSegment::nPagesAllocated [private] |
Definition at line 92 of file LinearDeviceSegment.h.
Referenced by allocatePageId(), deallocatePageRange(), ensureAllocatedSize(), getAllocatedSizeInPages(), and LinearDeviceSegment().
BlockNum LinearDeviceSegment::nPagesIncrement [private] |
Definition at line 92 of file LinearDeviceSegment.h.
Referenced by ensureAllocatedSize(), and LinearDeviceSegment().
BlockNum LinearDeviceSegment::nPagesExtended [private] |
Definition at line 92 of file LinearDeviceSegment.h.
Referenced by ensureAllocatedSize(), getNumPagesExtended(), and LinearDeviceSegment().
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(), VersionedSegment::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(), VersionedSegment::notifyPageDirty(), VersionedSegment::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().