Fennel: RandomAllocationSegmentBase Class Reference (original) (raw)

RandomAllocationSegmentBase is an abstract base class that implements RANDOM_ALLOCATION in terms of an underlying segment supporting LINEAR_ALLOCATION. More...

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

Inheritance diagram for RandomAllocationSegmentBase:

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
virtual ~RandomAllocationSegmentBase ()
virtual BlockId translatePageId (PageId)
Maps from a PageId in this segment to a BlockId.
virtual bool isPageIdAllocated (PageId pageId)
Tests whether a PageId is allocated.
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.
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.
SharedSegment const & getDelegateSegment () const
virtual BlockNum getNumPagesExtended ()
**Returns:**the number of incremental pages added to this instance of the segment
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 PageId translateBlockId (BlockId)
Maps from a BlockId to a PageId in this segment.
virtual PageId allocatePageId (PageOwnerId ownerId=ANON_PAGE_OWNER_ID)
Allocates a page without locking it into memory.
virtual bool ensureAllocatedSize (BlockNum nPages)
Allocates pages as needed to make getAllocatedSizeInPages() meet a lower bound.
virtual 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
RandomAllocationSegmentBase (SharedSegment delegateSegment)
PageId getSegAllocPageId (uint iSegPage) const
Calculates the PageId of a particular SegmentAllocationNode.
virtual PageId getSegAllocPageIdForWrite (PageId origSegAllocPageId)=0
Retrieves the pageId of the SegmentAllocationNode that should be updated when updates are made to that node.
virtual void undoSegAllocPageWrite (PageId segAllocPageId)=0
Indicates that no new pages were allocated from extents within a SegmentAllocationNode.
PageId getExtentAllocPageId (ExtentNum extentNum) const
Calculates the PageId of a particular extent allocation node.
virtual PageId getExtAllocPageIdForWrite (ExtentNum extentNum)=0
Retrieves the pageId of the extent allocation node that should be updated when updates are made to that 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.
virtual bool isPageIdValid (PageId pageId)
Tests whether the given PageId has valid contents (either an allocated data page or an allocation map page).
bool testPageId (PageId pageId, bool testAllocation, bool thisSegment)
Common implementation for isPageIdValid and isPageIdAllocated.
virtual PageOwnerId getPageOwnerId (PageId pageId, bool thisSegment)=0
Retrieves the ownerId corresponding to a page entry.
template
PageOwnerId getPageOwnerIdTemplate (PageId pageId, bool thisSegment)
Retrieves the ownerId corresponding to a page entry.
virtual void freePageEntry (ExtentNum extentNum, BlockNum iPageInExtent)=0
Marks the page entry corresponding to a deallocated page as unallocated.
template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>
void freePageEntryTemplate (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.
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.
virtual void formatPageExtents (SegmentAllocationNode &segAllocNode, ExtentNum &extentNum)=0
Formats each of the extents within a segment allocation node.
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.
virtual PageId allocateFromExtent (ExtentNum extentNum, PageOwnerId ownerId)=0
Allocates a new page from an extent known to have space.
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.
virtual PageId allocateFromNewExtent (ExtentNum extentNum, PageOwnerId ownerId)=0
Allocates a page from a new extent allocation node.
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.
virtual PageId getSegAllocPageIdForRead (PageId origSegAllocPageId, SharedSegment &allocNodeSegment)=0
Retrieves the actual pageId corresponding to the SegmentAllocationNode that should be accessed when reading from the node.
virtual PageId getExtAllocPageIdForRead (ExtentNum extentNum, SharedSegment &allocNodeSegment)=0
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)=0
Retrieves a copy of the page entry for a specified 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 Member Functions
void incrementPageCounters ()
Increments the page counters for this segment instance, corresponding to some page allocation.
void incrementPagesOccupiedCounter ()
Increments the pages occupied counter.
void decrementPageCounters ()
Decrements the page counters for this segment instance, corresponding to some page deallocation.
void countAllocatedPages ()
Counts the total number of allocated data pages as well as the total number of allocated pages, which includes used allocation node pages.
void tallySegAllocNodePages (PageId segAllocPageId, SharedSegment allocNodeSegment, PageId &nextSegAllocPageId)
Counts the number of allocated pages recorded in a SegmentAllocationNode.
void deallocatePageId (PageId pageId)
Deallocates a single page.
Private Attributes
BlockNum nPagesOccupiedHighWater
The maximum number of pages occupied by this segment instance.
BlockNum nPagesAllocated
The number of data pages allocated for this segment.
BlockNum netDeallocations
The net number of deallocations on this segment.
StrictMutex pageCounterMutex
Mutex used to ensure that only one thread is incrementing the page counters.
Friends
class SegmentFactory

