Class CachedPage
- All Implemented Interfaces:
Cacheable, TypedFormat, DerbyObserver, Page
- Direct Known Subclasses:
StoredPage
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected CacheManagerThe container cache my container lives in.private longprotected BaseDataFileFactoryMy factory class.protected intprotected booleanprotected static final intprotected CacheManagerThe page cache I live in.protected byte[]protected booleanstatic final intstatic final intFields inherited from class BasePage
identity, inClean, INIT_PAGE_OVERFLOW, INIT_PAGE_REUSE, INIT_PAGE_REUSE_RECORDID, INVALID_PAGE, LOG_RECORD_DEFAULT, LOG_RECORD_FOR_PURGE, LOG_RECORD_FOR_UPDATE, owner, preLatch, VALID_PAGEFields inherited from interface Page
DIAG_BYTES_FREE, DIAG_BYTES_RESERVED, DIAG_MAXROWSIZE, DIAG_MINIMUM_REC_SIZE, DIAG_MINROWSIZE, DIAG_NUMOVERFLOWED, DIAG_PAGE_SIZE, DIAG_PAGEOVERHEAD, DIAG_RESERVED_SPACE, DIAG_ROWSIZE, DIAG_SLOTTABLE_SIZE, FIRST_SLOT_NUMBER, INSERT_CONDITIONAL, INSERT_DEFAULT, INSERT_FOR_SPLIT, INSERT_INITIAL, INSERT_OVERFLOW, INSERT_UNDO_WITH_PURGE, INVALID_SLOT_NUMBER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate CachedPagechangeInstanceTo(int fid, PageKey newIdentity) Convert this page to requested type, as defined by input format id.voidclean(boolean remove) Write the page to disk.voidPut the object into the No Identity state.createIdentity(Object key, Object createParameter) Find the container and then create the page in that container.protected abstract voidcreatePage(PageKey id, PageCreationArgs args) protected byte[]Returns the page data array used to write on disk version.protected abstract voidinitFromData(FileContainer container, PageKey id) protected voidInitialize a CachedPage.booleanHas the page or its header been modified.booleanisDirty()Is the page dirty?voidpreDirty()Set state to indicate the page or its header is about to be modified.private voidreadPage(FileContainer myContainer, PageKey newIdentity) read the page from disk into this CachedPage object.protected voidexclusive latch on page is being released.voidsetContainerRowCount(long rowCount) Set the number of rows in the container - the page uses this to decide whether it needs to aggressive set the container's row count when it changes.protected voidsetDirty()Set state to indicate the page or its header has been modified.final voidsetFactory(BaseDataFileFactory factory) setIdentity(Object key) Find the container and then read the page from that container.protected voidsetPageArray(int pageSize) if the page size is different from the page buffer, then make a new page buffer and make subclass use the new page bufferprotected abstract voidusePageBuffer(byte[] buffer) protected abstract voidwriteFormatId(PageKey identity) protected abstract voidprivate voidwrite the page from this CachedPage object to disk.Methods inherited from class BasePage
allowInsert, appendOverflowFieldHeader, bumpPageVersion, bumpRecordCount, cleanPageForReuse, clearLastLogInstant, compactRecord, compactRecord, copyAndPurge, deallocatePage, deleteAtSlot, doUpdateAtSlot, entireRecordOnPage, fetchFieldFromSlot, fetchFromSlot, fetchNumFields, fetchNumFieldsAtSlot, fillInIdentity, findRecordById, getAuxObject, getHeaderAtSlot, getIdentity, getInvalidRecordHandle, getLastLogInstant, getNewOverflowPage, getNextSlotNumber, getOverflowPageForInsert, getPageId, getPageKey, getPageNumber, getPageStatus, getPageVersion, getRecordHandle, getRecordHandleAtSlot, getRecordLength, getReservedCount, getSlotNumber, getTotalSpace, initializeHeaders, initPage, initPage, insert, insertAllowOverflow, insertAtSlot, insertLongColumn, insertNoOverflow, internalDeletedRecordCount, internalNonDeletedRecordCount, isDeletedAtSlot, isDeletedOnPage, isLatched, isOverflowPage, isRepositionNeeded, logColumn, logField, logLongColumn, logRecord, logRow, makeRecordHandle, MakeRecordHandle, newRecordId, newRecordId, newRecordIdAndBump, nonDeletedRecordCount, purgeAtSlot, purgeRecord, purgeRowPieces, recordCount, recordExists, recordHeaderOnDemand, removeAndShiftDown, reserveSpaceForSlot, restorePortionLongColumn, restoreRecordFromSlot, restoreRecordFromStream, setAuxObject, setDeleteStatus, setDeleteStatus, setExclusive, setExclusiveNoWait, setHeaderAtSlot, setPageStatus, setPageStatus, setPageVersion, setRepositionNeeded, setReservedSpace, shiftUp, shouldReclaimSpace, skipField, skipRecord, slotTableToString, spaceForCopy, storeField, storeRecord, unfilled, unlatch, update, updateAtSlot, updateFieldAtSlot, updateFieldOverflowDetails, updateLastLogInstant, updateOverflowDetailsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Cacheable
getIdentityMethods inherited from interface Page
currentTimeStamp, equalTimeStamp, moveRecordForCompressAtSlot, setTimeStamp, spaceForInsert, spaceForInsertMethods inherited from interface TypedFormat
getTypeFormatId
-
Field Details
-
alreadyReadPage
protected boolean alreadyReadPage -
pageData
protected byte[] pageData -
isDirty
protected boolean isDirty -
preDirty
protected boolean preDirty -
initialRowCount
protected int initialRowCount -
containerRowCount
private long containerRowCount -
pageCache
The page cache I live in.
MT - Immutable -
containerCache
The container cache my container lives in.
MT - Immutable -
dataFactory
My factory class.
MT - Immutable - -
PAGE_FORMAT_ID_SIZE
protected static final int PAGE_FORMAT_ID_SIZE- See Also:
-
WRITE_SYNC
public static final int WRITE_SYNC- See Also:
-
WRITE_NO_SYNC
public static final int WRITE_NO_SYNC- See Also:
-
-
Constructor Details
-
CachedPage
public CachedPage()
-
-
Method Details
-
setFactory
-
initialize
protected void initialize()Initialize a CachedPage.Initialize the object, ie. perform work normally perfomed in constructor. Called by setIdentity() and createIdentity().
- Overrides:
initializein classBasePage
-
setIdentity
Find the container and then read the page from that container.This is the way new pages enter the page cache.
- Specified by:
setIdentityin interfaceCacheable- Returns:
- always true, higher levels have already checked the page number is valid for an open.
- Throws:
StandardException- Standard Derby policy.- See Also:
-
createIdentity
Find the container and then create the page in that container.This is the process of creating a new page in a container, in that case no need to read the page from disk - just need to initialize it in the cache.
- Specified by:
createIdentityin interfaceCacheable- Parameters:
key- Which page is this?createParameter- details needed to create page like size, format id, ...- Returns:
- new page, higher levels have already checked the page number is valid for an open.
- Throws:
StandardException- Standard exception policy.- See Also:
-
changeInstanceTo
Convert this page to requested type, as defined by input format id.The current cache entry is a different format id than the requested type, change it. This object is instantiated to the wrong subtype of cachedPage, this routine will create an object with the correct subtype, and transfer all pertinent information from this to the new correct object.
- Parameters:
fid- The format id of the new page.newIdentity- The key of the new page.- Returns:
- The new object created with the input fid and transfered info.
- Throws:
StandardException- Standard exception policy.
-
isDirty
public boolean isDirty()Is the page dirty?The isDirty flag indicates if the pageData or pageHeader has been modified. The preDirty flag indicates that the pageData or the pageHeader is about to be modified. The reason for these 2 flags instead of just one is to accomodate checkpoint. After a clean (latched) page sends a log record to the log stream but before that page is dirtied by the log operation, a checkpoint could be taken. If so, then the redoLWM will be after the log record but, without preDirty, the cache cleaning will not have waited for the change. So the preDirty bit is to stop the cache cleaning from skipping over this (latched) page even though it has not really been modified yet.
-
isActuallyDirty
public boolean isActuallyDirty()Has the page or its header been modified.See comment on class header on meaning of isDirty and preDirty bits.
- Returns:
- true if changes have actually been made to the page in memory.
-
preDirty
-
setDirty
protected void setDirty()Set state to indicate the page or its header has been modified.See comment on class header on meaning of isDirty and preDirty bits.
-
releaseExclusive
protected void releaseExclusive()exclusive latch on page is being released.The only work done in CachedPage is to update the row count on the container if it is too out of sync.
- Overrides:
releaseExclusivein classBasePage
-
clean
Write the page to disk.MP - In a simple world we would just not allow clean until it held the latch on the page. But in order to fit into the cache system, we don't have enough state around to just make clean() latch the page while doing the I/O - but we still need someway to insure that no changes happen to the page while the I/O is taking place. Also someday it would be fine to allow reads of this page while the I/O was taking place.
- Specified by:
cleanin interfaceCacheable- Throws:
StandardException- Error writing the page.- See Also:
-
clearIdentity
public void clearIdentity()Description copied from interface:CacheablePut the object into the No Identity state.
MT - single thread required - Method must only be called be cache manager and the cache manager will guarantee only one thread can be calling it.- Specified by:
clearIdentityin interfaceCacheable- Overrides:
clearIdentityin classBasePage
-
readPage
read the page from disk into this CachedPage object.A page is read in from disk into the pageData array of this object, and then put in the cache.
- Parameters:
myContainer- the container to read the page from.newIdentity- indentity (ie. page number) of the page to read- Throws:
StandardException- Standard exception policy.
-
writePage
write the page from this CachedPage object to disk.- Parameters:
identity- indentity (ie. page number) of the page to readsyncMe- does the write of this single page have to be sync'd?- Throws:
StandardException- Standard exception policy.
-
setContainerRowCount
public void setContainerRowCount(long rowCount) Description copied from class:BasePageSet the number of rows in the container - the page uses this to decide whether it needs to aggressive set the container's row count when it changes.- Specified by:
setContainerRowCountin classBasePage
-
setPageArray
protected void setPageArray(int pageSize) if the page size is different from the page buffer, then make a new page buffer and make subclass use the new page buffer -
getPageArray
Returns the page data array used to write on disk version.returns the page data array, that is actually written to the disk, when the page is cleaned from the page cache. Takes care of flushing in-memory information to the array (like page header and format id info).
- Specified by:
getPageArrayin classBasePage- Returns:
- The array of bytes that is the on disk version of page.
- Throws:
StandardException- Standard exception policy.
-
usePageBuffer
protected abstract void usePageBuffer(byte[] buffer) -
initFromData
- Throws:
StandardException
-
createPage
- Throws:
StandardException
-
writePage
- Throws:
StandardException
-
writeFormatId
- Throws:
StandardException
-