Segment Class Reference

Segment is a virtualization layer for allocating and accessing pages of device storage via the cache. More...

#include <Segment.h>

Inheritance diagram for Segment:

MappedPageListener ClosableObject DelegatingSegment DynamicDelegatingSegment LinearDeviceSegment ScratchSegment CircularSegment LinearViewSegment RandomAllocationSegmentBase SnapshotRandomAllocationSegment TracingSegment VersionedSegment WALSegment RandomAllocationSegment 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

virtual ~Segment ()
 Destructor.
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

virtual void initForUse ()
 Performs additional initialization required on the segment after it has been properly formatted.
virtual BlockNum getAllocatedSizeInPages ()=0
 
Returns:
number of pages allocated from this segment

virtual BlockNum getNumPagesOccupiedHighWater ()=0
 Returns the max number of pages occupied by this segment instance.
virtual BlockNum getNumPagesExtended ()=0
 
Returns:
the number of incremental pages added to this instance of the segment

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 void delegatedCheckpoint (Segment &delegatingSegment, CheckpointType checkpointType)
 Helper for DelegatingSegment.
virtual PageId getPageSuccessor (PageId pageId)=0
 Determines the successor of a given PageId.
virtual void setPageSuccessor (PageId pageId, PageId successorId)=0
 Sets the successor of a given PageId.
virtual AllocationOrder getAllocationOrder () const=0
 
Returns:
the AllocationOrder for this segment

virtual BlockId translatePageId (PageId)=0
 Maps from a PageId in this segment to a BlockId.
virtual PageId translateBlockId (BlockId)=0
 Maps from a BlockId to a PageId in this segment.
virtual PageId allocatePageId (PageOwnerId ownerId=ANON_PAGE_OWNER_ID)=0
 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 deallocatePageRange (PageId startPageId, PageId endPageId)=0
 Deallocates a range of pages allocated from this segment.
virtual bool isPageIdAllocated (PageId pageId)=0
 Tests whether a PageId is allocated.
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 MappedPageListenergetMappedPageListener (BlockId blockId)
 Returns the mapped page listener corresponding to a page.
virtual bool isWriteVersioned ()
 
Returns:
true if the segment supports versioning

virtual MappedPageListenergetTracingListener ()
 Retrieves the tracing wrapper corresponding to this listener if tracing is turned on.
virtual void notifyPageMap (CachePage &page)
 Receives notification from CacheImpl as soon as a page is mapped, before any I/O is initiated to retrieve the page contents.
virtual void notifyPageUnmap (CachePage &page)
 Receives notification from CacheImpl just before a page is unmapped.
virtual void notifyAfterPageRead (CachePage &page)
 Receives notification from CacheImpl after a page read completes.
virtual void notifyPageDirty (CachePage &page, bool bDataValid)
 Receives notification from CacheImpl the first time a page becomes dirty after it has been mapped (but before the contents have changed).
virtual bool canFlushPage (CachePage &page)
 Informs CacheImpl whether a dirty page can safely be flushed to disk.
virtual void notifyBeforePageFlush (CachePage &page)
 Receives notification from CacheImpl just before a dirty page is flushed to disk.
virtual void notifyAfterPageFlush (CachePage &page)
 Receives notification from CacheImpl when a page flush completes successfully.