Detailed Description

RandomAllocationSegmentBase is an abstract base class that implements RANDOM_ALLOCATION in terms of an underlying segment supporting LINEAR_ALLOCATION.

See the design docs for more detail.

The segment tracks space allocation using segment allocation nodes and extent allocation nodes. This base class defines the structure of the segment allocation node and a base page entry. It is left to each deriving class to define its own extent allocation node, and further refine the page entry, if necessary.

The allocation nodes may be stored in a separate segment.

Definition at line 68 of file RandomAllocationSegmentBase.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

RandomAllocationSegmentBase::RandomAllocationSegmentBase ( SharedSegment delegateSegment ) [explicit, protected]

| RandomAllocationSegmentBase::~RandomAllocationSegmentBase | ( | | ) | [virtual] | | ---------------------------------------------------------- | - | | - | ----------- |


Member Function Documentation

| void RandomAllocationSegmentBase::incrementPageCounters | ( | | ) | [private] | | ------------------------------------------------------- | - | | - | ----------- |

| void RandomAllocationSegmentBase::incrementPagesOccupiedCounter | ( | | ) | [private] | | --------------------------------------------------------------- | - | | - | ----------- |

| void RandomAllocationSegmentBase::decrementPageCounters | ( | | ) | [private] | | ------------------------------------------------------- | - | | - | ----------- |

| void RandomAllocationSegmentBase::countAllocatedPages | ( | | ) | [private] | | ----------------------------------------------------- | - | | - | ----------- |

void RandomAllocationSegmentBase::tallySegAllocNodePages ( PageId segAllocPageId,
SharedSegment allocNodeSegment,
PageId & nextSegAllocPageId
) [private]
void RandomAllocationSegmentBase::deallocatePageId ( PageId pageId ) [private]

Deallocates a single page.

Parameters:

pageId PageId of page to deallocate

Definition at line 338 of file RandomAllocationSegmentBase.cpp.

References decrementPageCounters(), freePageEntry(), SegmentAllocationNode::getExtentEntry(), SegNodeLock< Node >::getNodeForWrite(), getSegAllocPageId(), Segment::getTracingSegment(), isPageIdAllocated(), SegPageLock::lockExclusive(), nExtentsPerSegAlloc, nPagesPerExtent, NULL_PAGE_ID, Segment::pCache, splitPageId(), and DelegatingSegment::translatePageId().

Referenced by deallocatePageRange().

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

Calculates the PageId of a particular SegmentAllocationNode.

Parameters:

Returns:

corresponding PageId

Definition at line 104 of file RandomAllocationSegmentBaseImpl.h.

References Segment::getLinearPageId(), and nPagesPerSegAlloc.

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

virtual PageId RandomAllocationSegmentBase::getSegAllocPageIdForWrite ( PageId origSegAllocPageId ) [protected, pure virtual]
virtual void RandomAllocationSegmentBase::undoSegAllocPageWrite ( PageId segAllocPageId ) [protected, pure virtual]
PageId RandomAllocationSegmentBase::getExtentAllocPageId ( ExtentNum extentNum ) const [inline, protected]

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

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

virtual PageId RandomAllocationSegmentBase::getExtAllocPageIdForWrite ( ExtentNum extentNum ) [protected, pure virtual]
void RandomAllocationSegmentBase::splitPageId ( PageId pageId,
uint & iSegAlloc,
ExtentNum & extentNum,
BlockNum & iPageInExtent
) const [protected]

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, nExtentsPerSegAlloc, nPagesPerExtent, and nPagesPerSegAlloc.

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

