Fennel: CachePage Class Reference (original) (raw)
CachePage is a descriptor for the state of a page of cache memory. More...
#include <[CachePage.h](CachePage%5F8h-source.html)>
Inheritance diagram for CachePage:

| Public Types | |
|---|---|
| enum | DataStatus { DATA_INVALID, DATA_ERROR, DATA_CLEAN, DATA_DIRTY, DATA_WRITE, DATA_READ } |
| Enumeration of possible status of page data. More... | |
| Public Member Functions | |
| CachePage (Cache &, PBuffer) | |
| virtual | ~CachePage () |
| Cache & | getCache () |
| **Returns:**the cache which manages this page | |
| bool | isDirty () const |
| **Returns:**are the in-memory page contents different from those in the corresponding block on disk? | |
| bool | isTransferInProgress () const |
| **Returns:**is I/O currently in progress on this page? | |
| bool | isDataValid () const |
| **Returns:**is the page data valid? | |
| bool | isDataError () const |
| **Returns:**did the read required for mapping fail? | |
| BlockId | getBlockId () const |
| **Returns:**the mapped BlockId | |
| PConstBuffer | getReadableData () const |
| Obtains a const pointer to the page contents. | |
| PBuffer | getWritableData () |
| Obtains a writable pointer to the page contents, marking the page dirty. | |
| bool | isScratchLocked () const |
| **Returns:**true if page is currently locked as scratch memory | |
| MappedPageListener * | getMappedPageListener () const |
| **Returns:**the MappedPageListener associated with this page | |
| bool | tryUpgrade (TxnId txnId) |
| Attempts to upgrade from LOCKMODE_S (which caller must already have acquired) to LOCKMODE_X. | |
| void | upgrade (TxnId txnId) |
| Upgrades from LOCKMODE_S (which caller must already have acquired) to LOCKMODE_X. | |
| void | swapBuffers (CachePage &other) |
| Swaps this page's buffer with another page. | |
| Private Member Functions | |
| bool | hasBlockId () const |
| **Returns:**is the BlockId for this page currently set? | |
| void | waitForPendingIO (StrictMutexGuard &guard) |
| Waits for pending I/O to complete. | |
| bool | isExclusiveLockHeld () const |
| **Returns:**true if an exclusive lock is held on this page by some thread | |
| virtual void | notifyTransferCompletion (bool bSuccess) |
| Receives notification when a transfer completes. | |
| virtual PBuffer | getBuffer () const |
| **Returns:**memory address where transfer should start. | |
| virtual uint | getBufferSize () const |
| **Returns:**number of contiguous bytes from getBuffer() to be used for transfer. | |
| Private Attributes | |
| Cache & | cache |
| See also:getCache() | |
| StrictMutex | mutex |
| Mutex protecting this Page's state variables. | |
| SXMutex | lock |
| Synchronization object used to implement shared and exclusive locks. | |
| PBuffer | pBuffer |
| Allocated buffer memory, or NULL if page is currently unallocated. | |
| BlockId | blockId |
| The BlockId to which this page is currently mapped, or NULL_BLOCK_ID if unmapped. | |
| uint | nReferences |
| Reference count used to pin page so that it can't be victimized; this is equal to at least the number of locks currently held on this page, but may be higher due to the presence of threads which are still in the process of locking the page or otherwise manipulating it. | |
| LocalCondition | ioCompletionCondition |
| Condition variable used for notification of pending I/O completion. | |
| MappedPageListener * | pMappedPageListener |
| Listener to receive notifications of page writes, or NULL if no listener defined. | |
| DataStatus | dataStatus |
| Status of page data. | |
| Friends | |
| class | CacheImpl |
Detailed Description
CachePage is a descriptor for the state of a page of cache memory.
Once a CachePage has been mapped to some block of a Device and locked, its data can be read or written with the getReadableData() and getWritableData() member functions.
Definition at line 56 of file CachePage.h.
Member Enumeration Documentation
Enumeration of possible status of page data.
Order matters (valid data states are grouped together, as are I/O states).
Enumerator:
| DATA_INVALID | The page contents are invalid (either unmapped or newly allocated). |
|---|---|
| DATA_ERROR | The last transfer failed (so the page contents are invalid). |
| DATA_CLEAN | No transfer is in progress, and the page contains valid, unmodified data. |
| DATA_DIRTY | No transfer is in progress, and the page contains valid, dirty data. |
| DATA_WRITE | A disk write is in progress (so the page contains valid data). |
| DATA_READ | A disk read is in progress (so the page does not yet contain valid data). |
Definition at line 64 of file CachePage.h.
Constructor & Destructor Documentation
| CachePage::~CachePage | ( | | ) | [virtual] | | ---------------------- | - | | - | ----------- |
Member Function Documentation
| bool CachePage::hasBlockId | ( | | ) | const [inline, private] | | -------------------------- | - | | - | ------------------------- |
Waits for pending I/O to complete.
Note that this wraps a condition variable, which is subject to spurious wakeups; for this reason, the caller MUST enclose calls to this method in a while loop.
Definition at line 178 of file CachePage.h.
Referenced by CacheImpl< PageT, VictimPolicyT >::flushPage().
| bool CachePage::isExclusiveLockHeld | ( | | ) | const [inline, private] | | ----------------------------------- | - | | - | ------------------------- |
| void CachePage::notifyTransferCompletion | ( | bool | bSuccess | ) | [private, virtual] |
|---|
| PBuffer CachePage::getBuffer | ( | | ) | const [private, virtual] | | -------------------------------------------------------------------------------- | - | | - | -------------------------- |
| uint CachePage::getBufferSize | ( | | ) | const [private, virtual] | | ------------------------------------------------------------------------------------------ | - | | - | -------------------------- |
| Cache& CachePage::getCache | ( | | ) | [inline] | | --------------------------------------------- | - | | - | ---------- |
| bool CachePage::isDirty | ( | | ) | const [inline] | | ----------------------- | - | | - | ---------------- |
| bool CachePage::isTransferInProgress | ( | | ) | const [inline] | | ------------------------------------ | - | | - | ---------------- |
Returns:
is I/O currently in progress on this page?
Definition at line 223 of file CachePage.h.
| bool CachePage::isDataValid | ( | | ) | const [inline] | | --------------------------- | - | | - | ---------------- |
| bool CachePage::isDataError | ( | | ) | const [inline] | | --------------------------- | - | | - | ---------------- |
Returns:
did the read required for mapping fail?
Definition at line 239 of file CachePage.h.
| BlockId CachePage::getBlockId | ( | | ) | const [inline] | | ----------------------------- | - | | - | ---------------- |
Returns:
the mapped BlockId
Definition at line 247 of file CachePage.h.
Referenced by VersionedSegment::canFlushPage(), isScratchLocked(), TracingSegment::notifyAfterPageCheckpointFlush(), WALSegment::notifyAfterPageFlush(), TracingSegment::notifyAfterPageFlush(), TracingSegment::notifyAfterPageRead(), TracingSegment::notifyBeforePageFlush(), WALSegment::notifyPageDirty(), VersionedSegment::notifyPageDirty(), TracingSegment::notifyPageDirty(), TracingSegment::notifyPageMap(), TracingSegment::notifyPageUnmap(), CacheImpl< PageT, VictimPolicyT >::notifyTransferCompletion(), and DeviceIdPagePredicate::operator()().
00248 { 00249 return blockId; 00250 }
| PBuffer CachePage::getWritableData | ( | | ) | [inline] | | -------------------------------------------------------------------------------------- | - | | - | ---------- |
Obtains a writable pointer to the page contents, marking the page dirty.
The page must be locked in exclusive mode first. The number of valid bytes returned depends on the page size.
Returns:
pointer to the page contents
Definition at line 274 of file CachePage.h.
References Cache::getCache().
Referenced by LcsClusterNodeWriter::allocArrays(), LbmEntryTest::allocateBuf(), ExternalSortRunLoader::allocateBuffer(), BTreePrefetchSearchExecStream::allocateScratchPages(), LhxHashTable::allocBlock(), DoubleBufferExecStream::execute(), PagingTestBase::fillPage(), SegNodeLock< Node >::getNodeForWrite(), Segment::getWritableFooter(), LbmGeneratorExecStream::initBitmapTable(), LcsClusterAppendExecStream::initLoad(), SegPageBackupRestoreDevice::initScratchPages(), VersionedSegment::notifyPageDirty(), LbmUnionExecStream::open(), LbmChopperExecStream::open(), FlatFileExecStreamImpl::open(), ScratchBufferExecStream::open(), DoubleBufferExecStream::open(), VersionedSegment::recover(), SpillOutputStream::SpillOutputStream(), SegPageLock::swapBuffers(), and RandomAllocationSegmentTest::testAllocateAndDeallocate().
| bool CachePage::isScratchLocked | ( | | ) | const | | ------------------------------- | - | | - | ----- |
| bool CachePage::tryUpgrade | ( | TxnId | txnId | ) | [inline] |
|---|
| void CachePage::upgrade | ( | TxnId | txnId | ) | [inline] |
|---|
| void CachePage::swapBuffers | ( | CachePage & | other | ) |
|---|
Friends And Related Function Documentation
Member Data Documentation
Synchronization object used to implement shared and exclusive locks.
This is held for long durations (across cache lock/unlock calls).
Definition at line 120 of file CachePage.h.
Reference count used to pin page so that it can't be victimized; this is equal to at least the number of locks currently held on this page, but may be higher due to the presence of threads which are still in the process of locking the page or otherwise manipulating it.
Definition at line 143 of file CachePage.h.
Referenced by CachePage(), and ~CachePage().
The documentation for this class was generated from the following files:
- /home/pub/open/dev/fennel/cache/CachePage.h
- /home/pub/open/dev/fennel/cache/CachePage.cpp
