Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.impl.store.raw.data
Class CachedPage  view CachedPage download CachedPage.java

java.lang.Object
  extended byorg.apache.derby.impl.store.raw.data.BasePage
      extended byorg.apache.derby.impl.store.raw.data.CachedPage
All Implemented Interfaces:
org.apache.derby.iapi.services.cache.Cacheable, org.apache.derby.iapi.services.locks.Lockable, java.util.Observer, org.apache.derby.iapi.store.raw.Page, org.apache.derby.iapi.services.io.TypedFormat
Direct Known Subclasses:
StoredPage

public abstract class CachedPage
extends BasePage
implements org.apache.derby.iapi.services.cache.Cacheable

A base page that is cached. Since there are multiple page formats, use this abstract class to implement cacheable interface.


Field Summary
protected  boolean alreadyReadPage
           
protected  org.apache.derby.iapi.services.cache.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  org.apache.derby.iapi.services.cache.CacheManager pageCache
          The page cache I live in.
protected  byte[] pageData
           
protected  boolean preDirty
           
static int WRITE_NO_SYNC
           
static int WRITE_SYNC
           
 
Fields inherited from class org.apache.derby.impl.store.raw.data.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_PAGE
 
Fields inherited from interface org.apache.derby.iapi.store.raw.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
CachedPage()
           
 
Method Summary
private  CachedPage changeInstanceTo(int fid, org.apache.derby.iapi.store.raw.PageKey newIdentity)
           
 void clean(boolean remove)
          Write the page to disk.
 void clearIdentity()
          Put the object into the No Identity state.
 org.apache.derby.iapi.services.cache.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(org.apache.derby.iapi.store.raw.PageKey id, int[] args)
           
protected abstract  void initFromData(FileContainer container, org.apache.derby.iapi.store.raw.PageKey id)
           
protected  void initialize()
          Initialize a CachedPage.
 boolean isActuallyDirty()
          Has the page or its header been modified.
 boolean isDirty()
          Has the page or its header been modified or about to be modified.
 void preDirty()
          The page or its header is about to be modified.
private  void readPage(FileContainer myContainer, org.apache.derby.iapi.store.raw.PageKey newIdentity)
           
protected  void releaseExclusive()
          Ensure that container row count is updated if it is too out of sync
 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()
           
 void setFactory(BaseDataFileFactory factory)
           
 org.apache.derby.iapi.services.cache.Cacheable setIdentity(java.lang.Object key)
          Find the container and then read the page from that container.
protected  void setPageArray(int pageSize)
           
protected abstract  void usePageBuffer(byte[] buffer)
           
protected abstract  void writeFormatId(org.apache.derby.iapi.store.raw.PageKey identity)
           
protected abstract  void writePage(org.apache.derby.iapi.store.raw.PageKey id)
           
private  void writePage(org.apache.derby.iapi.store.raw.PageKey identity, boolean syncMe)
           
 
Methods inherited from class org.apache.derby.impl.store.raw.data.BasePage
allowInsert, appendOverflowFieldHeader, bumpPageVersion, bumpRecordCount, cleanPageForReuse, clearLastLogInstant, compactRecord, compactRecord, copyAndPurge, deallocatePage, delete, deleteAtSlot, doUpdateAtSlot, entireRecordOnPage, fetch, fetchFieldFromSlot, fetchFromSlot, fetchNumFields, fetchNumFieldsAtSlot, fillInIdentity, findRecordById, getAuxObject, getHeaderAtSlot, getIdentity, getInvalidRecordHandle, getLastLogInstant, getNewOverflowPage, getNextSlotNumber, getOverflowPageForInsert, getPageId, getPageNumber, getPageStatus, getPageVersion, getRecordHandle, getRecordHandleAtSlot, getRecordLength, getReservedCount, getSlotNumber, getTotalSpace, initializeHeaders, initPage, initPage, insert, insertAllowOverflow, insertAtSlot, insertLongColumn, insertNoOverflow, internalDeletedRecordCount, internalNonDeletedRecordCount, isDeletedAtSlot, isDeletedOnPage, isLatched, isOverflowPage, lockAttributes, lockerAlwaysCompatible, lockEvent, logColumn, logField, logLongColumn, logRecord, logRow, makeRecordHandle, MakeRecordHandle, newRecordId, newRecordId, newRecordIdAndBump, nonDeletedRecordCount, purgeAtSlot, purgeRecord, purgeRowPieces, recordCount, recordExists, recordHeaderOnDemand, removeAndShiftDown, requestCompatible, reserveSpaceForSlot, restorePortionLongColumn, restoreRecordFromSlot, restoreRecordFromStream, setAuxObject, setDeleteStatus, setDeleteStatus, setExclusive, setExclusiveNoWait, setHeaderAtSlot, setPageStatus, setPageStatus, setPageVersion, setReservedSpace, shiftUp, skipField, skipRecord, slotTableToString, spaceForCopy, storeField, storeRecord, unfilled, unlatch, unlockEvent, update, update, updateAtSlot, updateFieldAtSlot, updateFieldOverflowDetails, updateLastLogInstant, updateOverflowDetails
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.derby.iapi.services.cache.Cacheable
getIdentity
 