bool RandomAllocationSegmentBase::isPageIdValid ( PageId pageId ) [protected, virtual]
bool RandomAllocationSegmentBase::testPageId ( PageId pageId,
bool testAllocation,
bool thisSegment
) [protected]
virtual PageOwnerId RandomAllocationSegmentBase::getPageOwnerId ( PageId pageId,
bool thisSegment
) [protected, pure virtual]

template

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

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

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

virtual void RandomAllocationSegmentBase::freePageEntry ( ExtentNum extentNum,
BlockNum iPageInExtent
) [protected, pure virtual]

template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>

void RandomAllocationSegmentBase::freePageEntryTemplate ( ExtentNum extentNum,
BlockNum iPageInExtent
) [protected]
void RandomAllocationSegmentBase::markPageEntryUnused ( PageEntry & pageEntry ) [protected, virtual]

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

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

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

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(), formatPageExtents(), DelegatingSegment::getAllocatedSizeInPages(), SegNodeLock< Node >::getNodeForWrite(), getSegAllocPageId(), Segment::getTracingSegment(), inferSegAllocCount(), SegPageLock::lockExclusive(), min(), SegmentAllocationNode::nExtents, nExtentsPerSegAlloc, SegmentAllocationNode::nextSegAllocPageId, SegmentAllocationNode::nPagesPerExtent, nPagesPerExtent, NULL_PAGE_ID, Segment::pCache, and SegNodeLock< Node >::setMagicNumber().

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

template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>

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

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 formatExtentTemplate(), getExtentAllocPageId(), SegmentAllocationNode::getExtentEntry(), Segment::getTracingSegment(), SegmentAllocationNode::nExtents, nExtentsPerSegAlloc, nPagesPerExtent, and Segment::pCache.

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

template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>

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

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

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

virtual PageId RandomAllocationSegmentBase::allocateFromExtent ( ExtentNum extentNum,
PageOwnerId ownerId
) [protected, pure virtual]

template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>

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

template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>

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

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 getExtAllocPageIdForWrite(), and Segment::pCache.

Referenced by VersionedRandomAllocationSegment::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]

Allocates a new page from an extent known to have space, with the extent allocation node already locked.

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

Parameters:

[in] extentNode locked extent allocation node corresponding to extentNum
extentNum absolute extent number from which to allocate
ownerId PageOwnerId of owning object

Returns:

allocated PageId

Definition at line 203 of file RandomAllocationSegmentBaseImpl.h.

References Segment::getLinearPageId(), makePageNum(), nPagesPerExtent, and UNALLOCATED_PAGE_OWNER_ID.

00205 { 00206
00207 for (uint i = 0; i < nPagesPerExtent; i++) { 00208 PageEntryT &pageEntry = node.getPageEntry(i); 00209 if (pageEntry.ownerId == UNALLOCATED_PAGE_OWNER_ID) { 00210 if (i == 0) { 00211
00212
00213 permAssert(false); 00214 } 00215 pageEntry.ownerId = ownerId; 00216 PageId pageId = getLinearPageId(makePageNum(extentNum,i)); 00217 return pageId; 00218 } 00219 } 00220 00221 permAssert(false); 00222 }

template<class ExtentAllocationNodeT, class ExtentAllocLockT>

void RandomAllocationSegmentBase::setPageSuccessorTemplate ( PageId pageId,
PageId successorId,
SharedSegment allocNodeSegment
) [protected]
virtual PageId RandomAllocationSegmentBase::getSegAllocPageIdForRead ( PageId origSegAllocPageId,
SharedSegment & allocNodeSegment
) [protected, pure virtual]
virtual PageId RandomAllocationSegmentBase::getExtAllocPageIdForRead ( ExtentNum extentNum,
SharedSegment & allocNodeSegment
) [protected, pure virtual]

Retrieves the actual pageId corresponding to the extent allocation node that should be accessed when reading from the node.

Parameters:

extentNum absolute 0-based extent number
[out] allocNodeSegment segment from which the allocation node to be read originates

Returns:

pageId to be read

Implemented in RandomAllocationSegment, and VersionedRandomAllocationSegment.

Referenced by getPageEntryCopyTemplate().