virtual MappedPageListenernotifyAfterPageCheckpointFlush (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

 Segment (SharedCache)
void setUsablePageSize (uint)
PConstBuffer getReadableFooter (CachePage &page)
PBuffer getWritableFooter (CachePage &page)
PageId getLinearPageSuccessor (PageId pageId)
 An implementation of getPageSuccessor suitable for LINEAR_ALLOCATION.
void setLinearPageSuccessor (PageId pageId, PageId successorId)
 An implementation of setPageSuccessor suitable for LINEAR_ALLOCATION.
bool isLinearPageIdAllocated (PageId pageId)
 An implementation of isPageIdAllocated suitable for LINEAR_ALLOCATION when deallocation holes are disallowed.
virtual void closeImpl ()
 Must be implemented by derived class to release any resources.

Protected Attributes

SharedCache pCache
 Cache managing pages of this segment.
WeakSegment pTracingSegment
 The tracing segment associated with this segment, if tracing is turned on.
bool needsClose

Private Attributes

uint cbUsablePerPage
 Number of usable bytes on each page before footer.

Detailed Description

Segment is a virtualization layer for allocating and accessing pages of device storage via the cache.

See the design docs for more detail.

Definition at line 43 of file Segment.h.


Member Typedef Documentation

typedef std::hash_map<PageId,PageId> Segment::PageMap [protected]

Definition at line 56 of file Segment.h.

typedef PageMap::const_iterator Segment::PageMapConstIter [protected]

Definition at line 57 of file Segment.h.


Member Enumeration Documentation

enum Segment::AllocationOrder

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.

00105                          {
00109         RANDOM_ALLOCATION,
00110 
00115         ASCENDING_ALLOCATION,
00116 
00121         CONSECUTIVE_ALLOCATION,
00122 
00128         LINEAR_ALLOCATION
00129     };


Constructor & Destructor Documentation

Segment::Segment ( SharedCache   )  [explicit, protected]

Definition at line 34 of file Segment.cpp.

References getFullPageSize(), and setUsablePageSize().

00035     : pCache(pCacheInit)
00036 {
00037     setUsablePageSize(getFullPageSize());
00038 }

Segment::~Segment (  )  [virtual]

Destructor.

As a side-effect of closing a segment, a call to checkpoint() with CHECKPOINT_FLUSH_AND_UNMAP is made so that all pages are guaranteed to be unmapped before destruction.

Definition at line 40 of file Segment.cpp.

References ClosableObject::close().

00041 {
00042     close();
00043 }


Member Function Documentation

void Segment::setUsablePageSize ( uint   )  [protected]

Definition at line 70 of file Segment.cpp.

References cbUsablePerPage.

Referenced by DelegatingSegment::DelegatingSegment(), DynamicDelegatingSegment::DynamicDelegatingSegment(), Segment(), and VersionedSegment::VersionedSegment().

00071 {
00072     cbUsablePerPage = cb;
00073 }

PConstBuffer Segment::getReadableFooter ( CachePage page  )  [protected]

Definition at line 75 of file Segment.cpp.

References CachePage::getReadableData(), and getUsablePageSize().

Referenced by VersionedSegment::getPageVersion(), and VersionedSegment::recover().

00076 {
00077     return page.getReadableData() + getUsablePageSize();
00078 }

PBuffer Segment::getWritableFooter ( CachePage page  )  [protected]

Definition at line 80 of file Segment.cpp.

References getUsablePageSize(), and CachePage::getWritableData().

Referenced by VersionedSegment::notifyPageDirty().

00081 {
00082     return page.getWritableData() + getUsablePageSize();
00083 }

PageId Segment::getLinearPageSuccessor ( PageId  pageId  )  [protected]

An implementation of getPageSuccessor suitable for LINEAR_ALLOCATION.

Definition at line 85 of file Segment.cpp.

References isPageIdAllocated(), and NULL_PAGE_ID.

Referenced by ScratchSegment::getPageSuccessor(), LinearViewSegment::getPageSuccessor(), LinearDeviceSegment::getPageSuccessor(), and CircularSegment::getPageSuccessor().

00086 {
00087     assert(isPageIdAllocated(pageId));
00088     ++pageId;
00089     if (!isPageIdAllocated(pageId)) {
00090         return NULL_PAGE_ID;
00091     }
00092     return pageId;
00093 }

void Segment::setLinearPageSuccessor ( PageId  pageId,
PageId  successorId 
) [protected]

An implementation of setPageSuccessor suitable for LINEAR_ALLOCATION.

Definition at line 95 of file Segment.cpp.

References getLinearBlockNum(), and isPageIdAllocated().

Referenced by ScratchSegment::setPageSuccessor(), LinearViewSegment::setPageSuccessor(), LinearDeviceSegment::setPageSuccessor(), and CircularSegment::setPageSuccessor().

00096 {
00097     assert(isPageIdAllocated(pageId));
00098     assert(isPageIdAllocated(successorId));
00099     assert(getLinearBlockNum(successorId)
00100            == getLinearBlockNum(pageId) + 1);
00101 }

bool Segment::isLinearPageIdAllocated ( PageId  pageId  )  [protected]

An implementation of isPageIdAllocated suitable for LINEAR_ALLOCATION when deallocation holes are disallowed.

Definition at line 103 of file Segment.cpp.

References getAllocatedSizeInPages(), and getLinearBlockNum().

Referenced by ScratchSegment::isPageIdAllocated(), LinearViewSegment::isPageIdAllocated(), and LinearDeviceSegment::isPageIdAllocated().

00104 {
00105     if (getLinearBlockNum(pageId) >= getAllocatedSizeInPages()) {
00106         return false;
00107     }
00108     return true;
00109 }

void Segment::closeImpl (  )  [protected, virtual]

Must be implemented by derived class to release any resources.

Implements ClosableObject.

Reimplemented in DelegatingSegment, DynamicDelegatingSegment, and ScratchSegment.

Definition at line 45 of file Segment.cpp.

References checkpoint(), and CHECKPOINT_FLUSH_AND_UNMAP.

Referenced by DynamicDelegatingSegment::closeImpl(), and DelegatingSegment::closeImpl().

00046 {
00047     checkpoint(CHECKPOINT_FLUSH_AND_UNMAP);
00048 }

SharedCache Segment::getCache (  )  const [inline]

Returns:
the Cache for this Segment

Definition at line 358 of file Segment.h.

References pCache.

Referenced by ScratchSegment::getCache(), and TempSegDestructor::operator()().

00359 {
00360     return pCache;
00361 }

uint Segment::getFullPageSize (  )  const

Returns:
the full size of pages stored in this segment; this is the same as the size of underlying cache pages

Definition at line 133 of file Segment.cpp.

References pCache.

Referenced by LinearDeviceSegment::ensureAllocatedSize(), LinearDeviceSegment::getAvailableDevicePages(), LinearDeviceSegment::LinearDeviceSegment(), VersionedRandomAllocationSegment::locateDataPages(), VersionedSegment::recover(), Segment(), and SegPageLock::swapBuffers().

00134 {
00135     return pCache->getPageSize();
00136 }

uint Segment::getUsablePageSize (  )  const [inline]

Returns:
the full size of pages stored in this segment minus the size for any footer information stored at the end of each page

Definition at line 363 of file Segment.h.

References cbUsablePerPage.

Referenced by VersionedSegment::computeChecksum(), DynamicDelegatingSegment::DynamicDelegatingSegment(), getReadableFooter(), getWritableFooter(), VersionedSegment::notifyPageDirty(), RandomAllocationSegment::RandomAllocationSegment(), RandomAllocationSegmentBase::RandomAllocationSegmentBase(), SegPageLock::swapBuffers(), VersionedRandomAllocationSegment::VersionedRandomAllocationSegment(), and VersionedSegment::VersionedSegment().

00364 {
00365     return cbUsablePerPage;
00366 }

void Segment::initForUse (  )  [virtual]

Performs additional initialization required on the segment after it has been properly formatted.

Reimplemented in RandomAllocationSegmentBase, and VersionedRandomAllocationSegment.

Definition at line 163 of file Segment.cpp.

00164 {
00165 }

virtual BlockNum Segment::getAllocatedSizeInPages (  )  [pure virtual]

Returns:
number of pages allocated from this segment

Implemented in CircularSegment, DelegatingSegment, DynamicDelegatingSegment, LinearDeviceSegment, LinearViewSegment, RandomAllocationSegmentBase, and ScratchSegment.

Referenced by ensureAllocatedSize(), and isLinearPageIdAllocated().

virtual BlockNum Segment::getNumPagesOccupiedHighWater (  )  [pure 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

Implemented in DelegatingSegment, DynamicDelegatingSegment, LinearDeviceSegment, RandomAllocationSegmentBase, and ScratchSegment.

virtual BlockNum Segment::getNumPagesExtended (  )  [pure virtual]

Returns:
the number of incremental pages added to this instance of the segment

Implemented in DelegatingSegment, DynamicDelegatingSegment, LinearDeviceSegment, and ScratchSegment.

SharedSegment Segment::getTracingSegment (  ) 

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

Referenced by VersionedRandomAllocationSegment::allocateAllocNodes(), RandomAllocationSegment::allocateFromExtent(), RandomAllocationSegment::allocateFromNewExtent(), RandomAllocationSegment::allocatePageId(), VersionedRandomAllocationSegment::backupAllocationNodes(), VersionedRandomAllocationSegment::chainPageEntries(), SnapshotRandomAllocationSegment::commitChanges(), VersionedRandomAllocationSegment::copyPageEntryFromTemp(), VersionedRandomAllocationSegment::copyPageEntryToTemp(), RandomAllocationSegmentBase::deallocatePageId(), VersionedRandomAllocationSegment::findAllocPageIdForRead(), RandomAllocationSegmentBase::format(), RandomAllocationSegmentBase::formatPageExtentsTemplate(), RandomAllocationSegmentBase::freePageEntryTemplate(), RandomAllocationSegment::getExtAllocPageIdForRead(), VersionedRandomAllocationSegment::getOldestTxnId(), VersionedRandomAllocationSegment::getOldPageIds(), RandomAllocationSegmentBase::getPageEntryCopyTemplate(), RandomAllocationSegment::getSegAllocPageIdForRead(), VersionedRandomAllocationSegment::getTempAllocNodePage(), 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  ) 

Sets the tracing segment associated with this segment.

Parameters:
pTracingSegmentInit the tracing segment

Definition at line 60 of file Segment.cpp.

References pTracingSegment.

00061 {
00062     pTracingSegment = pTracingSegmentInit;
00063 }

void Segment::checkpoint ( CheckpointType  checkpointType = CHECKPOINT_FLUSH_ALL  ) 

Checkpoints this segment.

Parameters:
checkpointType type of checkpoint to execute

Definition at line 111 of file Segment.cpp.

References delegatedCheckpoint(), and pTracingSegment.

Referenced by closeImpl(), BackupRestoreTest::createSnapshotData(), BackupRestoreTest::executeSnapshotTxn(), and LcsClusterReplaceExecStreamTest::testClusterReplace().

00112 {
00113     // Note that we can't use getTracingSegment() here because that method
00114     // references the shared ptr associated with this segment, and the
00115     // shared segment may have already been freed during shutdown by the
00116     // time this method is called.
00117     SharedSegment sharedPtr = pTracingSegment.lock();
00118     if (sharedPtr && sharedPtr.get()) {
00119         delegatedCheckpoint(*(sharedPtr.get()),checkpointType);
00120     } else {
00121         delegatedCheckpoint(*this,checkpointType);
00122     }
00123 }

void Segment::delegatedCheckpoint ( Segment delegatingSegment,
CheckpointType  checkpointType 
) [virtual]

Helper for DelegatingSegment.

Parameters:
delegatingSegment the Segment on which checkpoint was originally called
checkpointType type of checkpoint requested

Reimplemented in DelegatingSegment, DynamicDelegatingSegment, LinearDeviceSegment, SnapshotRandomAllocationSegment, TracingSegment, and VersionedSegment.

Definition at line 125 of file Segment.cpp.

References pCache.

Referenced by checkpoint(), and LinearDeviceSegment::delegatedCheckpoint().

00128 {
00129     MappedPageListenerPredicate pagePredicate(delegatingSegment);
00130     pCache->checkpointPages(pagePredicate,checkpointType);
00131 }

virtual PageId Segment::getPageSuccessor ( PageId  pageId  )  [pure virtual]

Determines the successor of a given PageId.

This is an optional interface only supported by segments with some concept of page ordering.

Parameters:
pageId PageId for which the successor is to be found
Returns:
successor PageId

Implemented in CircularSegment, DelegatingSegment, DynamicDelegatingSegment, LinearDeviceSegment, LinearViewSegment, RandomAllocationSegment, ScratchSegment, SnapshotRandomAllocationSegment, and VersionedRandomAllocationSegment.

virtual void Segment::setPageSuccessor ( PageId  pageId,
PageId  successorId 
) [pure virtual]

Sets the successor of a given PageId.

This is an optional interface only supported by segments with some concept of modifiable ordering.

Parameters:
pageId PageId for which the successor is to be set
successorId PageId of successor

Implemented in CircularSegment, DelegatingSegment, DynamicDelegatingSegment, LinearDeviceSegment, LinearViewSegment, RandomAllocationSegment, ScratchSegment, SnapshotRandomAllocationSegment, TracingSegment, and VersionedRandomAllocationSegment.

virtual AllocationOrder Segment::getAllocationOrder (  )  const [pure virtual]

Returns:
the AllocationOrder for this segment

Implemented in CircularSegment, DelegatingSegment, DynamicDelegatingSegment, LinearDeviceSegment, LinearViewSegment, RandomAllocationSegmentBase, and ScratchSegment.

virtual BlockId Segment::translatePageId ( PageId   )  [pure virtual]

Maps from a PageId in this segment to a BlockId.

Implemented in CircularSegment, DelegatingSegment, DynamicDelegatingSegment, LinearDeviceSegment, LinearViewSegment, RandomAllocationSegmentBase, ScratchSegment, SnapshotRandomAllocationSegment, and TracingSegment.

virtual PageId Segment::translateBlockId ( BlockId   )  [pure virtual]

Maps from a BlockId to a PageId in this segment.

Implemented in CircularSegment, DelegatingSegment, DynamicDelegatingSegment, LinearDeviceSegment, LinearViewSegment, ScratchSegment, and TracingSegment.

virtual PageId Segment::allocatePageId ( PageOwnerId  ownerId = ANON_PAGE_OWNER_ID  )  [pure virtual]

Allocates a page without locking it into memory.

Parameters:
ownerId the PageOwnerId of the object which will own this page, or ANON_PAGE_OWNER_ID for pages unassociated with an owner
Returns:
the PageId of the allocated page, or NULL_PAGE_ID if none could be allocated

Implemented in CircularSegment, DelegatingSegment, DynamicDelegatingSegment, LinearDeviceSegment, LinearViewSegment, RandomAllocationSegment, ScratchSegment, SnapshotRandomAllocationSegment, TracingSegment, and VersionedRandomAllocationSegment.

Referenced by ensureAllocatedSize().

bool Segment::ensureAllocatedSize ( BlockNum  nPages  )  [virtual]

Allocates pages as needed to make getAllocatedSizeInPages() meet a lower bound.

The PageId's of the allocated pages are not returned, so this is mostly only meaningful for linear segments.

Parameters:
nPages lower bound for getAllocatedSizeInPages()
Returns:
true if enough pages could be allocated; false if not

Reimplemented in DelegatingSegment, DynamicDelegatingSegment, LinearDeviceSegment, and TracingSegment.

Definition at line 138 of file Segment.cpp.

References allocatePageId(), getAllocatedSizeInPages(), and NULL_PAGE_ID.

00139 {
00140     while (getAllocatedSizeInPages() < nPages) {
00141         if (allocatePageId() == NULL_PAGE_ID) {
00142             return false;
00143         }
00144     }
00145     return true;
00146 }

virtual void Segment::deallocatePageRange ( PageId  startPageId,
PageId  endPageId 
) [pure 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

Implemented in CircularSegment, DelegatingSegment, DynamicDelegatingSegment, LinearDeviceSegment, LinearViewSegment, RandomAllocationSegmentBase, ScratchSegment, SnapshotRandomAllocationSegment, TracingSegment, VersionedRandomAllocationSegment, and VersionedSegment.

virtual bool Segment::isPageIdAllocated ( PageId  pageId  )  [pure virtual]

Tests whether a PageId is allocated.

Parameters:
pageId the PageId of interest
Returns:
true iff the PageId is currently allocated in this segment

Implemented in CircularSegment, DelegatingSegment, DynamicDelegatingSegment, LinearDeviceSegment, LinearViewSegment, RandomAllocationSegmentBase, ScratchSegment, and VersionedRandomAllocationSegment.

Referenced by getLinearPageSuccessor(), and setLinearPageSuccessor().

PageId Segment::updatePage ( PageId  pageId,
bool  needsTranslation = false 
) [virtual]

Determines whether a page can be updated in-place, and if so, prepares the page for update.

Parameters:
pageId pageId of the page being modified
needsTranslation true if the pageId needs to be mapped to the appropriate update page; defaults to false
Returns:
NULL_PAGE_ID if the page can be updated in place; otherwise, the pageId of the page that should be used when updates are made to the page

Reimplemented in DelegatingSegment, DynamicDelegatingSegment, LinearViewSegment, and SnapshotRandomAllocationSegment.

Definition at line 148 of file Segment.cpp.

References NULL_PAGE_ID.

00149 {
00150     return NULL_PAGE_ID;
00151 }

MappedPageListener * Segment::getMappedPageListener ( BlockId  blockId  )  [virtual]

Returns the mapped page listener corresponding to a page.

Parameters:
blockId blockId of the page whose page listener we are returning
Returns:
segment corresponding to mapped page listener

Reimplemented in DynamicDelegatingSegment, SnapshotRandomAllocationSegment, and TracingSegment.

Definition at line 153 of file Segment.cpp.

00154 {
00155     return this;
00156 }

bool Segment::isWriteVersioned (  )  [virtual]

Returns:
true if the segment supports versioning

Reimplemented in DynamicDelegatingSegment, SnapshotRandomAllocationSegment, and TracingSegment.

Definition at line 158 of file Segment.cpp.

00159 {
00160     return false;
00161 }

PageId Segment::getLinearPageId ( BlockNum  iPage  )  [inline, static]

Constructs a linear PageId based on a linear page number.

Definition at line 348 of file Segment.h.

Referenced by RandomAllocationSegmentBase::allocateFromLockedExtentTemplate(), ScratchSegment::allocatePageId(), LinearViewSegment::allocatePageId(), LinearDeviceSegment::allocatePageId(), CircularSegment::allocatePageId(), RandomAllocationSegmentBase::getExtentAllocPageId(), VersionedRandomAllocationSegment::getOldPageIds(), RandomAllocationSegmentBase::getSegAllocPageId(), Database::init(), VersionedRandomAllocationSegment::locateDataPages(), SegmentTestBase::lockPage(), SegmentTestBase::prefetchPage(), SegPageIterTest::testBoundedIter(), SegPageEntryIterTest::testBoundedIter(), ScratchSegment::translateBlockId(), LinearViewSegment::translateBlockId(), LinearDeviceSegment::translateBlockId(), CircularSegment::translateBlockId(), and CircularSegment::translatePageId().

00349 {
00350     return PageId(iPage);
00351 }

BlockNum Segment::getLinearBlockNum ( PageId  pageId  )  [inline, static]

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(), isLinearPageIdAllocated(), CircularSegment::isPageIdAllocated(), SegmentTestBase::lockPage(), SegInputStream::readPrevBuffer(), setLinearPageSuccessor(), RandomAllocationSegmentBase::splitPageId(), CircularSegment::translateBlockId(), ScratchSegment::translatePageId(), LinearViewSegment::translatePageId(), LinearDeviceSegment::translatePageId(), CircularSegment::translatePageId(), and LinearViewSegment::updatePage().

00354 {
00355     return opaqueToInt(pageId);
00356 }

MappedPageListener * Segment::getTracingListener (  )  [virtual]

Retrieves the tracing wrapper corresponding to this listener if tracing is turned on.

Otherwise, returns this listener itself.

Returns:
tracing segment corresponding to a listener

Implements MappedPageListener.

Definition at line 65 of file Segment.cpp.

References getTracingSegment().

00066 {
00067     return getTracingSegment().get();
00068 }

void MappedPageListener::notifyPageMap ( CachePage page  )  [virtual, inherited]

Receives notification from CacheImpl as soon as a page is mapped, before any I/O is initiated to retrieve the page contents.

Called with the page mutex held, so the implementation must take care to avoid deadlock.

Parameters:
page the page being mapped

Reimplemented in DelegatingSegment, DynamicDelegatingSegment, and TracingSegment.

Definition at line 29 of file MappedPageListener.cpp.

Referenced by CacheImpl< PageT, VictimPolicyT >::mapPage().

00030 {
00031 }

void MappedPageListener::notifyPageUnmap ( CachePage page  )  [virtual, inherited]

Receives notification from CacheImpl just before a page is unmapped.

Called with the page mutex held, so the implementation must take care to avoid deadlock.

Parameters:
page the page being unmapped

Reimplemented in DelegatingSegment, DynamicDelegatingSegment, TracingSegment, and WALSegment.

Definition at line 33 of file MappedPageListener.cpp.

00034 {
00035 }

void MappedPageListener::notifyAfterPageRead ( CachePage page  )  [virtual, inherited]

Receives notification from CacheImpl after a page read completes.

Called with the page mutex held, so the implementation must take care to avoid deadlock.

Parameters:
page the page read

Reimplemented in DelegatingSegment, DynamicDelegatingSegment, and TracingSegment.

Definition at line 37 of file MappedPageListener.cpp.

Referenced by CacheImpl< PageT, VictimPolicyT >::notifyTransferCompletion().

00038 {
00039 }

void MappedPageListener::notifyPageDirty ( CachePage page,
bool  bDataValid 
) [virtual, inherited]

Receives notification from CacheImpl the first time a page becomes dirty after it has been mapped (but before the contents have changed).

Allows some logging action to be taken; for example, making a backup copy of the unmodified page contents. Note that when called for a newly allocated page, the page contents are invalid. Because it is implied that the calling thread already has an exclusive lock on the page, no cache locks are held when called.

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 in DelegatingSegment, DynamicDelegatingSegment, SnapshotRandomAllocationSegment, TracingSegment, VersionedSegment, and WALSegment.

Definition at line 41 of file MappedPageListener.cpp.

00042 {
00043 }

bool MappedPageListener::canFlushPage ( CachePage page  )  [virtual, inherited]

Informs CacheImpl whether a dirty page can safely be flushed to disk.

Called with the page mutex held, so the implementation must take care to avoid deadlock.

Parameters:
page the page to be flushed

Reimplemented in DelegatingSegment, DynamicDelegatingSegment, SnapshotRandomAllocationSegment, and VersionedSegment.

Definition at line 53 of file MappedPageListener.cpp.

Referenced by CacheImpl< PageT, VictimPolicyT >::flushPage().

00054 {
00055     return true;
00056 }

void MappedPageListener::notifyBeforePageFlush ( CachePage page  )  [virtual, inherited]

Receives notification from CacheImpl just before a dirty page is flushed to disk.

Allows some logging action to be taken; for example, flushing corresponding write-ahead log pages, or storing a checksum in the page header. Called with the page mutex held, so the implementation must take care to avoid deadlock.

Parameters:
page the page to be flushed

Reimplemented in DelegatingSegment, DynamicDelegatingSegment, and TracingSegment.

Definition at line 45 of file MappedPageListener.cpp.

00046 {
00047 }

void MappedPageListener::notifyAfterPageFlush ( CachePage page  )  [virtual, inherited]

Receives notification from CacheImpl when a page flush completes successfully.

Called with the page mutex held, so the implementation must take care to avoid deadlock.

Parameters:
page the page that was flushed

Reimplemented in DelegatingSegment, DynamicDelegatingSegment, TracingSegment, and WALSegment.

Definition at line 49 of file MappedPageListener.cpp.

Referenced by CacheImpl< PageT, VictimPolicyT >::notifyTransferCompletion().

00050 {
00051 }

MappedPageListener * MappedPageListener::notifyAfterPageCheckpointFlush ( CachePage page  )  [virtual, inherited]

Receives notification that a page has been flushed during a checkpoint.

Also determines if the listener on the page needs to be reset.

Note that if the page listener is reset, that page may not be unmapped during a CHECKPOINT_FLUSH_AND_UNMAP checkpoint call.

This method should be called immediately after the page flush has completed while the checkpoint is still in progress.

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.

00059     {
00060         return !needsClose;
00061     }

void ClosableObject::close (  )  [inherited]

Closes this object, releasing any unallocated resources.

Reimplemented in CollectExecStream, CorrelationJoinExecStream, LcsClusterAppendExecStream, and LcsClusterReplaceExecStream.

Definition at line 39 of file ClosableObject.cpp.

References ClosableObject::closeImpl(), and ClosableObject::needsClose.

Referenced by CacheImpl< PageT, VictimPolicyT >::allocatePages(), LcsRowScanBaseExecStream::closeImpl(), ExecStreamGraphImpl::closeImpl(), FlatFileBuffer::open(), ClosableObjectDestructor::operator()(), and ~Segment().

00040 {
00041     if (!needsClose) {
00042         return;
00043     }
00044     needsClose = false;
00045     closeImpl();
00046 }


Member Data Documentation

uint Segment::cbUsablePerPage [private]

Number of usable bytes on each page before footer.

Definition at line 52 of file Segment.h.

Referenced by getUsablePageSize(), and setUsablePageSize().

SharedCache Segment::pCache [protected]

Cache managing pages of this segment.

Definition at line 62 of file Segment.h.

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

WeakSegment Segment::pTracingSegment [protected]

The tracing segment associated with this segment, if tracing is turned on.

A weak_ptr is used due to the circular shared pointers between this segment and its tracing segment.

Definition at line 69 of file Segment.h.

Referenced by checkpoint(), getTracingSegment(), and setTracingSegment().

bool ClosableObject::needsClose [protected, inherited]

Definition at line 44 of file ClosableObject.h.

Referenced by SegStreamAllocation::beginWrite(), ExecStreamGraphImpl::clear(), ClosableObject::ClosableObject(), ClosableObject::close(), FlatFileBuffer::open(), ExecStreamGraphImpl::open(), ExecStream::open(), and ClosableObject::~ClosableObject().


The documentation for this class was generated from the following files:
Generated on Mon Jun 22 04:00:45 2009 for Fennel by  doxygen 1.5.1