public abstract class CachedPage extends BasePage implements Cacheable
Modifier and Type | Field and Description |
---|---|
protected boolean |
alreadyReadPage |
protected CacheManager |
containerCache
The container cache my container lives in.
|
private long |
containerRowCount |
protected BaseDataFileFactory |
dataFactory
My factory class.
|
protected int |
initialRowCount |
protected boolean |
isDirty |
protected static int |
PAGE_FORMAT_ID_SIZE |
protected CacheManager |
pageCache
The page cache I live in.
|
protected byte[] |
pageData |
protected boolean |
preDirty |
static int |
WRITE_NO_SYNC |
static int |
WRITE_SYNC |
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_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 and Description |
---|
CachedPage() |
Modifier and Type | Method and Description |
---|---|
private CachedPage |
changeInstanceTo(int fid,
PageKey newIdentity)
Convert this page to requested type, as defined by input format id.
|
void |
clean(boolean remove)
Write the page to disk.
|
void |
clearIdentity()
Put the object into the No Identity state.
|
Cacheable |
createIdentity(java.lang.Object key,
java.lang.Object createParameter)
Find the container and then create the page in that container.
|
protected abstract void |
createPage(PageKey id,
PageCreationArgs args) |
protected byte[] |
getPageArray()
Returns the page data array used to write on disk version.
|
protected abstract void |
initFromData(FileContainer container,
PageKey id) |
protected void |
initialize()
Initialize a CachedPage.
|
boolean |
isActuallyDirty()
Has the page or its header been modified.
|
boolean |
isDirty()
Is the page dirty?
|
void |
preDirty()
Set state to indicate the page or its header is about to be modified.
|
private void |
readPage(FileContainer myContainer,
PageKey newIdentity)
read the page from disk into this CachedPage object.
|
protected void |
releaseExclusive()
exclusive latch on page is being released.
|
void |
setContainerRowCount(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 void |
setDirty()
Set state to indicate the page or its header has been modified.
|
void |
setFactory(BaseDataFileFactory factory) |
Cacheable |
setIdentity(java.lang.Object key)
Find the container and then read the page from that container.
|
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
|
protected abstract void |
usePageBuffer(byte[] buffer) |
protected abstract void |
writeFormatId(PageKey identity) |
protected abstract void |
writePage(PageKey id) |
private void |
writePage(PageKey identity,
boolean syncMe)
write the page from this CachedPage object to disk.
|
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, updateOverflowDetails
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getIdentity
currentTimeStamp, equalTimeStamp, moveRecordForCompressAtSlot, setTimeStamp, spaceForInsert, spaceForInsert
getTypeFormatId
protected boolean alreadyReadPage
protected byte[] pageData
protected boolean isDirty
protected boolean preDirty
protected int initialRowCount
private long containerRowCount
protected CacheManager pageCache
protected CacheManager containerCache
protected BaseDataFileFactory dataFactory
protected static final int PAGE_FORMAT_ID_SIZE
public static final int WRITE_SYNC
public static final int WRITE_NO_SYNC
public final void setFactory(BaseDataFileFactory factory)
protected void initialize()
Initialize the object, ie. perform work normally perfomed in constructor. Called by setIdentity() and createIdentity().
initialize
in class BasePage
public Cacheable setIdentity(java.lang.Object key) throws StandardException
This is the way new pages enter the page cache.
setIdentity
in interface Cacheable
StandardException
- Standard Derby policy.Cacheable.setIdentity(java.lang.Object)
public Cacheable createIdentity(java.lang.Object key, java.lang.Object createParameter) throws StandardException
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.
createIdentity
in interface Cacheable
key
- Which page is this?createParameter
- details needed to create page like size,
format id, ...StandardException
- Standard exception policy.Cacheable.createIdentity(java.lang.Object, java.lang.Object)
private CachedPage changeInstanceTo(int fid, PageKey newIdentity) throws StandardException
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.
fid
- The format id of the new page.newIdentity
- The key of the new page.StandardException
- Standard exception policy.public boolean isDirty()
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.
isDirty
in interface Cacheable
Cacheable.isDirty()
public boolean isActuallyDirty()
See comment on class header on meaning of isDirty and preDirty bits.
public void preDirty()
See comment on class header on meaning of isDirty and preDirty bits.
protected void setDirty()
See comment on class header on meaning of isDirty and preDirty bits.
protected void releaseExclusive()
The only work done in CachedPage is to update the row count on the container if it is too out of sync.
releaseExclusive
in class BasePage
public void clean(boolean remove) throws StandardException
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.
clean
in interface Cacheable
StandardException
- Error writing the page.Cacheable.clean(boolean)
public void clearIdentity()
Cacheable
clearIdentity
in interface Cacheable
clearIdentity
in class BasePage
private void readPage(FileContainer myContainer, PageKey newIdentity) throws StandardException
A page is read in from disk into the pageData array of this object, and then put in the cache.
myContainer
- the container to read the page from.newIdentity
- indentity (ie. page number) of the page to readStandardException
- Standard exception policy.private void writePage(PageKey identity, boolean syncMe) throws StandardException
identity
- indentity (ie. page number) of the page to readsyncMe
- does the write of this single page have to be sync'd?StandardException
- Standard exception policy.public void setContainerRowCount(long rowCount)
BasePage
setContainerRowCount
in class BasePage
protected void setPageArray(int pageSize)
protected byte[] getPageArray() throws StandardException
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).
getPageArray
in class BasePage
StandardException
- Standard exception policy.protected abstract void usePageBuffer(byte[] buffer)
protected abstract void initFromData(FileContainer container, PageKey id) throws StandardException
StandardException
protected abstract void createPage(PageKey id, PageCreationArgs args) throws StandardException
StandardException
protected abstract void writePage(PageKey id) throws StandardException
StandardException
protected abstract void writeFormatId(PageKey identity) throws StandardException
StandardException
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.