Fennel: VersionedRandomAllocationSegment Class Reference (original) (raw)

VersionedRandomAllocationSegment refines RandomAllocationSegmentBase, defining a VersionedExtentAllocationNode where each page entry within the segment is versioned. More...

#include <[VersionedRandomAllocationSegment.h](VersionedRandomAllocationSegment%5F8h-source.html)>

Inheritance diagram for VersionedRandomAllocationSegment:

List of all members.

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
VersionedRandomAllocationSegment (SharedSegment delegateSegment, SharedSegment pTempSegmentInit)
void getLatestPageEntryCopy (PageId pageId, VersionedPageEntry &pageEntryCopy)
Retrieves the latest copy of a page entry for a specified page, which may correspond to an uncommitted, modified page entry.
void initPageEntry (PageId pageId, PageId versionChainId, TxnId allocationCsn)
Initializes the versioning fields in a pageEntry for a specified page.
void chainPageEntries (PageId pageId, PageId versionChainId, PageId successorId)
Chains one page to another, updating the corresponding page entry in the temp segment page.
void updateAllocNodes (ModifiedPageEntryMap const &modifiedPageEntryMap, TxnId commitCsn, bool commit, SharedSegment pOrigSegment)
Updates the permanent allocation nodes to reflect changes currently in the temporary segment, or vice versa if the updates correspond to a rollback.
SXMutex & getDeallocationMutex ()
**Returns:**the deallocation mutex that prevents reading of the page chain while deallocations are in progress
bool getOldPageIds (uint &iSegAlloc, ExtentNum &extentNum, TxnId oldestActiveTxnId, uint numPages, PageSet &oldPageSet)
Retrieves a batch of pageIds corresponding either to old snapshot pages that are no longer being referenced or pages marked for deallocation.
void deallocateOldPages (PageSet const &oldPageSet, TxnId oldestActiveTxnId)
Deallocates an old set of pages and updates the version chain that the pages may be a part of.
void freeTempPages ()
Frees any of the remaining temp pages that were used to keep track of allocation node updates.
BlockNum backupAllocationNodes (SharedSegPageBackupRestoreDevice pBackupDevice, bool countDataPages, TxnId lowerBoundCsn, TxnId upperBoundCsn, bool volatile const &abortFlag)
Writes all the segment and extent allocation pages from this segment sequentially to a backup file.
void backupDataPages (SharedSegPageBackupRestoreDevice pBackupDevice, TxnId lowerBoundCsn, TxnId upperBoundCsn, bool volatile const &abortFlag)
Walks through all page entries in this segment and locates the ones that have allocationCsn's in between a lower and upper bound.
void restoreFromBackup (SharedSegPageBackupRestoreDevice pBackupDevice, TxnId lowerBoundCsn, TxnId upperBoundCsn, bool volatile const &abortFlag)
Restores the segment and extent allocation node pages and data pages for this segment from a backup file.
virtual bool isPageIdAllocated (PageId pageId)
Tests whether a PageId is allocated.
virtual PageId allocatePageId (PageOwnerId ownerId)
Allocates a page without locking it into memory.
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 void deallocatePageRange (PageId startPageId, PageId endPageId)
Deallocates a range of pages allocated from this segment.
virtual void initForUse ()
Performs additional initialization required on the segment after it has been properly formatted.
virtual BlockId translatePageId (PageId)
Maps from a PageId in this segment to a BlockId.
virtual AllocationOrder getAllocationOrder () const
**Returns:**the AllocationOrder for this segment
virtual BlockNum getAllocatedSizeInPages ()
**Returns:**number of pages allocated from this segment
virtual BlockNum getNumPagesOccupiedHighWater ()
Returns the max number of pages occupied by this segment instance.
SharedSegment const & getDelegateSegment () const
virtual BlockNum getNumPagesExtended ()
**Returns:**the number of incremental pages added to this instance of the segment
virtual PageId translateBlockId (BlockId)
Maps from a BlockId to a PageId in this segment.
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.
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 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 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 bool canFlushPage (CachePage &page)
Informs CacheImpl whether a dirty page can safely be flushed to disk.
SharedCache getCache () const
**Returns:**the Cache for this Segment
uint getFullPageSize () const
**Returns:**the full size of pages stored in this segment; this is the same as the size of underlying cache pages
uint getUsablePageSize () const
**Returns:**the full size of pages stored in this segment minus the size for any footer information stored at the end of each page
SharedSegment getTracingSegment ()
**Returns:**tracing segment associated with this segment if tracing is turned on; otherwise, returns the segment itself
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 ()
**Returns:**true if the segment supports versioning
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
**Returns:**whether the object has been closed
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
PageId getSegAllocPageId (uint iSegPage) const
Calculates the PageId of a particular SegmentAllocationNode.
PageId getExtentAllocPageId (ExtentNum extentNum) const
Calculates the PageId of a particular extent allocation node.
BlockNum makePageNum (ExtentNum extentNum, BlockNum iPageInExtent) const
Calculates a linear page number.
void splitPageId (PageId pageId, uint &iSegAlloc, ExtentNum &extentNum, BlockNum &iPageInExtent) const
Maps a linear PageId from this segment into the corresponding SegmentAllocationNode, extent allocation node, and extent-relative page index.
bool testPageId (PageId pageId, bool testAllocation, bool thisSegment)
Common implementation for isPageIdValid and isPageIdAllocated.
template
PageOwnerId getPageOwnerIdTemplate (PageId pageId, bool thisSegment)
Retrieves the ownerId corresponding to a page entry.
template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>
void freePageEntryTemplate (ExtentNum extentNum, BlockNum iPageInExtent)
Marks the page entry corresponding to a deallocated page as unallocated.
PageId getFirstSegAllocPageId () const
**Returns:**the PageId of the first SegmentAllocationNode
uint inferSegAllocCount ()
Infers the number of SegmentAllocationNodes from the size of the underlying segment.
void format ()
Formats allocation pages based on current size of underlying segment, marking all pages as deallocated.
template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>
void formatPageExtentsTemplate (SegmentAllocationNode &segAllocNode, ExtentNum &extentNum)
Formats each of the extents within a segment allocation node.
template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>
void formatExtentTemplate (ExtentAllocationNodeT &extentNode)
Formats one extent allocation.
PageId allocatePageIdFromSegment (PageOwnerId ownerId, SharedSegment allocNodeSegment)
Allocates a page without locking it into memory.
template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>
PageId allocateFromExtentTemplate (ExtentNum extentNum, PageOwnerId ownerId, SharedSegment allocNodeSegment)
Allocates a new page from an extent known to have space.
template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>
PageId allocateFromNewExtentTemplate (ExtentNum extentNum, PageOwnerId ownerId, SharedSegment allocNodeSegment)
Allocates a page from a new extent allocation node.
template<class ExtentAllocationNodeT, class PageEntryT>
PageId allocateFromLockedExtentTemplate (ExtentAllocationNodeT &extentNode, ExtentNum extentNum, PageOwnerId ownerId)
Allocates a new page from an extent known to have space, with the extent allocation node already locked.
template<class ExtentAllocationNodeT, class ExtentAllocLockT>
void setPageSuccessorTemplate (PageId pageId, PageId successorId, SharedSegment allocNodeSegment)
Sets the successor pageId for a page.
template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>
void getPageEntryCopyTemplate (PageId pageId, PageEntryT &pageEntryCopy, bool isAllocated, bool thisSegment)
Retrieves a copy of the page entry for a specified page.
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
BlockNum nPagesPerExtent
Number of pages in one extent, including the extent allocation node itself (so actual data capacity per extent is one less).
BlockNum nPagesPerSegAlloc
Number of pages mapped by one SegmentAllocationNode, including the SegmentAllocationNode itself.
ExtentNum nExtentsPerSegAlloc
Number of extents mapped by a full SegmentAllocationNode.
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 Types
typedef std::hash_map< PageId, SharedModifiedAllocationNode > ModifiedAllocationNodeMap
typedef ModifiedAllocationNodeMap::const_iterator NodeMapConstIter
Private Member Functions
template
PageId getTempAllocNodePage (PageId origNodePageId, bool isSegAllocNode)
Retrieves the pageId in the temporary segment of the page corresponding to an allocation node page.
PageId findAllocPageIdForRead (PageId origAllocNodePageId, SharedSegment &allocNodeSegment)
Determines whether an allocation node page has been modified.
void deferDeallocation (PageId pageId)
Marks a page entry as deallocation deferred in the temporary segment.
void updateExtentEntry (uint iSegAlloc, ExtentNum extentNum, uint allocationCount, bool commit)
Updates an extent entry corresponding to either a commit or rollback action of page allocations and/or deallocations.
void allocateAllocNodes (uint iSegAlloc, PageId nextPageId, ExtentNum extentNum)
Allocates a new SegmentAllocationNode and VersionedExtentAllocationNodes if they haven't been allocated yet.
void allocateExtAllocNodes (SegmentAllocationNode &segAllocNode, uint iSegAlloc, ExtentNum extentNum)
Allocates a new VersionedExtentAllocationNode if it hasn't been allocated yet.
void updatePageEntry (PageId pageId, ExtentNum extentNum, uint iPageInExtent, SharedModifiedPageEntry pModEntry, TxnId commitCsn, bool commit, SharedSegment pOrigSegment)
Updates a page entry by either copying a page entry from the temporary segment to the permanent one if we're committing the page entry, or the reverse if we're rolling it back.
void copyPageEntryFromTemp (PageId pageId, PageId origPageId, PageId tempPageId, BlockNum iPageInExtent, ModifiedPageEntry::ModType lastModType, TxnId commitCsn, PageOwnerId ownerId)
Copies a page entry from the temporary segment to the permanent one.
void copyPageEntryToTemp (PageId origPageId, PageId tempPageId, BlockNum iPageInExtent)
Copies a page entry from the permanent segment to the temporary one.
bool validateFreePageCount (PageId pageId)
Sanity checks the unallocated page count in a SegmentAllocationNode against the pages marked as unallocated in the corresponding VersionedExtentAllocationNode.
void freeTempPage (PageId origAllocNodePageId, PageId tempAllocNodePageId)
Frees a temporary page corresponding to an allocation node page, since all temporary updates to the page have either committed or rolled back.
TxnId getOldestTxnId (PageId pageId, TxnId oldestActiveTxnId, PageId &anchorPageId, std::hash_set< PageId > &deallocatedPageSet, bool &deallocateChain)
Determines the txnId corresponding to the oldest pageId in a page chain that can be deallocated, provided there are pages that can be deallocated.
void deallocateEntirePageChain (PageId pageId, TxnId oldestActiveTxnId, std::hash_set< PageId > &deallocatedPageSet)
Deallocates an entire page chain.
void deallocateSinglePage (PageId pageId, std::hash_set< PageId > &deallocatedPageSet)
Deallocates a single page and also discards it from the cache.
void deallocatePageChain (PageId anchorPageId, TxnId deallocationCsn, std::hash_set< PageId > &deallocatedPageSet)
Deallocates all old pages in a page chain.
bool validatePageChain (PageId anchorPageId)
Walks a page chain and ensures that all pages in the chain are allocated pages.
bool uncommittedDeallocation (PageId anchorPageId, std::hash_set< PageId > &deallocatedPageSet)
Determines if a page chain is in the process of being marked deallocation-deferred and has not yet been committed.
void skipDeferredDeallocations (PageId pageId, std::hash_set< PageId > &deallocatedPageSet)
Adds all pages in a page chain corresponding to deallocation-deferred pages to the set of pages that have been deallocated so we'll skip over them.
void updateTempPageEntry (PageId pageId, VersionedPageEntry const &pageEntry)
Updates a page entry in the temporary segment, if it exists.
void getCommittedPageEntryCopy (PageId pageId, VersionedPageEntry &pageEntryCopy)
Retrieves the committed copy of a page entry for a specified page.
bool isPageIdAllocateCommitted (PageId pageId)
Determines if a page corresponds to a committed allocation.
void chainPageEntries (PageId pageId, PageId versionChainId, PageId successorId, bool thisSegment)
Chains one page to another, updating either the corresponding permanent page entry or the temporary one.
void locateDataPages (SharedSegPageBackupRestoreDevice pBackupDevice, TxnId lowerBoundCsn, TxnId upperBoundCsn, bool isBackup, bool volatile const &abortFlag)
void checkAbort (bool volatile const &abortFlag)
Determines whether the abort flag is set.
PageOwnerId makeDeallocatedPageOwnerId (TxnId txnId)
Constructs a pageOwnerId corresponding to a deallocation-deferred page.
bool isDeallocatedPageOwnerId (PageOwnerId pageOwnerId)
Determines whether a pageOwnerId corresponds to a deallocation-deferred page.
TxnId getDeallocatedTxnId (PageOwnerId pageOwnerId)
Extracts the id corresponding to the txn that deallocated a page from the page's pageOwnerId.
virtual bool isPageIdValid (PageId pageId)
Tests whether the given PageId has valid contents (either an allocated data page or an allocation map page).
virtual PageId getSegAllocPageIdForWrite (PageId origSegAllocPageId)
Retrieves the pageId of the SegmentAllocationNode that should be updated when updates are made to that node.
virtual void undoSegAllocPageWrite (PageId segAllocPageId)
Indicates that no new pages were allocated from extents within a SegmentAllocationNode.
virtual PageId getExtAllocPageIdForWrite (ExtentNum extentNum)
Retrieves the pageId of the extent allocation node that should be updated when updates are made to that node.
virtual PageId allocateFromExtent (ExtentNum extentNum, PageOwnerId ownerId)
Allocates a new page from an extent known to have space.
virtual void formatPageExtents (SegmentAllocationNode &segAllocNode, ExtentNum &extentNum)
Formats each of the extents within a segment allocation node.
virtual PageId allocateFromNewExtent (ExtentNum extentNum, PageOwnerId ownerId)
Allocates a page from a new extent allocation node.
virtual void freePageEntry (ExtentNum extentNum, BlockNum iPageInExtent)
Marks the page entry corresponding to a deallocated page as unallocated.
virtual void markPageEntryUnused (PageEntry &pageEntry)
Marks a page entry as unused.
virtual PageOwnerId getPageOwnerId (PageId pageId, bool thisSegment)
Retrieves the ownerId corresponding to a page entry.
virtual PageId getSegAllocPageIdForRead (PageId origSegAllocPageId, SharedSegment &allocNodeSegment)
Retrieves the actual pageId corresponding to the SegmentAllocationNode that should be accessed when reading from the node.
virtual PageId getExtAllocPageIdForRead (ExtentNum extentNum, SharedSegment &allocNodeSegment)
Retrieves the actual pageId corresponding to the extent allocation node that should be accessed when reading from the node.
virtual void getPageEntryCopy (PageId pageId, PageEntry &pageEntryCopy, bool isAllocated, bool thisSegment)
Retrieves a copy of the page entry for a specified page.
Private Attributes
ModifiedAllocationNodeMap allocationNodeMap
Maps allocation node pages to the modified copy of the node that contains uncommitted page modifications.
SXMutex mapMutex
Mutex used to protect allocationNodeMap.
SXMutex deallocationMutex
Mutex that prevents multiple deallocations from occuring concurrently.
SharedSegment pTempSegment
Segment used to allocate pages to store uncommitted modifications to segment and extent allocation node pages.
Friends
class SegmentFactory