Methods inherited from interface org.apache.derby.iapi.store.raw.Page
currentTimeStamp, equalTimeStamp, moveRecordForCompressAtSlot, setTimeStamp, spaceForInsert, spaceForInsert
 
Methods inherited from interface org.apache.derby.iapi.services.io.TypedFormat
getTypeFormatId
 

Field Detail

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

protected org.apache.derby.iapi.services.cache.CacheManager pageCache
The page cache I live in.
MT - Immutable


containerCache

protected org.apache.derby.iapi.services.cache.CacheManager containerCache
The container cache my container lives in.
MT - Immutable


dataFactory

protected BaseDataFileFactory dataFactory
My factory class.
MT - Immutable -


PAGE_FORMAT_ID_SIZE

protected static final int PAGE_FORMAT_ID_SIZE
See Also:
Constant Field Values

WRITE_SYNC

public static final int WRITE_SYNC
See Also:
Constant Field Values

WRITE_NO_SYNC

public static final int WRITE_NO_SYNC
See Also:
Constant Field Values
Constructor Detail

CachedPage

public CachedPage()
Method Detail

setFactory

public final void setFactory(BaseDataFileFactory factory)

initialize

protected void initialize()
Initialize a CachedPage.

Initialize the object, ie. perform work normally perfomed in constructor. Called by setIdentity() and createIdentity().

Overrides:
initialize in class BasePage

setIdentity

public org.apache.derby.iapi.services.cache.Cacheable setIdentity(java.lang.Object key)
                                                           throws org.apache.derby.iapi.error.StandardException
Find the container and then read the page from that container.

Specified by:
setIdentity in interface org.apache.derby.iapi.services.cache.Cacheable

createIdentity

public org.apache.derby.iapi.services.cache.Cacheable createIdentity(java.lang.Object key,
                                                                     java.lang.Object createParameter)
                                                              throws org.apache.derby.iapi.error.StandardException
Find the container and then create the page in that container.

Specified by:
createIdentity in interface org.apache.derby.iapi.services.cache.Cacheable

changeInstanceTo

private CachedPage changeInstanceTo(int fid,
                                    org.apache.derby.iapi.store.raw.PageKey newIdentity)
                             throws org.apache.derby.iapi.error.StandardException

isDirty

public boolean isDirty()
Has the page or its header been modified or about to be modified. See comment on class header on meaning of isDirty and preDirty bits.

Specified by:
isDirty in interface org.apache.derby.iapi.services.cache.Cacheable

isActuallyDirty

public boolean isActuallyDirty()
Has the page or its header been modified. See comment on class header on meaning of isDirty and preDirty bits.


preDirty

public void preDirty()
The page or its header is about to be modified. See comment on class header on meaning of isDirty and preDirty bits.

Specified by:
preDirty in class BasePage

releaseExclusive

protected void releaseExclusive()
Ensure that container row count is updated if it is too out of sync

Overrides:
releaseExclusive in class BasePage

setDirty

protected void setDirty()

clean

public void clean(boolean remove)
           throws org.apache.derby.iapi.error.StandardException
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. So first

Specified by:
clean in interface org.apache.derby.iapi.services.cache.Cacheable

clearIdentity

public void clearIdentity()
Description copied from interface: org.apache.derby.iapi.services.cache.Cacheable
Put 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:
clearIdentity in interface org.apache.derby.iapi.services.cache.Cacheable
Overrides:
clearIdentity in class BasePage

readPage

private void readPage(FileContainer myContainer,
                      org.apache.derby.iapi.store.raw.PageKey newIdentity)
               throws org.apache.derby.iapi.error.StandardException

writePage

private void writePage(org.apache.derby.iapi.store.raw.PageKey identity,
                       boolean syncMe)
                throws org.apache.derby.iapi.error.StandardException

setContainerRowCount

public void setContainerRowCount(long rowCount)
Description copied from class: BasePage
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.

Specified by:
setContainerRowCount in class BasePage

setPageArray

protected void setPageArray(int pageSize)
                     throws org.apache.derby.iapi.error.StandardException

usePageBuffer

protected abstract void usePageBuffer(byte[] buffer)

initFromData

protected abstract void initFromData(FileContainer container,
                                     org.apache.derby.iapi.store.raw.PageKey id)
                              throws org.apache.derby.iapi.error.StandardException

createPage

protected abstract void createPage(org.apache.derby.iapi.store.raw.PageKey id,
                                   int[] args)
                            throws org.apache.derby.iapi.error.StandardException

writePage

protected abstract void writePage(org.apache.derby.iapi.store.raw.PageKey id)
                           throws org.apache.derby.iapi.error.StandardException

writeFormatId

protected abstract void writeFormatId(org.apache.derby.iapi.store.raw.PageKey identity)
                               throws org.apache.derby.iapi.error.StandardException