virtual void RandomAllocationSegmentBase::getPageEntryCopy ( PageId pageId,
PageEntry & pageEntryCopy,
bool isAllocated,
bool thisSegment
) [protected, pure virtual]

template<class ExtentAllocationNodeT, class ExtentAllocLockT, class PageEntryT>

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

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 getExtAllocPageIdForRead(), getExtentAllocPageId(), Segment::getTracingSegment(), Segment::pCache, splitPageId(), and testPageId().

Referenced by VersionedRandomAllocationSegment::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] | | ---------------------------------------------------- | - | ------ | | - | ----------- |

bool RandomAllocationSegmentBase::isPageIdAllocated ( PageId pageId ) [virtual]

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

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

Returns:

the max number of pages occupied by a segment

Reimplemented from DelegatingSegment.

Definition at line 448 of file RandomAllocationSegmentBase.cpp.

References nPagesOccupiedHighWater.

void RandomAllocationSegmentBase::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 DelegatingSegment.

Reimplemented in VersionedRandomAllocationSegment.

Definition at line 326 of file RandomAllocationSegmentBase.cpp.

References deallocatePageId(), format(), and NULL_PAGE_ID.

Referenced by VersionedRandomAllocationSegment::deallocateSinglePage().

00329 { 00330 permAssert(startPageId == endPageId); 00331 if (startPageId != NULL_PAGE_ID) { 00332 deallocatePageId(startPageId); 00333 } else { 00334 format(); 00335 } 00336 }

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

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

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

PageId DelegatingSegment::getPageSuccessor ( PageId pageId ) [virtual, inherited]
void DelegatingSegment::setPageSuccessor ( PageId pageId,
PageId successorId
) [virtual, inherited]

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

PageId DelegatingSegment::allocatePageId ( PageOwnerId ownerId = ANON_PAGE_OWNER_ID ) [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 VersionedRandomAllocationSegment::allocateAllocNodes(), RandomAllocationSegment::allocateFromExtent(), RandomAllocationSegment::allocateFromNewExtent(), RandomAllocationSegment::allocatePageId(), VersionedRandomAllocationSegment::backupAllocationNodes(), VersionedRandomAllocationSegment::chainPageEntries(), SnapshotRandomAllocationSegment::commitChanges(), VersionedRandomAllocationSegment::copyPageEntryFromTemp(), VersionedRandomAllocationSegment::copyPageEntryToTemp(), deallocatePageId(), VersionedRandomAllocationSegment::findAllocPageIdForRead(), format(), formatPageExtentsTemplate(), freePageEntryTemplate(), RandomAllocationSegment::getExtAllocPageIdForRead(), VersionedRandomAllocationSegment::getOldestTxnId(), VersionedRandomAllocationSegment::getOldPageIds(), 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.

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 allocateFromLockedExtentTemplate(), ScratchSegment::allocatePageId(), LinearViewSegment::allocatePageId(), LinearDeviceSegment::allocatePageId(), CircularSegment::allocatePageId(), getExtentAllocPageId(), VersionedRandomAllocationSegment::getOldPageIds(), getSegAllocPageId(), Database::init(), VersionedRandomAllocationSegment::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(), 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

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 VersionedRandomAllocationSegment::allocateAllocNodes(), allocateFromLockedExtentTemplate(), allocatePageIdFromSegment(), VersionedRandomAllocationSegment::backupAllocationNodes(), deallocatePageId(), format(), formatExtentTemplate(), formatPageExtentsTemplate(), VersionedRandomAllocationSegment::getOldPageIds(), VersionedRandomAllocationSegment::locateDataPages(), makePageNum(), RandomAllocationSegment::RandomAllocationSegment(), VersionedRandomAllocationSegment::restoreFromBackup(), splitPageId(), tallySegAllocNodePages(), VersionedRandomAllocationSegment::validateFreePageCount(), and VersionedRandomAllocationSegment::VersionedRandomAllocationSegment().

Number of extents mapped by a full SegmentAllocationNode.

This is immutable.

Definition at line 159 of file RandomAllocationSegmentBase.h.

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

Cache managing pages of this segment.

Definition at line 62 of file Segment.h.

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


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


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