Detailed Description

VersionedRandomAllocationSegment refines RandomAllocationSegmentBase, defining a VersionedExtentAllocationNode where each page entry within the segment is versioned.

When modifications are made to either VersionedExtentAllocationNodes or SegmentAllocationNodes, the changes are reflected in pages originating from a temporary segment. The changes are only copied back to the permanent segment when a transaction commits; changes are thrown away on a rollback.

Page deallocations are handled differently. Deallocated pages are not actually deallocated, but instead are marked as deallocation-deferred. This makes the page unusable but not yet available for re-allocation. A deallocation-deferred page is deallocated by calling the methods getOldPageIds() and deallocateOldPages(). The former finds pages that need to be deallocated, while the latter does the actual deallocation. When the deallocations are done, the modifications are made directly in the permanent segment. The two methods should be called in a loop, one after the other, until getOldPageIds() can no longer find any old pages.

Definition at line 138 of file VersionedRandomAllocationSegment.h.


Member Typedef Documentation


Member Enumeration Documentation

Enumeration of the possible orderings of PageIds returned from allocatePageId.

The enumeration is from weakest to strongest ordering, and should not be changed.

Enumerator:

RANDOM_ALLOCATION Random order.
ASCENDING_ALLOCATION Later calls always return greater PageIds, but not necessarily consecutively.
CONSECUTIVE_ALLOCATION PageIds are returned in consecutive ascending order of BlockNum; the DeviceId is always the same.
LINEAR_ALLOCATION PageIds are returned in consecutive ascending order starting with 0; all bytes of the PageId are used (no division into DeviceId/BlockNum), yielding maximum range.

Definition at line 105 of file Segment.h.


Constructor & Destructor Documentation

VersionedRandomAllocationSegment::VersionedRandomAllocationSegment ( SharedSegment delegateSegment,
SharedSegment pTempSegmentInit
) [explicit]

Member Function Documentation

template

PageId VersionedRandomAllocationSegment::getTempAllocNodePage ( PageId origNodePageId,
bool isSegAllocNode
) [private]

Retrieves the pageId in the temporary segment of the page corresponding to an allocation node page.

If the page doesn't yet exist in the temporary segment, creates it.

Assumes that the pageEntry will be updated. Therefore, it also increments the update count corresponding to the pageEntry.

Parameters:

origNodePageId pageId of the node in the permanent segment
isSegAllocNode true if the page being retrieved is a segment allocation node

Returns:

pageId of node in the temporary segment

Definition at line 82 of file VersionedRandomAllocationSegmentImpl.h.

References allocationNodeMap, Segment::getTracingSegment(), mapMutex, Segment::pCache, and pTempSegment.

00085 { 00086 SXMutexExclusiveGuard mapGuard(mapMutex); 00087 00088 PageId tempNodePageId; 00089 SharedModifiedAllocationNode pModAllocNode; 00090 00091
00092
00093
00094
00095 NodeMapConstIter iter = allocationNodeMap.find(origNodePageId); 00096 if (iter == allocationNodeMap.end()) { 00097
00098
00099 SegmentAccessor tempAccessor(pTempSegment, pCache); 00100 AllocationLockT tempAllocLock(tempAccessor); 00101 tempNodePageId = tempAllocLock.allocatePage(); 00102 00103 SegmentAccessor selfAccessor(getTracingSegment(), pCache); 00104 AllocationLockT allocLock(selfAccessor); 00105 allocLock.lockShared(origNodePageId); 00106 00107 memcpy( 00108 tempAllocLock.getPage().getWritableData(), 00109 allocLock.getPage().getReadableData(), 00110 pTempSegment->getUsablePageSize()); 00111 00112
00113 pModAllocNode = 00114 SharedModifiedAllocationNode(new ModifiedAllocationNode()); 00115 pModAllocNode->tempPageId = tempNodePageId; 00116 pModAllocNode->updateCount = 0; 00117 pModAllocNode->isSegAllocNode = isSegAllocNode; 00118 } else { 00119 pModAllocNode = iter->second; 00120 tempNodePageId = pModAllocNode->tempPageId; 00121 } 00122 00123
00124 pModAllocNode->updateCount++; 00125 00126 if (iter == allocationNodeMap.end()) { 00127 allocationNodeMap.insert( 00128 ModifiedAllocationNodeMap::value_type( 00129 origNodePageId, 00130 pModAllocNode)); 00131 } 00132 00133 return tempNodePageId; 00134 }

PageId VersionedRandomAllocationSegment::findAllocPageIdForRead ( PageId origAllocNodePageId,
SharedSegment & allocNodeSegment
) [private]

Determines whether an allocation node page has been modified.

If it has been, passes back the temporary pageId corresponding to the page. Otherwise, the original pageId is passed back.

This method assumes that the caller has already acquired a shared mutex on allocationNodeMap.

Parameters:

origAllocNodePageId pageId of the node in the permanent segment
[out] allocNodeSegment the temp segment if the node has been modified; otherwise, the segment itself

Returns:

the pageId of the node in the temp segment if the page has been modified; otherwise, the original pageId

Definition at line 107 of file VersionedRandomAllocationSegment.cpp.

References allocationNodeMap, Segment::getTracingSegment(), SXMutex::isLocked(), LOCKMODE_S, mapMutex, and pTempSegment.

Referenced by getExtAllocPageIdForRead(), and getSegAllocPageIdForRead().

void VersionedRandomAllocationSegment::deferDeallocation ( PageId pageId ) [private]

Marks a page entry as deallocation deferred in the temporary segment.

Once the txn commits, the permanent entry will also be marked so it can then be deallocated by an ALTER SYSTEM DEALLOCATE OLD statement.

Parameters:

pageId the pageId of the page entry to be marked

Definition at line 183 of file VersionedRandomAllocationSegment.cpp.

References getExtAllocPageIdForWrite(), SegNodeLock< Node >::getNodeForWrite(), VersionedExtentAllocationNode::getPageEntry(), isDeallocatedPageOwnerId(), SegPageLock::lockExclusive(), makeDeallocatedPageOwnerId(), PageEntry::ownerId, Segment::pCache, pTempSegment, RandomAllocationSegmentBase::splitPageId(), and UNALLOCATED_PAGE_OWNER_ID.

Referenced by deallocatePageRange().

void VersionedRandomAllocationSegment::updateExtentEntry ( uint iSegAlloc,
ExtentNum extentNum,
uint allocationCount,
bool commit
) [private]

Updates an extent entry corresponding to either a commit or rollback action of page allocations and/or deallocations.

In the case of a commit, the permanent extent entry is updated. In the case of a rollback, the changes made in the temporary extent entry are thrown away.

This method assumes that the caller has already acquired an exclusive mutex on allocationNodeMap.

Parameters:

iSegAlloc 0-based index of containing SegmentAllocationNode
extentNum absolute 0-based extent number of containing extent allocation node
allocationCount the total number of allocations and deallocations made to a page, which corresponds to the number of updates performed on the extent entry
commit if true, updates correspond to a commit; else updates correspond to a rollback

Definition at line 559 of file VersionedRandomAllocationSegment.cpp.

References allocationNodeMap, SegmentAllocationNode::getExtentEntry(), SegNodeLock< Node >::getNodeForWrite(), RandomAllocationSegmentBase::getSegAllocPageId(), Segment::getTracingSegment(), SXMutex::isLocked(), SegPageLock::lockExclusive(), LOCKMODE_X, mapMutex, RandomAllocationSegmentBase::nExtentsPerSegAlloc, SegmentAllocationNode::ExtentEntry::nUnallocatedPages, Segment::pCache, and pTempSegment.

Referenced by updateAllocNodes().

void VersionedRandomAllocationSegment::allocateAllocNodes ( uint iSegAlloc,
PageId nextPageId,
ExtentNum extentNum
) [private]

Allocates a new SegmentAllocationNode and VersionedExtentAllocationNodes if they haven't been allocated yet.

Also recursively allocates predecessor SegmentAllocationNodes, as needed.

Parameters:

iSegAlloc 0-based index corresponding to the SegmentAllocationNode that needs to be allocated
nextPageId the pageId to be set as the nextSegAllocPageId for the SegmentAllocationNode being allocated
extentNum absolute 0-based extent number of the extent allocation node that needs to be allocated

Definition at line 605 of file VersionedRandomAllocationSegment.cpp.

References allocateExtAllocNodes(), SegNodeLock< Node >::checkMagicNumber(), SegNodeLock< Node >::getNodeForWrite(), RandomAllocationSegmentBase::getSegAllocPageId(), Segment::getTracingSegment(), SegPageLock::lockExclusive(), SegmentAllocationNode::nExtents, SegmentAllocationNode::nextSegAllocPageId, RandomAllocationSegmentBase::nPagesPerExtent, SegmentAllocationNode::nPagesPerExtent, NULL_PAGE_ID, Segment::pCache, and SegNodeLock< Node >::setMagicNumber().

Referenced by updateAllocNodes().

Updates a page entry by either copying a page entry from the temporary segment to the permanent one if we're committing the page entry, or the reverse if we're rolling it back.

This method assumes that the caller has already acquired an exclusive mutex on allocationNodeMap.

Parameters:

pageId pageId of the page entry
extentNum absolute 0-based extent number of the extent allocation node corresponding to the page entry
iPageInExtent 0-based index of page in extent
pModEntry information about the modified page entry
commitCsn sequence number to write into the pageEntry on a commit if the pageEntry corresponds to a page allocation; otherwise, set to NULL_TXN_ID
commit true if the updates correspond to a commit
pOrigSegment the originating segment that modified the page entry that needs to be updated

Definition at line 455 of file VersionedRandomAllocationSegment.cpp.

References ModifiedPageEntry::ALLOCATED, allocationNodeMap, copyPageEntryFromTemp(), copyPageEntryToTemp(), RandomAllocationSegmentBase::getExtentAllocPageId(), SXMutex::isLocked(), LOCKMODE_X, mapMutex, and Segment::pCache.

Referenced by updateAllocNodes().

void VersionedRandomAllocationSegment::copyPageEntryFromTemp ( PageId pageId,
PageId origPageId,
PageId tempPageId,
BlockNum iPageInExtent,
ModifiedPageEntry::ModType lastModType,
TxnId commitCsn,
PageOwnerId ownerId
) [private]

Copies a page entry from the temporary segment to the permanent one.

Parameters:

pageId pageId of the page entry
origPageId pageId of the extent page in the permanent segment
tempPageId pageId of the extent page in the temporary segment
iPageInExtent 0-based index of page in extent
lastModType whether the page was last allocated or deallocated
commitCsn sequence number to write into the pageEntry for page allocations
ownerId the ownerId to set in the pageEntry for page allocations

Definition at line 496 of file VersionedRandomAllocationSegment.cpp.

References ModifiedPageEntry::ALLOCATED, VersionedPageEntry::allocationCsn, ModifiedPageEntry::DEALLOCATED, SegNodeLock< Node >::getNodeForWrite(), VersionedExtentAllocationNode::getPageEntry(), Segment::getTracingSegment(), isDeallocatedPageOwnerId(), SegPageLock::lockExclusive(), makeDeallocatedPageOwnerId(), PageEntry::ownerId, Segment::pCache, pTempSegment, and UNCOMMITTED_PAGE_OWNER_ID.

Referenced by updatePageEntry().

void VersionedRandomAllocationSegment::copyPageEntryToTemp ( PageId origPageId,
PageId tempPageId,
BlockNum iPageInExtent
) [private]
bool VersionedRandomAllocationSegment::validateFreePageCount ( PageId pageId ) [private]

Sanity checks the unallocated page count in a SegmentAllocationNode against the pages marked as unallocated in the corresponding VersionedExtentAllocationNode.

Parameters:

pageId pageId corresponding to the allocation nodes to be verified

Returns:

true if the counts match

Definition at line 670 of file VersionedRandomAllocationSegment.cpp.

References RandomAllocationSegmentBase::getExtentAllocPageId(), SegmentAllocationNode::getExtentEntry(), SegNodeLock< Node >::getNodeForRead(), VersionedExtentAllocationNode::getPageEntry(), RandomAllocationSegmentBase::getSegAllocPageId(), Segment::getTracingSegment(), SegPageLock::lockExclusive(), SegPageLock::lockShared(), RandomAllocationSegmentBase::nExtentsPerSegAlloc, RandomAllocationSegmentBase::nPagesPerExtent, SegmentAllocationNode::ExtentEntry::nUnallocatedPages, Segment::pCache, RandomAllocationSegmentBase::splitPageId(), and UNALLOCATED_PAGE_OWNER_ID.

void VersionedRandomAllocationSegment::freeTempPage ( PageId origAllocNodePageId,
PageId tempAllocNodePageId
) [private]
TxnId VersionedRandomAllocationSegment::getOldestTxnId ( PageId pageId,
TxnId oldestActiveTxnId,
PageId & anchorPageId,
std::hash_set< PageId > & deallocatedPageSet,
bool & deallocateChain
) [private]

Determines the txnId corresponding to the oldest pageId in a page chain that can be deallocated, provided there are pages that can be deallocated.

If pages in the chain are marked deallocation-deferred and are no longer being referenced, then set the flag indicating that the entire page chain should be deallocated.

Parameters:

pageId a pageId in a page chain corresponding to an old page
oldestActiveTxnId the txnId of the current, oldest active txnId; used as the threshhold for determining which pages are old
[out] anchorPageId the pageId of the anchor in the page chain
[in,out] deallocatedPageSet set of pages that have already been deallocated or need to be skipped because they can't be deallocated
[out] deallocateChain set to true if the entire page chain needs to be deallocated because the pages are marked as deallocation- deferred and are no longer referenced

Returns:

the txnId one larger than the commit sequence number on the oldest page that can be deallocated or NULL_TXN_ID if the page chain should be left as is (either because there's nothing to deallocate, or the page chain contains deallocation-deferred pages)

Definition at line 849 of file VersionedRandomAllocationSegment.cpp.

References VersionedPageEntry::allocationCsn, getDeallocatedTxnId(), RandomAllocationSegmentBase::getExtentAllocPageId(), SegNodeLock< Node >::getNodeForRead(), VersionedExtentAllocationNode::getPageEntry(), Segment::getTracingSegment(), isDeallocatedPageOwnerId(), isPageIdAllocateCommitted(), SegPageLock::lockShared(), NULL_PAGE_ID, NULL_TXN_ID, PageEntry::ownerId, Segment::pCache, skipDeferredDeallocations(), RandomAllocationSegmentBase::splitPageId(), UNCOMMITTED_PAGE_OWNER_ID, and VersionedPageEntry::versionChainPageId.

Referenced by deallocateOldPages().

void VersionedRandomAllocationSegment::deallocateEntirePageChain ( PageId pageId,
TxnId oldestActiveTxnId,
std::hash_set< PageId > & deallocatedPageSet
) [private]
void VersionedRandomAllocationSegment::deallocateSinglePage ( PageId pageId,
std::hash_set< PageId > & deallocatedPageSet
) [private]

Deallocates a single page and also discards it from the cache.

This method assumes that the caller has already acquired an exclusive mutex on allocationNodeMap.

Parameters:

pageId pageId of the page to be deallocated
[in,out] deallocatedPageSet set of pageIds deallocated

Definition at line 985 of file VersionedRandomAllocationSegment.cpp.

References allocationNodeMap, copyPageEntryToTemp(), RandomAllocationSegmentBase::deallocatePageRange(), RandomAllocationSegmentBase::getExtentAllocPageId(), SegmentAllocationNode::getExtentEntry(), SegNodeLock< Node >::getNodeForWrite(), RandomAllocationSegmentBase::getSegAllocPageId(), SXMutex::isLocked(), SegPageLock::lockExclusive(), LOCKMODE_X, mapMutex, RandomAllocationSegmentBase::nExtentsPerSegAlloc, SegmentAllocationNode::ExtentEntry::nUnallocatedPages, Segment::pCache, pTempSegment, and RandomAllocationSegmentBase::splitPageId().

Referenced by deallocateEntirePageChain(), and deallocatePageChain().

void VersionedRandomAllocationSegment::deallocatePageChain ( PageId anchorPageId,
TxnId deallocationCsn,
std::hash_set< PageId > & deallocatedPageSet
) [private]

Deallocates all old pages in a page chain.

Parameters:

anchorPageId pageId of the anchor page in the page chain
deallocationCsn the open, upper bound on the allocationCsn corresponding to pages that should be deallocated
[in,out] deallocatedPageSet set of pageIds corresponding to pages that have been deallocated

Definition at line 1029 of file VersionedRandomAllocationSegment.cpp.

References VersionedPageEntry::allocationCsn, chainPageEntries(), deallocateSinglePage(), getCommittedPageEntryCopy(), isDeallocatedPageOwnerId(), NULL_PAGE_ID, PageEntry::ownerId, UNALLOCATED_PAGE_OWNER_ID, uncommittedDeallocation(), updateTempPageEntry(), and VersionedPageEntry::versionChainPageId.

Referenced by deallocateOldPages().

bool VersionedRandomAllocationSegment::validatePageChain ( PageId anchorPageId ) [private]
bool VersionedRandomAllocationSegment::uncommittedDeallocation ( PageId anchorPageId,
std::hash_set< PageId > & deallocatedPageSet
) [private]

Determines if a page chain is in the process of being marked deallocation-deferred and has not yet been committed.

This method assumes that the caller has already acquired an exclusive mutex on allocationNodeMap.

Parameters:

anchorPageId pageId of the anchor page in a chain
[in,out] deallocatedPageSet set of pages that have been deallocated or need to be skipped

Returns:

true if the anchor page entry is marked as deallocation-deferred in its temporary page entry

Definition at line 1092 of file VersionedRandomAllocationSegment.cpp.

References allocationNodeMap, getDeallocatedTxnId(), RandomAllocationSegmentBase::getExtentAllocPageId(), SegNodeLock< Node >::getNodeForRead(), VersionedExtentAllocationNode::getPageEntry(), isDeallocatedPageOwnerId(), SXMutex::isLocked(), LOCKMODE_X, SegPageLock::lockShared(), mapMutex, PageEntry::ownerId, Segment::pCache, pTempSegment, skipDeferredDeallocations(), and RandomAllocationSegmentBase::splitPageId().

Referenced by deallocatePageChain().

void VersionedRandomAllocationSegment::skipDeferredDeallocations ( PageId pageId,
std::hash_set< PageId > & deallocatedPageSet
) [private]
void VersionedRandomAllocationSegment::updateTempPageEntry ( PageId pageId,
VersionedPageEntry const & pageEntry
) [private]

Updates a page entry in the temporary segment, if it exists.

This method assumes that the caller has already acquired an exclusive mutex on allocationNodeMap.

Parameters:

pageId of the page entry that needs to be updated
[in] pageEntry source page entry

Definition at line 1165 of file VersionedRandomAllocationSegment.cpp.

References allocationNodeMap, RandomAllocationSegmentBase::getExtentAllocPageId(), SegNodeLock< Node >::getNodeForWrite(), VersionedExtentAllocationNode::getPageEntry(), SXMutex::isLocked(), SegPageLock::lockExclusive(), LOCKMODE_X, mapMutex, Segment::pCache, pTempSegment, and RandomAllocationSegmentBase::splitPageId().

Referenced by deallocatePageChain().

void VersionedRandomAllocationSegment::getCommittedPageEntryCopy ( PageId pageId,
VersionedPageEntry & pageEntryCopy
) [private]
bool VersionedRandomAllocationSegment::isPageIdAllocateCommitted ( PageId pageId ) [private]
void VersionedRandomAllocationSegment::chainPageEntries ( PageId pageId,
PageId versionChainId,
PageId successorId,
bool thisSegment
) [private]

Chains one page to another, updating either the corresponding permanent page entry or the temporary one.

Also may set the successorId of the first page.

Parameters:

pageId the pageId of the page that will be chained to the page corresponding to the second parameter
versionChainId the pageId of the page to be chained from the first parameter
successorId if not set to NULL_PAGE_ID, the successorId of the pageEntry corresponding to the first parameter is set
thisSegment if true, make updates in the permanent page entry rather than the temporary one

Definition at line 352 of file VersionedRandomAllocationSegment.cpp.

References getExtAllocPageIdForWrite(), RandomAllocationSegmentBase::getExtentAllocPageId(), SegNodeLock< Node >::getNodeForWrite(), VersionedExtentAllocationNode::getPageEntry(), Segment::getTracingSegment(), isPageIdAllocated(), SegPageLock::lockExclusive(), NULL_PAGE_ID, Segment::pCache, pTempSegment, RandomAllocationSegmentBase::splitPageId(), PageEntry::successorId, and VersionedPageEntry::versionChainPageId.

Referenced by chainPageEntries(), SnapshotRandomAllocationSegment::chainPageEntries(), and deallocatePageChain().

void VersionedRandomAllocationSegment::locateDataPages ( SharedSegPageBackupRestoreDevice pBackupDevice,
TxnId lowerBoundCsn,
TxnId upperBoundCsn,
bool isBackup,
bool volatile const & abortFlag
) [private]

Definition at line 1298 of file VersionedRandomAllocationSegment.cpp.

References VersionedPageEntry::allocationCsn, checkAbort(), RandomAllocationSegmentBase::getExtentAllocPageId(), SegmentAllocationNode::getExtentEntry(), Segment::getFullPageSize(), Segment::getLinearPageId(), SegNodeLock< Node >::getNodeForRead(), SegPageLock::getPage(), VersionedExtentAllocationNode::getPageEntry(), CachePage::getReadableData(), RandomAllocationSegmentBase::getSegAllocPageId(), Segment::getTracingSegment(), SegPageLock::lockShared(), RandomAllocationSegmentBase::makePageNum(), SegmentAllocationNode::nExtents, RandomAllocationSegmentBase::nExtentsPerSegAlloc, SegmentAllocationNode::nextSegAllocPageId, RandomAllocationSegmentBase::nPagesPerExtent, NULL_PAGE_ID, NULL_TXN_ID, SegmentAllocationNode::ExtentEntry::nUnallocatedPages, PageEntry::ownerId, Segment::pCache, RandomAllocationSegmentBase::translatePageId(), UNALLOCATED_PAGE_OWNER_ID, and SegPageLock::unlock().

Referenced by backupDataPages(), and restoreFromBackup().

void VersionedRandomAllocationSegment::checkAbort ( bool volatile const & abortFlag ) [private]
PageOwnerId VersionedRandomAllocationSegment::makeDeallocatedPageOwnerId ( TxnId txnId ) [inline, private]
bool VersionedRandomAllocationSegment::isDeallocatedPageOwnerId ( PageOwnerId pageOwnerId ) [inline, private]

Determines whether a pageOwnerId corresponds to a deallocation-deferred page.

Parameters:

pageOwnerId the pageOwnerId under question

Returns:

true if the pageOwnerId corresponds to a deallocation-deferred page

Definition at line 143 of file VersionedRandomAllocationSegmentImpl.h.

References ANON_PAGE_OWNER_ID, DEALLOCATED_PAGE_OWNER_ID_MASK, and opaqueToInt().

Referenced by copyPageEntryFromTemp(), deallocateEntirePageChain(), deallocatePageChain(), deferDeallocation(), getDeallocatedTxnId(), getOldestTxnId(), getOldPageIds(), skipDeferredDeallocations(), and uncommittedDeallocation().

TxnId VersionedRandomAllocationSegment::getDeallocatedTxnId ( PageOwnerId pageOwnerId ) [inline, private]
bool VersionedRandomAllocationSegment::isPageIdValid ( PageId pageId ) [private, virtual]
PageId VersionedRandomAllocationSegment::getSegAllocPageIdForWrite ( PageId origSegAllocPageId ) [private, virtual]
void VersionedRandomAllocationSegment::undoSegAllocPageWrite ( PageId segAllocPageId ) [private, virtual]
PageId VersionedRandomAllocationSegment::getExtAllocPageIdForWrite ( ExtentNum extentNum ) [private, virtual]
PageId VersionedRandomAllocationSegment::allocateFromExtent ( ExtentNum extentNum,
PageOwnerId ownerId
) [private, virtual]
PageId VersionedRandomAllocationSegment::allocateFromNewExtent ( ExtentNum extentNum,
PageOwnerId ownerId
) [private, virtual]
void VersionedRandomAllocationSegment::freePageEntry ( ExtentNum extentNum,
BlockNum iPageInExtent
) [private, virtual]
void VersionedRandomAllocationSegment::markPageEntryUnused ( PageEntry & pageEntry ) [private, virtual]
PageOwnerId VersionedRandomAllocationSegment::getPageOwnerId ( PageId pageId,
bool thisSegment
) [private, virtual]

Retrieves the ownerId corresponding to a page entry.

See also:

getPageOwnerIdTemplate()

Parameters:

pageId PageId of the page whose owner we are retrieving
thisSegment if true, retrieve page entry from this segment; otherwise, retrieve it from an alternative segment

Returns:

ownerId

Implements RandomAllocationSegmentBase.

Definition at line 271 of file VersionedRandomAllocationSegment.cpp.

00274 { 00275 return getPageOwnerIdTemplate(pageId, thisSegment); 00276 }

PageId VersionedRandomAllocationSegment::getSegAllocPageIdForRead ( PageId origSegAllocPageId,
SharedSegment & allocNodeSegment
) [private, virtual]
PageId VersionedRandomAllocationSegment::getExtAllocPageIdForRead ( ExtentNum extentNum,
SharedSegment & allocNodeSegment
) [private, virtual]
void VersionedRandomAllocationSegment::getPageEntryCopy ( PageId pageId,
PageEntry & pageEntryCopy,
bool isAllocated,
bool thisSegment
) [private, virtual]
void VersionedRandomAllocationSegment::getLatestPageEntryCopy ( PageId pageId,
VersionedPageEntry & pageEntryCopy
)
void VersionedRandomAllocationSegment::initPageEntry ( PageId pageId,
PageId versionChainId,
TxnId allocationCsn
)

Initializes the versioning fields in a pageEntry for a specified page.

Parameters:

pageId pageId of the page whose PageEntry we are setting
versionChainId version chain pageId to be set
allocationCsn commit sequence number to be set

Definition at line 317 of file VersionedRandomAllocationSegment.cpp.

References VersionedPageEntry::allocationCsn, getExtAllocPageIdForWrite(), SegNodeLock< Node >::getNodeForWrite(), VersionedExtentAllocationNode::getPageEntry(), isPageIdAllocated(), SegPageLock::lockExclusive(), NULL_TXN_ID, PageEntry::ownerId, Segment::pCache, pTempSegment, RandomAllocationSegmentBase::splitPageId(), UNALLOCATED_PAGE_OWNER_ID, and VersionedPageEntry::versionChainPageId.

Referenced by SnapshotRandomAllocationSegment::allocatePageId().

void VersionedRandomAllocationSegment::chainPageEntries ( PageId pageId,
PageId versionChainId,
PageId successorId
)

Chains one page to another, updating the corresponding page entry in the temp segment page.

Also may set the successorId of the first page.

Parameters:

pageId the pageId of the page that will be chained to the page corresponding to the second parameter
versionChainId the pageId of the page to be chained from the first parameter
successorId if not set to NULL_PAGE_ID, the successorId of the pageEntry corresponding to the first parameter is set

Definition at line 344 of file VersionedRandomAllocationSegment.cpp.

References chainPageEntries().

00348 { 00349 chainPageEntries(pageId, versionChainId, successorId, false); 00350 }

void VersionedRandomAllocationSegment::updateAllocNodes ( ModifiedPageEntryMap const & modifiedPageEntryMap,
TxnId commitCsn,
bool commit,
SharedSegment pOrigSegment
)

Updates the permanent allocation nodes to reflect changes currently in the temporary segment, or vice versa if the updates correspond to a rollback.

Parameters:

modifiedPageEntryMap map containing information on page entries that have been modified
commitCsn sequence number to write into the pageEntry on a commit if the pageEntry corresponds to a page allocation; otherwise, set to NULL_TXN_ID
commit true if the updates correspond to a commit
pOrigSegment the originating segment that modified the allocation nodes that need to be updated

Definition at line 389 of file VersionedRandomAllocationSegment.cpp.

References allocateAllocNodes(), ModifiedPageEntry::ALLOCATED, allocationNodeMap, ModifiedPageEntry::DEALLOCATED, freeTempPage(), isPageIdAllocated(), mapMutex, NULL_PAGE_ID, RandomAllocationSegmentBase::splitPageId(), updateExtentEntry(), and updatePageEntry().

Referenced by SnapshotRandomAllocationSegment::commitChanges(), and SnapshotRandomAllocationSegment::rollbackChanges().

00394 { 00395 SXMutexExclusiveGuard mapGuard(mapMutex); 00396 00397 for (ModifiedPageEntryMapIter iter = modifiedPageEntryMap.begin(); 00398 iter != modifiedPageEntryMap.end(); 00399 iter++) 00400 { 00401 PageId pageId = iter->first; 00402 SharedModifiedPageEntry pModEntry = iter->second; 00403 00404 assert(isPageIdAllocated(pageId)); 00405 00406 ExtentNum extentNum; 00407 BlockNum iPageInExtent; 00408 uint iSegAlloc; 00409 splitPageId(pageId, iSegAlloc, extentNum, iPageInExtent); 00410 assert(iPageInExtent); 00411 00412
00413
00414 allocateAllocNodes(iSegAlloc, NULL_PAGE_ID, extentNum); 00415 00416
00417
00418
00419 if ((pModEntry->lastModType == ModifiedPageEntry::ALLOCATED) || 00420 (pModEntry->lastModType == ModifiedPageEntry::DEALLOCATED)) 00421 { 00422 updateExtentEntry( 00423 iSegAlloc, 00424 extentNum, 00425 pModEntry->allocationCount, 00426 commit); 00427 } 00428 updatePageEntry( 00429 pageId, 00430 extentNum, 00431 iPageInExtent, 00432 pModEntry, 00433 commitCsn, 00434 commit, 00435 pOrigSegment); 00436 } 00437 00438
00439
00440
00441
00442 ModifiedAllocationNodeMap::iterator iter = allocationNodeMap.begin(); 00443 while (iter != allocationNodeMap.end()) { 00444 SharedModifiedAllocationNode pModNode = iter->second; 00445 if (pModNode->updateCount == 0 && !pModNode->isSegAllocNode) { 00446 PageId pageId = iter->first; 00447 iter++; 00448 freeTempPage(pageId, pModNode->tempPageId); 00449 } else { 00450 iter++; 00451 } 00452 } 00453 }

| SXMutex & VersionedRandomAllocationSegment::getDeallocationMutex | ( | | ) | | ------------------------------------------------------------------------------------- | - | | - |

bool VersionedRandomAllocationSegment::getOldPageIds ( uint & iSegAlloc,
ExtentNum & extentNum,
TxnId oldestActiveTxnId,
uint numPages,
PageSet & oldPageSet
)

Retrieves a batch of pageIds corresponding either to old snapshot pages that are no longer being referenced or pages marked for deallocation.

The number of pageIds returned must be at least some value as specified by an input parameter, unless there are no more pages left to deallocate. The old pages are located starting at a location specified by the index of a SegmentAllocationNode and the offset of an extent within that node. Upon exit, those parameters are replaced with the location where the search should be resumed the next time the method is called.

Once a batch of pages have been identified, deallocateOldPages() should then be called. After deallocating that set of pages, getOldPageIds() should be called again to identify the next set of old pages.

Parameters:

[in,out] iSegAlloc on input, 0-based index of starting SegmentAllocationNode; on exit, the index where the search should be resumed the next time this method is called
[in,out] extentNum on input, the 0-based extent number of the extent from which to start the search for old pages; upon exit, the extent number where the search should be resumed the next time this method is called
oldestActiveTxnId the txnId of the current, oldest active txnId; used as the threshhold for determining which pages are old
numPages lower bound on the number of pages to pass back, unless there are no more pages to deallocate
[out] oldPageSet set of old pageIds found

Returns:

true if additional pages need to be searched; false if reached end of search

Definition at line 714 of file VersionedRandomAllocationSegment.cpp.

References getDeallocatedTxnId(), RandomAllocationSegmentBase::getExtentAllocPageId(), SegmentAllocationNode::getExtentEntry(), Segment::getLinearPageId(), SegNodeLock< Node >::getNodeForRead(), VersionedExtentAllocationNode::getPageEntry(), RandomAllocationSegmentBase::getSegAllocPageId(), Segment::getTracingSegment(), isDeallocatedPageOwnerId(), SegPageLock::lockShared(), RandomAllocationSegmentBase::makePageNum(), SegmentAllocationNode::nExtents, RandomAllocationSegmentBase::nExtentsPerSegAlloc, SegmentAllocationNode::nextSegAllocPageId, RandomAllocationSegmentBase::nPagesPerExtent, NULL_PAGE_ID, SegmentAllocationNode::ExtentEntry::nUnallocatedPages, Segment::pCache, and UNALLOCATED_PAGE_OWNER_ID.

Referenced by SnapshotSegmentTest::deallocateOldPages(), and Database::deallocateOldPages().

void VersionedRandomAllocationSegment::deallocateOldPages ( PageSet const & oldPageSet,
TxnId oldestActiveTxnId
)

Deallocates an old set of pages and updates the version chain that the pages may be a part of.

Old pages are identified by calling getOldPageIds().

The actual deallocation of pages is in a separate method to minimize the duration the deallocation mutex is held.

Parameters:

[in] oldPageSet set of old pageIds that need to be deallocated
oldestActiveTxnId the txnId of the current, oldest active txnId; used as the threshhold for determining which pages should be deallocated

Definition at line 794 of file VersionedRandomAllocationSegment.cpp.

References deallocateEntirePageChain(), deallocatePageChain(), deallocationMutex, getOldestTxnId(), isPageIdAllocateCommitted(), mapMutex, and NULL_TXN_ID.

Referenced by SnapshotSegmentTest::deallocateOldPages(), and Database::deallocateOldPages().

00797 { 00798 SXMutexExclusiveGuard deallocationGuard(deallocationMutex); 00799 SXMutexExclusiveGuard mapGuard(mapMutex); 00800 00801 std::hash_set deallocatedPageSet; 00802 for (PageSetConstIter pageIter = oldPageSet.begin(); 00803 pageIter != oldPageSet.end(); pageIter++) 00804 { 00805 PageId pageId = *pageIter; 00806 00807
00808
00809 if (deallocatedPageSet.find(pageId) != deallocatedPageSet.end()) { 00810 continue; 00811 } 00812
00813
00814 if (isPageIdAllocateCommitted(pageId)) { 00815 deallocatedPageSet.insert(pageId); 00816 continue; 00817 } 00818 00819
00820
00821
00822
00823 PageId anchorPageId; 00824 bool deallocateChain; 00825 TxnId deallocationCsn = 00826 getOldestTxnId( 00827 pageId, 00828 oldestActiveTxnId, 00829 anchorPageId, 00830 deallocatedPageSet, 00831 deallocateChain); 00832 if (deallocateChain) { 00833 deallocateEntirePageChain( 00834 pageId, 00835 oldestActiveTxnId, 00836 deallocatedPageSet); 00837 continue; 00838 } 00839 if (deallocationCsn == NULL_TXN_ID) { 00840 continue; 00841 } 00842 00843
00844
00845 deallocatePageChain(anchorPageId, deallocationCsn, deallocatedPageSet); 00846 } 00847 }

| void VersionedRandomAllocationSegment::freeTempPages | ( | | ) | | ---------------------------------------------------- | - | | - |

BlockNum VersionedRandomAllocationSegment::backupAllocationNodes ( SharedSegPageBackupRestoreDevice pBackupDevice,
bool countDataPages,
TxnId lowerBoundCsn,
TxnId upperBoundCsn,
bool volatile const & abortFlag
)

Writes all the segment and extent allocation pages from this segment sequentially to a backup file.

If requested, also counts the number of data pages that will need to be backed up later, based on pages whose allocationCsn's are within a lower and upper bound. If the lower bound is set to NULL_TXN_ID, then that indicates that there is no lower bound; otherwise, the lower bound is exclusive. There must always be an upper bound and it is inclusive.

Parameters:

pBackupDevice device that does all I/O for the backup
countDataPages if true, count the number of data pages that will be backed up
lowerBoundCsn the lower bound allocation csn
upperBoundCsn the upper bound allocation csn
[in] abortFlag reference to a flag indicating whether the backup should be aborted

Returns:

number of data pages that will be backed up if countDataPages is true; otherwise, returns 0

Definition at line 1213 of file VersionedRandomAllocationSegment.cpp.

References VersionedPageEntry::allocationCsn, checkAbort(), RandomAllocationSegmentBase::getExtentAllocPageId(), SegmentAllocationNode::getExtentEntry(), SegNodeLock< Node >::getNodeForRead(), SegPageLock::getPage(), VersionedExtentAllocationNode::getPageEntry(), CachePage::getReadableData(), RandomAllocationSegmentBase::getSegAllocPageId(), Segment::getTracingSegment(), SegPageLock::lockShared(), SegmentAllocationNode::nExtents, RandomAllocationSegmentBase::nExtentsPerSegAlloc, SegmentAllocationNode::nextSegAllocPageId, RandomAllocationSegmentBase::nPagesPerExtent, NULL_PAGE_ID, NULL_TXN_ID, SegmentAllocationNode::ExtentEntry::nUnallocatedPages, PageEntry::ownerId, Segment::pCache, and UNALLOCATED_PAGE_OWNER_ID.

Referenced by BackupRestoreTest::backup().

void VersionedRandomAllocationSegment::backupDataPages ( SharedSegPageBackupRestoreDevice pBackupDevice,
TxnId lowerBoundCsn,
TxnId upperBoundCsn,
bool volatile const & abortFlag
)

Walks through all page entries in this segment and locates the ones that have allocationCsn's in between a lower and upper bound.

If the lower bound is set to NULL_TXN_ID, then that indicates that there is no lower bound; otherwise, the lower bound is exclusive. There must always be an upper bound and it is inclusive.

Parameters:

pBackupDevice device that carries out I/O for the backup
lowerBoundCsn the lower bound allocation csn
upperBoundCsn the upper bound allocation csn
[in] abortFlag reference to a flag indicating whether the backup should be aborted

Definition at line 1284 of file VersionedRandomAllocationSegment.cpp.

References locateDataPages().

Referenced by BackupRestoreTest::backup(), and Database::completeBackup().

01289 { 01290 locateDataPages( 01291 pBackupDevice, 01292 lowerBoundCsn, 01293 upperBoundCsn, 01294 true, 01295 abortFlag); 01296 }

void VersionedRandomAllocationSegment::restoreFromBackup ( SharedSegPageBackupRestoreDevice pBackupDevice,
TxnId lowerBoundCsn,
TxnId upperBoundCsn,
bool volatile const & abortFlag
)

Restores the segment and extent allocation node pages and data pages for this segment from a backup file.

The data pages in the backup file correspond to pages with allocationCsn's in between a lower and upper bound. If the lower bound is set to NULL_TXN_ID, then that indicates that there is no lower bound; otherwise, the lower bound is exclusive. There must always be an upper bound and it is inclusive.

Parameters:

pBackupDevice device that carries out I/O during the restore
lowerBoundCsn the lower bound allocation csn
upperBoundCsn the upper bound allocation csn
[in] abortFlag reference to a flag indicating whether the restore should be aborted

Definition at line 1399 of file VersionedRandomAllocationSegment.cpp.

References checkAbort(), DelegatingSegment::ensureAllocatedSize(), RandomAllocationSegmentBase::getExtentAllocPageId(), SegmentAllocationNode::getExtentEntry(), SegNodeLock< Node >::getNodeForRead(), RandomAllocationSegmentBase::getSegAllocPageId(), Segment::getTracingSegment(), locateDataPages(), SegPageLock::lockShared(), RandomAllocationSegmentBase::makePageNum(), SegmentAllocationNode::nExtents, RandomAllocationSegmentBase::nExtentsPerSegAlloc, SegmentAllocationNode::nextSegAllocPageId, RandomAllocationSegmentBase::nPagesPerExtent, NULL_PAGE_ID, Segment::pCache, and RandomAllocationSegmentBase::translatePageId().

Referenced by BackupRestoreTest::restore(), and Database::restoreFromBackup().

bool VersionedRandomAllocationSegment::isPageIdAllocated ( PageId pageId ) [virtual]
PageId VersionedRandomAllocationSegment::allocatePageId ( PageOwnerId ownerId ) [virtual]
PageId VersionedRandomAllocationSegment::getPageSuccessor ( PageId pageId ) [virtual]
void VersionedRandomAllocationSegment::setPageSuccessor ( PageId pageId,
PageId successorId
) [virtual]
void VersionedRandomAllocationSegment::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.

Parameters:

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 RandomAllocationSegmentBase.

Definition at line 159 of file VersionedRandomAllocationSegment.cpp.

References deallocationMutex, deferDeallocation(), RandomAllocationSegmentBase::format(), and NULL_PAGE_ID.

| void VersionedRandomAllocationSegment::initForUse | ( | | ) | [virtual] | | ------------------------------------------------- | - | | - | ----------- |

PageId RandomAllocationSegmentBase::getSegAllocPageId ( uint iSegPage ) const [inline, protected, inherited]

Calculates the PageId of a particular SegmentAllocationNode.

Parameters:

Returns:

corresponding PageId

Definition at line 104 of file RandomAllocationSegmentBaseImpl.h.

References Segment::getLinearPageId(), and RandomAllocationSegmentBase::nPagesPerSegAlloc.

Referenced by allocateAllocNodes(), RandomAllocationSegmentBase::allocatePageIdFromSegment(), backupAllocationNodes(), RandomAllocationSegmentBase::deallocatePageId(), deallocateSinglePage(), RandomAllocationSegmentBase::format(), getOldPageIds(), locateDataPages(), restoreFromBackup(), updateExtentEntry(), and validateFreePageCount().

PageId RandomAllocationSegmentBase::getExtentAllocPageId ( ExtentNum extentNum ) const [inline, protected, inherited]

Calculates the PageId of a particular extent allocation node.

Parameters:

extentNum absolute 0-based extent number

Returns:

corresponding PageId

Definition at line 118 of file RandomAllocationSegmentBaseImpl.h.

References Segment::getLinearPageId(), and RandomAllocationSegmentBase::makePageNum().

Referenced by backupAllocationNodes(), chainPageEntries(), deallocateSinglePage(), RandomAllocationSegmentBase::formatPageExtentsTemplate(), RandomAllocationSegmentBase::freePageEntryTemplate(), getExtAllocPageIdForRead(), RandomAllocationSegment::getExtAllocPageIdForRead(), getExtAllocPageIdForWrite(), RandomAllocationSegment::getExtAllocPageIdForWrite(), getOldestTxnId(), getOldPageIds(), RandomAllocationSegmentBase::getPageEntryCopyTemplate(), locateDataPages(), restoreFromBackup(), uncommittedDeallocation(), updatePageEntry(), updateTempPageEntry(), and validateFreePageCount().

BlockNum RandomAllocationSegmentBase::makePageNum ( ExtentNum extentNum,
BlockNum iPageInExtent
) const [inline, protected, inherited]
void RandomAllocationSegmentBase::splitPageId ( PageId pageId,
uint & iSegAlloc,
ExtentNum & extentNum,
BlockNum & iPageInExtent
) const [protected, inherited]

Maps a linear PageId from this segment into the corresponding SegmentAllocationNode, extent allocation node, and extent-relative page index.

Parameters:

pageId input PageId
[out] iSegAlloc 0-based index of containing SegmentAllocationNode
[out] extentNum absolute 0-based extent number of containing extent allocation node
[out] iPageInExtent 0-based index of page in extent

Definition at line 279 of file RandomAllocationSegmentBase.cpp.

References Segment::getLinearBlockNum(), MAXU, RandomAllocationSegmentBase::nExtentsPerSegAlloc, RandomAllocationSegmentBase::nPagesPerExtent, and RandomAllocationSegmentBase::nPagesPerSegAlloc.

Referenced by chainPageEntries(), RandomAllocationSegmentBase::deallocatePageId(), deallocateSinglePage(), deferDeallocation(), getOldestTxnId(), RandomAllocationSegmentBase::getPageEntryCopyTemplate(), initPageEntry(), RandomAllocationSegmentBase::setPageSuccessorTemplate(), RandomAllocationSegmentBase::testPageId(), uncommittedDeallocation(), updateAllocNodes(), updateTempPageEntry(), and validateFreePageCount().

bool RandomAllocationSegmentBase::testPageId ( PageId pageId,
bool testAllocation,
bool thisSegment
) [protected, inherited]

template

PageOwnerId RandomAllocationSegmentBase::getPageOwnerIdTemplate ( PageId pageId,
bool thisSegment
) [protected, inherited]

Retrieves the ownerId corresponding to a page entry.

This template method allows the caller to specify different page entry types.

Parameters:

pageId PageId of the page whose owner we are retrieving
thisSegment if true, retrieve page entry from this segment; otherwise, retrieve it from an alternative segment

Returns:

ownerId

Definition at line 262 of file RandomAllocationSegmentBaseImpl.h.

References RandomAllocationSegmentBase::getPageEntryCopy().

00265 { 00266 PageEntryT pageEntry; 00267 00268 getPageEntryCopy(pageId, pageEntry, false, thisSegment); 00269 return pageEntry.ownerId; 00270 }

template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>

void RandomAllocationSegmentBase::freePageEntryTemplate ( ExtentNum extentNum,
BlockNum iPageInExtent
) [protected, inherited]

| PageId RandomAllocationSegmentBase::getFirstSegAllocPageId | ( | | ) | const [inline, protected, inherited] | | ---------------------------------------------------------- | - | | - | -------------------------------------- |

| uint RandomAllocationSegmentBase::inferSegAllocCount | ( | | ) | [protected, inherited] | | ----------------------------------------------------------------------------------------------------------------- | - | | - | ------------------------ |

| void RandomAllocationSegmentBase::format | ( | | ) | [protected, inherited] | | ---------------------------------------- | - | | - | ------------------------ |

Formats allocation pages based on current size of underlying segment, marking all pages as deallocated.

Definition at line 67 of file RandomAllocationSegmentBase.cpp.

References DelegatingSegment::ensureAllocatedSize(), RandomAllocationSegmentBase::formatPageExtents(), DelegatingSegment::getAllocatedSizeInPages(), SegNodeLock< Node >::getNodeForWrite(), RandomAllocationSegmentBase::getSegAllocPageId(), Segment::getTracingSegment(), RandomAllocationSegmentBase::inferSegAllocCount(), SegPageLock::lockExclusive(), min(), SegmentAllocationNode::nExtents, RandomAllocationSegmentBase::nExtentsPerSegAlloc, SegmentAllocationNode::nextSegAllocPageId, SegmentAllocationNode::nPagesPerExtent, RandomAllocationSegmentBase::nPagesPerExtent, NULL_PAGE_ID, Segment::pCache, and SegNodeLock< Node >::setMagicNumber().

Referenced by deallocatePageRange(), and RandomAllocationSegmentBase::deallocatePageRange().

template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>

void RandomAllocationSegmentBase::formatPageExtentsTemplate ( SegmentAllocationNode & segAllocNode,
ExtentNum & extentNum
) [protected, inherited]

Formats each of the extents within a segment allocation node.

This template method allows the caller to specify different extent allocation node types.

Parameters:

[in] segAllocNode locked segment allocation node
[in,out] extentNum on input, the initial absolute 0-based extent number that needs to be formatted; on output, the last extent number formatted + 1

Definition at line 146 of file RandomAllocationSegmentBaseImpl.h.

References RandomAllocationSegmentBase::formatExtentTemplate(), RandomAllocationSegmentBase::getExtentAllocPageId(), SegmentAllocationNode::getExtentEntry(), Segment::getTracingSegment(), SegmentAllocationNode::nExtents, RandomAllocationSegmentBase::nExtentsPerSegAlloc, RandomAllocationSegmentBase::nPagesPerExtent, and Segment::pCache.

Referenced by allocateExtAllocNodes(), formatPageExtents(), and RandomAllocationSegment::formatPageExtents().

template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>

void RandomAllocationSegmentBase::formatExtentTemplate ( ExtentAllocationNodeT & extentNode ) [protected, inherited]
PageId RandomAllocationSegmentBase::allocatePageIdFromSegment ( PageOwnerId ownerId,
SharedSegment allocNodeSegment
) [protected, inherited]

Allocates a page without locking it into memory.

The allocation nodes originate from a specified segment.

Parameters:

ownerId the PageOwnerId of the object which will own this page, or ANON_PAGE_OWNER_ID for pages unassociated with an owner
allocNodeSegment segment from which the allocation nodes originate

Returns:

the PageId of the allocated page, or NULL_PAGE_ID if none could be allocated

Definition at line 151 of file RandomAllocationSegmentBase.cpp.

References RandomAllocationSegmentBase::allocateFromExtent(), RandomAllocationSegmentBase::allocateFromNewExtent(), DelegatingSegment::ensureAllocatedSize(), SegmentAllocationNode::getExtentEntry(), RandomAllocationSegmentBase::getFirstSegAllocPageId(), SegNodeLock< Node >::getNodeForRead(), SegNodeLock< Node >::getNodeForWrite(), RandomAllocationSegmentBase::getSegAllocPageId(), RandomAllocationSegmentBase::getSegAllocPageIdForWrite(), RandomAllocationSegmentBase::incrementPageCounters(), RandomAllocationSegmentBase::incrementPagesOccupiedCounter(), SegPageLock::lockExclusive(), RandomAllocationSegmentBase::makePageNum(), SegmentAllocationNode::nExtents, RandomAllocationSegmentBase::nExtentsPerSegAlloc, SegmentAllocationNode::nextSegAllocPageId, SegmentAllocationNode::nPagesPerExtent, RandomAllocationSegmentBase::nPagesPerExtent, NULL_PAGE_ID, SegmentAllocationNode::ExtentEntry::nUnallocatedPages, Segment::pCache, SegNodeLock< Node >::setMagicNumber(), RandomAllocationSegmentBase::undoSegAllocPageWrite(), and SegPageLock::unlock().

Referenced by allocatePageId(), and RandomAllocationSegment::allocatePageId().

template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>

PageId RandomAllocationSegmentBase::allocateFromExtentTemplate ( ExtentNum extentNum,
PageOwnerId ownerId,
SharedSegment allocNodeSegment
) [protected, inherited]

template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>

PageId RandomAllocationSegmentBase::allocateFromNewExtentTemplate ( ExtentNum extentNum,
PageOwnerId ownerId,
SharedSegment allocNodeSegment
) [protected, inherited]

Allocates a page from a new extent allocation node.

The extent is specified by the absolute extent number and the segment where the extent allocation node originates from.

This template method allows the caller to specify different extent allocation node types.

Parameters:

extentNum absolute 0-based extent number from which to allocate
ownerId PageOwnerId of owning object
allocNodeSegment segment that the allocation node page originates from

Returns:

allocated PageId

Definition at line 183 of file RandomAllocationSegmentBaseImpl.h.

References RandomAllocationSegmentBase::getExtAllocPageIdForWrite(), and Segment::pCache.

Referenced by allocateFromNewExtent(), and RandomAllocationSegment::allocateFromNewExtent().

00187 { 00188 SegmentAccessor segAccessor(allocNodeSegment, pCache); 00189 ExtentAllocLockT extentAllocLock(segAccessor); 00190 extentAllocLock.lockExclusive(getExtAllocPageIdForWrite(extentNum)); 00191 extentAllocLock.setMagicNumber(); 00192 ExtentAllocationNodeT &extentNode = extentAllocLock.getNodeForWrite(); 00193 formatExtentTemplate<ExtentAllocationNodeT, ExtentAllocLockT, PageEntryT>( 00194 extentNode); 00195 return 00196 allocateFromLockedExtentTemplate<ExtentAllocationNodeT, PageEntryT>( 00197 extentNode, 00198 extentNum, 00199 ownerId); 00200 }

template<class ExtentAllocationNodeT, class PageEntryT>

PageId RandomAllocationSegmentBase::allocateFromLockedExtentTemplate ( ExtentAllocationNodeT & extentNode,
ExtentNum extentNum,
PageOwnerId ownerId
) [protected, inherited]

template<class ExtentAllocationNodeT, class ExtentAllocLockT>

void RandomAllocationSegmentBase::setPageSuccessorTemplate ( PageId pageId,
PageId successorId,
SharedSegment allocNodeSegment
) [protected, inherited]

template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>

void RandomAllocationSegmentBase::getPageEntryCopyTemplate ( PageId pageId,
PageEntryT & pageEntryCopy,
bool isAllocated,
bool thisSegment
) [protected, inherited]

Retrieves a copy of the page entry for a specified page.

This template method allows the caller to specify different extent allocation node and page entry types.

Parameters:

pageId pageId of the page whose page entry data we are retrieving
[out] pageEntryCopy copy of page entry retrieved
isAllocated if true, assert that the page is allocated
thisSegment if true, retrieve page entry from this segment; otherwise, retrieve it from an alternative segment

Definition at line 273 of file RandomAllocationSegmentBaseImpl.h.

References RandomAllocationSegmentBase::getExtAllocPageIdForRead(), RandomAllocationSegmentBase::getExtentAllocPageId(), Segment::getTracingSegment(), Segment::pCache, RandomAllocationSegmentBase::splitPageId(), and RandomAllocationSegmentBase::testPageId().

Referenced by getPageEntryCopy().

00278 { 00279 if (isAllocated) { 00280 assert(testPageId(pageId, true, thisSegment)); 00281 } 00282 00283 ExtentNum extentNum; 00284 BlockNum iPageInExtent; 00285 uint iSegAlloc; 00286 splitPageId(pageId, iSegAlloc, extentNum, iPageInExtent); 00287 assert(iPageInExtent); 00288 00289 SharedSegment allocNodeSegment; 00290 PageId extentPageId; 00291 if (thisSegment) { 00292 allocNodeSegment = getTracingSegment(); 00293 extentPageId = getExtentAllocPageId(extentNum); 00294 } else { 00295 extentPageId = getExtAllocPageIdForRead(extentNum, allocNodeSegment); 00296 } 00297 00298 SegmentAccessor segAccessor(allocNodeSegment, pCache); 00299 ExtentAllocLockT extentAllocLock(segAccessor); 00300 extentAllocLock.lockShared(extentPageId); 00301 ExtentAllocationNodeT const &extentNode = 00302 extentAllocLock.getNodeForRead(); 00303 00304 PageEntryT const &pageEntry = 00305 extentNode.getPageEntry(iPageInExtent); 00306 00307 pageEntryCopy = pageEntry; 00308 }

| BlockId RandomAllocationSegmentBase::translatePageId | ( | PageId | | ) | [virtual, inherited] | | ---------------------------------------------------- | - | ------ | | - | ---------------------- |

| BlockNum RandomAllocationSegmentBase::getAllocatedSizeInPages | ( | | ) | [virtual, inherited] | | ----------------------------------------------------------------------------------------------------------------- | - | | - | ---------------------- |

| BlockNum RandomAllocationSegmentBase::getNumPagesOccupiedHighWater | ( | | ) | [virtual, inherited] | | ---------------------------------------------------------------------------------------------------------------------- | - | | - | ---------------------- |

| SharedSegment const& DelegatingSegment::getDelegateSegment | ( | | ) | const [inline, inherited] | | -------------------------------------------------------------------------------------------------------------------- | - | | - | --------------------------- |

| BlockNum DelegatingSegment::getNumPagesExtended | ( | | ) | [virtual, inherited] | | --------------------------------------------------------------------------------------------------- | - | | - | ---------------------- |

| PageId DelegatingSegment::translateBlockId | ( | BlockId | | ) | [virtual, inherited] | | ------------------------------------------ | - | ------- | | - | ---------------------- |

bool DelegatingSegment::ensureAllocatedSize ( BlockNum nPages ) [virtual, inherited]
void DelegatingSegment::delegatedCheckpoint ( Segment & delegatingSegment,
CheckpointType checkpointType
) [virtual, inherited]
PageId DelegatingSegment::updatePage ( PageId pageId,
bool needsTranslation = false
) [virtual, inherited]
void DelegatingSegment::notifyPageMap ( CachePage & page ) [virtual, inherited]
void DelegatingSegment::notifyPageUnmap ( CachePage & page ) [virtual, inherited]
void DelegatingSegment::notifyAfterPageRead ( CachePage & page ) [virtual, inherited]
void DelegatingSegment::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.

Parameters:

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 MappedPageListener.

Reimplemented in SnapshotRandomAllocationSegment, TracingSegment, VersionedSegment, and WALSegment.

Definition at line 122 of file DelegatingSegment.cpp.

References DelegatingSegment::pDelegateSegment.

Referenced by WALSegment::notifyPageDirty(), VersionedSegment::notifyPageDirty(), TracingSegment::notifyPageDirty(), and SnapshotRandomAllocationSegment::notifyPageDirty().

void DelegatingSegment::notifyBeforePageFlush ( CachePage & page ) [virtual, inherited]
void DelegatingSegment::notifyAfterPageFlush ( CachePage & page ) [virtual, inherited]
bool DelegatingSegment::canFlushPage ( CachePage & page ) [virtual, inherited]

| void Segment::setUsablePageSize | ( | uint | | ) | [protected, inherited] | | ------------------------------- | - | ----------------------------------------------------------------- | | - | ------------------------ |

PageId Segment::getLinearPageSuccessor ( PageId pageId ) [protected, inherited]
void Segment::setLinearPageSuccessor ( PageId pageId,
PageId successorId
) [protected, inherited]
bool Segment::isLinearPageIdAllocated ( PageId pageId ) [protected, inherited]

| SharedCache Segment::getCache | ( | | ) | const [inline, inherited] | | --------------------------------------------------------------------------------------- | - | | - | --------------------------- |

| uint Segment::getFullPageSize | ( | | ) | const [inherited] | | ------------------------------------------------------------------------------------------ | - | | - | ------------------- |

| uint Segment::getUsablePageSize | ( | | ) | const [inline, inherited] | | -------------------------------------------------------------------------------------------- | - | | - | --------------------------- |

Returns:

tracing segment associated with this segment if tracing is turned on; otherwise, returns the segment itself

Definition at line 50 of file Segment.cpp.

References Segment::pTracingSegment.

Referenced by allocateAllocNodes(), RandomAllocationSegment::allocateFromExtent(), RandomAllocationSegment::allocateFromNewExtent(), RandomAllocationSegment::allocatePageId(), backupAllocationNodes(), chainPageEntries(), SnapshotRandomAllocationSegment::commitChanges(), copyPageEntryFromTemp(), copyPageEntryToTemp(), RandomAllocationSegmentBase::deallocatePageId(), findAllocPageIdForRead(), RandomAllocationSegmentBase::format(), RandomAllocationSegmentBase::formatPageExtentsTemplate(), RandomAllocationSegmentBase::freePageEntryTemplate(), RandomAllocationSegment::getExtAllocPageIdForRead(), getOldestTxnId(), getOldPageIds(), RandomAllocationSegmentBase::getPageEntryCopyTemplate(), RandomAllocationSegment::getSegAllocPageIdForRead(), getTempAllocNodePage(), Segment::getTracingListener(), locateDataPages(), restoreFromBackup(), SnapshotRandomAllocationSegment::rollbackChanges(), RandomAllocationSegment::setPageSuccessor(), updateExtentEntry(), and 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.

Parameters:

pTracingSegmentInit the tracing segment

Definition at line 60 of file Segment.cpp.

References Segment::pTracingSegment.

void Segment::checkpoint ( CheckpointType checkpointType = CHECKPOINT_FLUSH_ALL ) [inherited]
MappedPageListener * Segment::getMappedPageListener ( BlockId blockId ) [virtual, inherited]

| bool Segment::isWriteVersioned | ( | | ) | [virtual, inherited] | | ------------------------------ | - | | - | ---------------------- |

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(), getOldPageIds(), RandomAllocationSegmentBase::getSegAllocPageId(), Database::init(), locateDataPages(), SegmentTestBase::lockPage(), SegmentTestBase::prefetchPage(), SegPageIterTest::testBoundedIter(), SegPageEntryIterTest::testBoundedIter(), ScratchSegment::translateBlockId(), LinearViewSegment::translateBlockId(), LinearDeviceSegment::translateBlockId(), CircularSegment::translateBlockId(), and CircularSegment::translatePageId().

00349 { 00350 return PageId(iPage); 00351 }

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().

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.

Parameters:

page the page that was flushed

Returns:

NULL if the listener on the page does not need to be reset; otherwise, returns the listener that the page should be reset to

Reimplemented in SnapshotRandomAllocationSegment, and TracingSegment.

Definition at line 62 of file MappedPageListener.cpp.

00064 { 00065 return NULL; 00066 }

| bool ClosableObject::isClosed | ( | | ) | const [inline, inherited] | | ----------------------------- | - | | - | --------------------------- |

Returns:

whether the object has been closed

Definition at line 58 of file ClosableObject.h.

| 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().



Member Data Documentation

Maps allocation node pages to the modified copy of the node that contains uncommitted page modifications.

Definition at line 150 of file VersionedRandomAllocationSegment.h.

Referenced by deallocateSinglePage(), findAllocPageIdForRead(), freeTempPage(), freeTempPages(), getTempAllocNodePage(), uncommittedDeallocation(), undoSegAllocPageWrite(), updateAllocNodes(), updateExtentEntry(), updatePageEntry(), and updateTempPageEntry().

Mutex used to protect allocationNodeMap.

Multiple readers are allowed but only a single writer.

In the case where both mapMutex and deallocationMutex need to be acquired, acquire deallocationMutex first.

Definition at line 159 of file VersionedRandomAllocationSegment.h.

Referenced by deallocateOldPages(), deallocateSinglePage(), findAllocPageIdForRead(), freeTempPage(), freeTempPages(), getPageEntryCopy(), getTempAllocNodePage(), initForUse(), uncommittedDeallocation(), undoSegAllocPageWrite(), updateAllocNodes(), updateExtentEntry(), updatePageEntry(), and updateTempPageEntry().

Segment used to allocate pages to store uncommitted modifications to segment and extent allocation node pages.

Definition at line 173 of file VersionedRandomAllocationSegment.h.

Referenced by allocateFromExtent(), allocateFromNewExtent(), allocatePageId(), chainPageEntries(), copyPageEntryFromTemp(), copyPageEntryToTemp(), deallocateSinglePage(), deferDeallocation(), findAllocPageIdForRead(), freeTempPage(), getTempAllocNodePage(), initPageEntry(), setPageSuccessor(), uncommittedDeallocation(), updateExtentEntry(), updateTempPageEntry(), and VersionedRandomAllocationSegment().

Number of pages in one extent, including the extent allocation node itself (so actual data capacity per extent is one less).

This is immutable.

Definition at line 147 of file RandomAllocationSegmentBase.h.

Referenced by allocateAllocNodes(), RandomAllocationSegmentBase::allocateFromLockedExtentTemplate(), RandomAllocationSegmentBase::allocatePageIdFromSegment(), backupAllocationNodes(), RandomAllocationSegmentBase::deallocatePageId(), RandomAllocationSegmentBase::format(), RandomAllocationSegmentBase::formatExtentTemplate(), RandomAllocationSegmentBase::formatPageExtentsTemplate(), getOldPageIds(), locateDataPages(), RandomAllocationSegmentBase::makePageNum(), RandomAllocationSegment::RandomAllocationSegment(), restoreFromBackup(), RandomAllocationSegmentBase::splitPageId(), RandomAllocationSegmentBase::tallySegAllocNodePages(), validateFreePageCount(), and VersionedRandomAllocationSegment().

Number of extents mapped by a full SegmentAllocationNode.

This is immutable.

Definition at line 159 of file RandomAllocationSegmentBase.h.

Referenced by allocateExtAllocNodes(), RandomAllocationSegmentBase::allocatePageIdFromSegment(), backupAllocationNodes(), RandomAllocationSegmentBase::deallocatePageId(), deallocateSinglePage(), RandomAllocationSegmentBase::format(), RandomAllocationSegmentBase::formatPageExtentsTemplate(), getOldPageIds(), locateDataPages(), RandomAllocationSegmentBase::makePageNum(), RandomAllocationSegment::RandomAllocationSegment(), RandomAllocationSegmentBase::RandomAllocationSegmentBase(), restoreFromBackup(), RandomAllocationSegmentBase::splitPageId(), updateExtentEntry(), validateFreePageCount(), and VersionedRandomAllocationSegment().

Cache managing pages of this segment.

Definition at line 62 of file Segment.h.

Referenced by allocateAllocNodes(), RandomAllocationSegmentBase::allocateFromExtentTemplate(), RandomAllocationSegmentBase::allocateFromNewExtentTemplate(), RandomAllocationSegmentBase::allocatePageIdFromSegment(), backupAllocationNodes(), chainPageEntries(), copyPageEntryFromTemp(), copyPageEntryToTemp(), RandomAllocationSegmentBase::deallocatePageId(), deallocateSinglePage(), deferDeallocation(), VersionedSegment::delegatedCheckpoint(), SnapshotRandomAllocationSegment::delegatedCheckpoint(), Segment::delegatedCheckpoint(), RandomAllocationSegmentBase::format(), RandomAllocationSegmentBase::formatPageExtentsTemplate(), RandomAllocationSegmentBase::freePageEntryTemplate(), Segment::getCache(), Segment::getFullPageSize(), getOldestTxnId(), getOldPageIds(), RandomAllocationSegmentBase::getPageEntryCopyTemplate(), getTempAllocNodePage(), initPageEntry(), locateDataPages(), VersionedSegment::notifyPageDirty(), VersionedSegment::recover(), restoreFromBackup(), RandomAllocationSegmentBase::setPageSuccessorTemplate(), RandomAllocationSegmentBase::tallySegAllocNodePages(), uncommittedDeallocation(), updateExtentEntry(), updatePageEntry(), updateTempPageEntry(), and validateFreePageCount().


The documentation for this class was generated from the following files:


Generated on Mon Jun 22 04:00:49 2009 for Fennel by doxygen 1.5.1