|
|||||||||
| Home >> All >> org >> apache >> derby >> impl >> store >> raw >> [ data overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.derby.impl.store.raw.data
Class FileContainer

java.lang.Objectorg.apache.derby.impl.store.raw.data.BaseContainer
org.apache.derby.impl.store.raw.data.FileContainer
- All Implemented Interfaces:
- org.apache.derby.iapi.services.cache.Cacheable, org.apache.derby.iapi.services.locks.Lockable, org.apache.derby.iapi.services.io.TypedFormat
- Direct Known Subclasses:
- InputStreamContainer, RAFContainer
- public abstract class FileContainer
- extends BaseContainer
- implements org.apache.derby.iapi.services.cache.Cacheable, org.apache.derby.iapi.services.io.TypedFormat
- extends BaseContainer
FileContainer is an abstract base class for containers which are based on files. This class extends BaseContainer and implements Cacheable and TypedFormat
| Field Summary | |
protected static int |
ALLOC_PAGE_ARG_NUM
|
protected AllocationCache |
allocCache
|
private boolean |
bulkIncreaseContainerSize
|
protected boolean |
canUpdate
|
private java.util.zip.CRC32 |
checksum
|
protected static int |
CHECKSUM_SIZE
|
private static int |
CONTAINER_FORMAT_ID_SIZE
the container format must fit in this many bytes |
protected static int |
CONTAINER_INFO_SIZE
The size of the persistently stored container info ContainerHeader contains the following information: 4 bytes int FormatId 4 bytes int status 4 bytes int pageSize 4 bytes int spareSpace 4 bytes int minimumRecordSize 2 bytes short initialPages 2 bytes short spare1 8 bytes long first Allocation page number 8 bytes long first Allocation page offset 8 bytes long container version 8 bytes long estimated number of rows 8 bytes long spare2 8 bytes long spare3 8 bytes long checksum container info size is 80 bytes, with 20 bytes of spare space |
protected org.apache.derby.iapi.services.cache.CacheManager |
containerCache
|
(package private) byte[] |
containerInfo
|
protected long |
containerVersion
|
protected BaseDataFileFactory |
dataFactory
|
private static int |
DEFAULT_PRE_ALLOC_SIZE
|
private byte[] |
encryptionBuffer
|
private long |
estimatedPageCount
An estimated page count. |
protected long |
estimatedRowCount
|
private static int |
FILE_COMMITTED_DROP
|
private static int |
FILE_DROPPED
|
private static int |
FILE_REUSABLE_RECORDID
|
static long |
FIRST_ALLOC_PAGE_NUMBER
where the first alloc page is located - the logical page number and the physical page offset NOTE if it is not 0 this is not going to work for Stream file which doesn't support seek |
static long |
FIRST_ALLOC_PAGE_OFFSET
|
protected long |
firstAllocPageNumber
|
protected long |
firstAllocPageOffset
|
protected static int |
formatIdInteger
|
protected short |
initialPages
|
protected boolean |
isDirty
|
private long |
lastAllocatedPage
The last allocated page. |
private long[] |
lastInsertedPage
The page that was last inserted into. |
private int |
lastInsertedPage_index
|
protected org.apache.derby.iapi.store.raw.log.LogInstant |
lastLogInstant
|
private long |
lastUnfilledPage
The last unfilled page found. |
private static int |
MAX_PRE_ALLOC_SIZE
|
private static int |
MIN_PRE_ALLOC_SIZE
|
protected int |
minimumRecordSize
|
protected org.apache.derby.iapi.services.cache.CacheManager |
pageCache
|
protected int |
pageSize
|
private static int |
PRE_ALLOC_THRESHOLD
|
private int |
PreAllocSize
|
private int |
PreAllocThreshold
|
protected boolean |
preDirty
|
protected static java.lang.String |
SPACE_TRACE
|
protected int |
spareSpace
|
protected static int |
STORED_PAGE_ARG_NUM
the number of arguments we need to pass to alloc page for create |
| Fields inherited from class org.apache.derby.impl.store.raw.data.BaseContainer |
identity, isCommittedDrop, isDropped, isReusableRecordId |
| Constructor Summary | |
protected |
FileContainer(BaseDataFileFactory factory)
|
| Method Summary | |
protected void |
bumpContainerVersion(org.apache.derby.iapi.store.raw.log.LogInstant instant)
increment the version by one and return the new version. |
protected boolean |
canUpdate()
Can the container be updated. |
void |
clearIdentity()
Put the object into the No Identity state. |
protected void |
clearPreallocThreshold()
The container will have no pre-allocate threshold, i.e., if the implementation supports it, page preallocation will happen the next time a new page is allocated. |
protected abstract void |
closeContainer()
|
protected void |
compressContainer(org.apache.derby.iapi.store.raw.xact.RawTransaction ntt,
BaseContainerHandle allocHandle)
Compress free space from container. |
protected abstract void |
createContainer(org.apache.derby.iapi.store.raw.ContainerKey newIdentity)
Create a new container. |
protected org.apache.derby.iapi.services.cache.Cacheable |
createIdent(org.apache.derby.iapi.store.raw.ContainerKey newIdentity,
java.lang.Object createParameter)
|
org.apache.derby.iapi.services.cache.Cacheable |
createIdentity(java.lang.Object key,
java.lang.Object createParameter)
Create a new item. |
private void |
createInfoFromLog(org.apache.derby.iapi.util.ByteArray byteArray)
Set container properties from the passed in ByteArray, which is created by logCreateContainerInfo. |
private void |
createInfoFromProp(java.util.Properties createArgs)
Set container properties from the passed in createArgs. |
protected void |
deallocatePage(BaseContainerHandle handle,
BasePage page)
Deallocate a page from the container. |
private void |
deallocatePagenum(BaseContainerHandle handle,
long pnum)
deallocate the page from the alloc page |
protected void |
decryptPage(byte[] pageData,
int pageSize)
Decrypts a page MT - MT safe. |
protected int |
doPreAllocatePages(long lastPreallocPagenum,
int preAllocSize)
Preallocate the pages - actually doing it, called by subclass only |
protected void |
dropContainer(org.apache.derby.iapi.store.raw.log.LogInstant instant,
boolean isDropped)
Drop Container. |
protected byte[] |
encryptPage(byte[] pageData,
int pageSize)
Encrypts a page. |
private AllocPage |
findAllocPageForAdd(BaseContainerHandle allocHandle,
org.apache.derby.iapi.store.raw.xact.RawTransaction ntt,
long lastAllocatedPage)
|
private AllocPage |
findLastAllocPage(BaseContainerHandle handle,
org.apache.derby.iapi.store.raw.xact.RawTransaction tran)
Find the last alloc page, returns null if no alloc page is found |
protected BasePage |
getAllocPage(long pageNumber)
Get an alloc page - only accessible to the raw store (container and recovery) |
protected BasePage |
getAnyPage(BaseContainerHandle handle,
long pageNumber)
Get any old page - turn off all validation |
void |
getContainerProperties(java.util.Properties prop)
Request the system properties associated with a container. |
protected long |
getContainerVersion()
Get the logged container version. |
protected byte[] |
getEmbryonicPage(java.io.DataInput fileData)
Get an embryonic page from the dataInput stream. |
long |
getEstimatedPageCount(BaseContainerHandle handle,
int flag)
|
long |
getEstimatedRowCount(int flag)
MT - this routine is NOT MT-safe and clients don't need to provide synchronization. |
protected BasePage |
getFirstHeadPage(BaseContainerHandle handle,
boolean wait)
Get the first valid page in the container |
protected BasePage |
getHeadPage(BaseContainerHandle handle,
long pageNumber,
boolean wait)
Get only a valid, non-overflow page. |
private BasePage |
getInsertablePage(BaseContainerHandle handle,
long pageNumber,
boolean wait,
boolean overflowOK)
|
private long |
getLastInsertedPage()
|
private long |
getLastPageNumber(BaseContainerHandle handle)
|
private long |
getLastUnfilledPage()
|
protected int |
getMinimumRecordSize()
|
protected BasePage |
getNextHeadPage(BaseContainerHandle handle,
long pageNumber,
boolean wait)
Get the next page in the container. |
protected BasePage |
getPage(BaseContainerHandle handle,
long pageNumber,
boolean wait)
Get a valid (non-deallocated or free) page in the container. |
protected BasePage |
getPageForCompress(BaseContainerHandle handle,
int flag,
long pageno)
|
protected BasePage |
getPageForInsert(BaseContainerHandle handle,
int flag)
Get a potentially suitable page for insert and latch it. |
protected int |
getPageSize()
|
org.apache.derby.iapi.store.access.SpaceInfo |
getSpaceInfo(BaseContainerHandle handle)
Get information about space used by the container. |
protected int |
getSpareSpace()
|
int |
getTypeFormatId()
Return my format identifier. |
private long |
getUnfilledPageNumber(BaseContainerHandle handle,
long pagenum)
|
private BasePage |
getUserPage(BaseContainerHandle handle,
long pageNumber,
boolean overflowOK,
boolean wait)
Get a page in the container. |
private void |
initContainerHeader(boolean changeContainer)
|
private void |
initializeLastInsertedPage(int size)
|
protected BasePage |
initPage(BaseContainerHandle allochandle,
org.apache.derby.iapi.store.raw.PageKey pkey,
int[] createArgs,
long pageOffset,
boolean reuse,
boolean overflow)
Initialize a page |
boolean |
isDirty()
We treat this container as dirty if it has the container file open. |
protected BasePage |
latchPage(BaseContainerHandle handle,
BasePage foundPage,
boolean wait)
|
protected void |
letGo(BaseContainerHandle handle)
The container is kept by the find() in File.openContainer. |
protected org.apache.derby.iapi.util.ByteArray |
logCreateContainerInfo()
Log all information on the container creation necessary to recreate the container during a load tran. |
private AllocPage |
makeAllocPage(org.apache.derby.iapi.store.raw.xact.RawTransaction ntt,
BaseContainerHandle handle,
long pageNumber,
long pageOffset,
int containerInfoSize)
|
protected BasePage |
newPage(BaseContainerHandle userHandle,
org.apache.derby.iapi.store.raw.xact.RawTransaction ntt,
BaseContainerHandle allocHandle,
boolean isOverflow)
Create a new page in the container. |
protected abstract boolean |
openContainer(org.apache.derby.iapi.store.raw.ContainerKey newIdentity)
Open a container. |
private boolean |
pageValid(BaseContainerHandle handle,
long pagenum)
|
protected abstract int |
preAllocate(long lastPreallocPagenum,
int preAllocSize)
preAllocate writes out the preallocated pages to disk if necessary. |
void |
preDirty(boolean preDirtyOn)
The container is about to be modified. |
protected void |
prepareForBulkLoad(BaseContainerHandle handle,
int numPage)
The container will be grown vastly, prepare for it. |
protected void |
readHeader(java.io.DataInput fileData)
Read the container's header. |
private void |
readHeaderFromArray(byte[] a)
Read containerInfo from a byte array The container Header array must be written by or of the same format as put together by writeHeaderFromArray. |
protected abstract void |
readPage(long pageNumber,
byte[] pageData)
Read a page into the supplied array. |
protected BasePage |
reCreatePageForLoadTran(BaseContainerHandle handle,
int pageFormat,
long pageNumber,
long pageOffset)
ReCreate a page for load tran/rollforward recovery. |
protected void |
setDirty(boolean dirty)
|
void |
setEstimatedRowCount(long count,
int flag)
|
protected org.apache.derby.iapi.services.cache.Cacheable |
setIdent(org.apache.derby.iapi.store.raw.ContainerKey newIdentity)
Open the container. |
org.apache.derby.iapi.services.cache.Cacheable |
setIdentity(java.lang.Object key)
Open the container. |
private void |
setLastInsertedPage(long val)
|
private void |
setLastUnfilledPage(long val)
|
private void |
switchToMultiInsertPageMode(BaseContainerHandle handle)
|
protected void |
trackUnfilledPage(long pagenumber,
boolean unfilled)
|
protected void |
updateEstimatedRowCount(int delta)
Update estimated row count by page as it leaves the cache. |
protected void |
writeHeader(byte[] pageData)
Write the container header to a page array (the first allocation page) |
protected void |
writeHeader(java.io.DataOutput fileData,
boolean create,
byte[] epage)
Write the container header directly to output stream (fileData). |
private void |
writeHeaderToArray(byte[] a)
Write containerInfo into a byte array The container Header thus put together can be read by readHeaderFromArray. |
protected abstract void |
writePage(long pageNumber,
byte[] pageData,
boolean syncPage)
Write a page from the supplied array. |
| Methods inherited from class org.apache.derby.impl.store.raw.data.BaseContainer |
addPage, compressContainer, fillInIdentity, flushAll, getAllocPage, getAnyPage, getCommittedDropState, getContainerId, getContainerStatus, getDeallocLock, getDroppedState, getFirstPage, getIdentity, getNextPage, getSegmentId, isReusableRecordId, lockAttributes, lockerAlwaysCompatible, lockEvent, removeContainer, removePage, requestCompatible, setCommittedDropState, setDroppedState, setReusableRecordIdState, truncate, truncatePages, unlockEvent, use |
| 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 |
clean, getIdentity |
| Field Detail |
formatIdInteger
protected static final int formatIdInteger
- See Also:
- Constant Field Values
pageCache
protected final org.apache.derby.iapi.services.cache.CacheManager pageCache
containerCache
protected final org.apache.derby.iapi.services.cache.CacheManager containerCache
dataFactory
protected final BaseDataFileFactory dataFactory
pageSize
protected int pageSize
spareSpace
protected int spareSpace
minimumRecordSize
protected int minimumRecordSize
initialPages
protected short initialPages
canUpdate
protected boolean canUpdate
PreAllocThreshold
private int PreAllocThreshold
PreAllocSize
private int PreAllocSize
bulkIncreaseContainerSize
private boolean bulkIncreaseContainerSize
PRE_ALLOC_THRESHOLD
private static final int PRE_ALLOC_THRESHOLD
- See Also:
- Constant Field Values
MIN_PRE_ALLOC_SIZE
private static final int MIN_PRE_ALLOC_SIZE
- See Also:
- Constant Field Values
DEFAULT_PRE_ALLOC_SIZE
private static final int DEFAULT_PRE_ALLOC_SIZE
- See Also:
- Constant Field Values
MAX_PRE_ALLOC_SIZE
private static final int MAX_PRE_ALLOC_SIZE
- See Also:
- Constant Field Values
firstAllocPageNumber
protected long firstAllocPageNumber
firstAllocPageOffset
protected long firstAllocPageOffset
containerVersion
protected long containerVersion
estimatedRowCount
protected long estimatedRowCount
lastLogInstant
protected org.apache.derby.iapi.store.raw.log.LogInstant lastLogInstant
lastInsertedPage
private long[] lastInsertedPage
- The page that was last inserted into. Use this for getPageForInsert.
Remember the last allocated non-overflow page, and remember it in
memory only.
Use Get/Set method to access this field except when we know it is
being single thread access.
lastInsertedPage_index
private int lastInsertedPage_index
lastUnfilledPage
private long lastUnfilledPage
- The last unfilled page found. Use this for getPageForInsert.
Remember the last unfilled page found, and remember it in memory only.
Use Get/Set method to access this field except when we know it is
being single thread access.
lastAllocatedPage
private long lastAllocatedPage
- The last allocated page. This global var is access *without*
synchronization. It is used as a hint for page allocation to find the
next reusable page.
estimatedPageCount
private long estimatedPageCount
- An estimated page count. Use this for getEstimatedPagecount.
Remember it in memory only.
preDirty
protected boolean preDirty
isDirty
protected boolean isDirty
allocCache
protected AllocationCache allocCache
containerInfo
byte[] containerInfo
checksum
private java.util.zip.CRC32 checksum
encryptionBuffer
private byte[] encryptionBuffer
CONTAINER_FORMAT_ID_SIZE
private static final int CONTAINER_FORMAT_ID_SIZE
- the container format must fit in this many bytes
- See Also:
- Constant Field Values
CHECKSUM_SIZE
protected static final int CHECKSUM_SIZE
- See Also:
- Constant Field Values
CONTAINER_INFO_SIZE
protected static final int CONTAINER_INFO_SIZE
- The size of the persistently stored container info
ContainerHeader contains the following information:
4 bytes int FormatId
4 bytes int status
4 bytes int pageSize
4 bytes int spareSpace
4 bytes int minimumRecordSize
2 bytes short initialPages
2 bytes short spare1
8 bytes long first Allocation page number
8 bytes long first Allocation page offset
8 bytes long container version
8 bytes long estimated number of rows
8 bytes long spare2
8 bytes long spare3
8 bytes long checksum
container info size is 80 bytes, with 20 bytes of spare space
- See Also:
- Constant Field Values
STORED_PAGE_ARG_NUM
protected static final int STORED_PAGE_ARG_NUM
- the number of arguments we need to pass to alloc page for create
- See Also:
- Constant Field Values
ALLOC_PAGE_ARG_NUM
protected static final int ALLOC_PAGE_ARG_NUM
- See Also:
- Constant Field Values
FIRST_ALLOC_PAGE_NUMBER
public static final long FIRST_ALLOC_PAGE_NUMBER
- where the first alloc page is located -
the logical page number and the physical page offset
NOTE if it is not 0 this is not going to work for Stream
file which doesn't support seek
- See Also:
- Constant Field Values
FIRST_ALLOC_PAGE_OFFSET
public static final long FIRST_ALLOC_PAGE_OFFSET
- See Also:
- Constant Field Values
FILE_DROPPED
private static final int FILE_DROPPED
- See Also:
- Constant Field Values
FILE_COMMITTED_DROP
private static final int FILE_COMMITTED_DROP
- See Also:
- Constant Field Values
FILE_REUSABLE_RECORDID
private static final int FILE_REUSABLE_RECORDID
- See Also:
- Constant Field Values
SPACE_TRACE
protected static final java.lang.String SPACE_TRACE
| Constructor Detail |
FileContainer
protected FileContainer(BaseDataFileFactory factory)
| Method Detail |
getTypeFormatId
public int getTypeFormatId()
- Return my format identifier.
- Specified by:
getTypeFormatIdin interfaceorg.apache.derby.iapi.services.io.TypedFormat
getSpaceInfo
public org.apache.derby.iapi.store.access.SpaceInfo getSpaceInfo(BaseContainerHandle handle) throws org.apache.derby.iapi.error.StandardException
- Get information about space used by the container.
- Specified by:
getSpaceInfoin classBaseContainer
setIdentity
public org.apache.derby.iapi.services.cache.Cacheable setIdentity(java.lang.Object key) throws org.apache.derby.iapi.error.StandardException
- Open the container.
- Specified by:
setIdentityin interfaceorg.apache.derby.iapi.services.cache.Cacheable
setIdent
protected org.apache.derby.iapi.services.cache.Cacheable setIdent(org.apache.derby.iapi.store.raw.ContainerKey newIdentity) throws org.apache.derby.iapi.error.StandardException
- Open the container.
Open the container with key "newIdentity".
should be same name as setIdentity but seems to cause method resolution ambiguities
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
- Description copied from interface:
org.apache.derby.iapi.services.cache.Cacheable - Create a new item.
Create a new item and set the identity of the object to represent it. The object will be in the No Identity state, ie. it will have just been created or clearIdentity() was just called.
The object must copy the information out of key, not just store a reference to key if the key is not immutable. After this call the expression getIdentity().equals(key) must return true.
If the class of the object needs to change (e.g. to support a different format) then the object should create a new object, call its initParameter() with the parameters the original object was called with, set its identity and return a reference to it. The cache manager will discard the reference to the old object.
If an exception is thrown the object must be left in 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:
createIdentityin interfaceorg.apache.derby.iapi.services.cache.Cacheable
createIdent
protected org.apache.derby.iapi.services.cache.Cacheable createIdent(org.apache.derby.iapi.store.raw.ContainerKey newIdentity, java.lang.Object createParameter) throws org.apache.derby.iapi.error.StandardException
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:
clearIdentityin interfaceorg.apache.derby.iapi.services.cache.Cacheable- Overrides:
clearIdentityin classBaseContainer
isDirty
public boolean isDirty()
- We treat this container as dirty if it has the container file open.
- Specified by:
isDirtyin interfaceorg.apache.derby.iapi.services.cache.Cacheable
preDirty
public void preDirty(boolean preDirtyOn)
- Description copied from class:
BaseContainer - The container is about to be modified.
Loggable actions use this to make sure the container gets cleaned if a
checkpoint is taken after any log record is sent to the log stream but
before the container is actually dirtied.
- Specified by:
preDirtyin classBaseContainer
setDirty
protected void setDirty(boolean dirty)
createContainer
protected abstract void createContainer(org.apache.derby.iapi.store.raw.ContainerKey newIdentity) throws org.apache.derby.iapi.error.StandardException
- Create a new container.
Create a new container, all references to identity must be through the passed in identity, this object will no identity until after this method returns.
openContainer
protected abstract boolean openContainer(org.apache.derby.iapi.store.raw.ContainerKey newIdentity) throws org.apache.derby.iapi.error.StandardException
- Open a container.
Longer descrption of routine.
Open a container. Open the file that maps to this container, if the file does not exist then we assume the container was never created. If the file exists but we have trouble opening it then we throw some exception.
MT - single thread required - Enforced by cache manager.
closeContainer
protected abstract void closeContainer()
dropContainer
protected void dropContainer(org.apache.derby.iapi.store.raw.log.LogInstant instant, boolean isDropped)
- Drop Container.
- Specified by:
dropContainerin classBaseContainer
bumpContainerVersion
protected final void bumpContainerVersion(org.apache.derby.iapi.store.raw.log.LogInstant instant)
- increment the version by one and return the new version.
MT - caller must synchronized this in the same sync block that modifies the container header.
getContainerVersion
protected long getContainerVersion()
- Description copied from class:
BaseContainer - Get the logged container version.
- Specified by:
getContainerVersionin classBaseContainer
getContainerProperties
public void getContainerProperties(java.util.Properties prop) throws org.apache.derby.iapi.error.StandardException
- Request the system properties associated with a container.
Request the value of properties that are associated with a container. The following properties can be requested: derby.storage.pageSize derby.storage.pageReservedSpace derby.storage.minimumRecordSize derby.storage.reusableRecordId cloudsacpe.storage.initialPages
To get the value of a particular property add it to the property list, and on return the value of the property will be set to it's current value. For example: get_prop(ConglomerateController cc) { Properties prop = new Properties(); prop.put("derby.storage.pageSize", ""); cc.getContainerProperties(prop); System.out.println( "table's page size = " + prop.getProperty("derby.storage.pageSize"); }
- Specified by:
getContainerPropertiesin classBaseContainer
readHeader
protected void readHeader(java.io.DataInput fileData) throws java.io.IOException, org.apache.derby.iapi.error.StandardException
- Read the container's header. Assumes the input stream (fileData)
is positioned at the beginning of the file.
Subclass that implements openContainer is expected to manufacture a DataInput
stream which is used here to read the header.
MT - single thread required - Enforced by caller.
initContainerHeader
private void initContainerHeader(boolean changeContainer)
readHeaderFromArray
private void readHeaderFromArray(byte[] a)
throws org.apache.derby.iapi.error.StandardException,
java.io.IOException
- Read containerInfo from a byte array
The container Header array must be written by or of
the same format as put together by writeHeaderFromArray.
writeHeader
protected void writeHeader(byte[] pageData)
throws org.apache.derby.iapi.error.StandardException,
java.io.IOException
- Write the container header to a page array (the first allocation page)
writeHeader
protected void writeHeader(java.io.DataOutput fileData, boolean create, byte[] epage) throws java.io.IOException, org.apache.derby.iapi.error.StandardException
- Write the container header directly to output stream (fileData).
Assumes the output stream is positioned at the beginning of the file.
Subclasses that can writes the container header is expected to
manufacture a DataOutput stream which is used here.
MT - single thread required - Enforced by caller
getEmbryonicPage
protected byte[] getEmbryonicPage(java.io.DataInput fileData) throws java.io.IOException
- Get an embryonic page from the dataInput stream.
If fileData is not null, then the embyronic page will be read
in from the input stream (fileData), which is assumed to be
positioned at the beginning of the first allocation page.
if fileData is null, then just manufacture an array which
is the size of an embryonic page.
writeHeaderToArray
private void writeHeaderToArray(byte[] a)
throws java.io.IOException
- Write containerInfo into a byte array
The container Header thus put together can be read by readHeaderFromArray.
logCreateContainerInfo
protected org.apache.derby.iapi.util.ByteArray logCreateContainerInfo() throws org.apache.derby.iapi.error.StandardException
- Log all information on the container creation necessary to recreate the
container during a load tran.
- Specified by:
logCreateContainerInfoin classBaseContainer
createInfoFromLog
private void createInfoFromLog(org.apache.derby.iapi.util.ByteArray byteArray) throws org.apache.derby.iapi.error.StandardException
- Set container properties from the passed in ByteArray, which is created
by logCreateContainerInfo. This information is used to recreate the
container during recovery load tran.
The following container properties are set:
pageSize
spareSpace
minimumRecordSize
isReusableRecordId
initialPages
createInfoFromProp
private void createInfoFromProp(java.util.Properties createArgs) throws org.apache.derby.iapi.error.StandardException
- Set container properties from the passed in createArgs.
The following container properties are set:
pageSize
spareSpace
minimumRecordSize
isReusableRecordId
initialPages
RESOLVE - in the future setting parameters should be overridable
by sub-class, e.g. one implementation of Container may require a
minimum page size of 4k.
canUpdate
protected boolean canUpdate()
- Description copied from class:
BaseContainer - Can the container be updated.
- Specified by:
canUpdatein classBaseContainer
deallocatePage
protected void deallocatePage(BaseContainerHandle handle, BasePage page) throws org.apache.derby.iapi.error.StandardException
- Deallocate a page from the container.
- Specified by:
deallocatePagein classBaseContainer
deallocatePagenum
private void deallocatePagenum(BaseContainerHandle handle, long pnum) throws org.apache.derby.iapi.error.StandardException
- deallocate the page from the alloc page
compressContainer
protected void compressContainer(org.apache.derby.iapi.store.raw.xact.RawTransaction ntt, BaseContainerHandle allocHandle) throws org.apache.derby.iapi.error.StandardException
- Compress free space from container.
MT - thread aware - It is assumed that our caller (our super class) has already arranged a logical lock on page allocation to only allow a single thread through here. Compressing free space is done in allocation page units, working it's way from the end of the container to the beginning. Each loop operates on the last allocation page in the container. Freeing space in the container page involves 2 transactions, an update to an allocation page, N data pages, and possibly the delete of the allocation page. The User Transaction (UT) initiated the compress call. The Nested Top Transaction (NTT) is the transaction started by RawStore inside the compress call. This NTT is committed before compress returns. The NTT is used to access high traffic data structures such as the AllocPage. This is outline of the algorithm used in compressing the container. Until a non free page is found loop, in each loop return to the OS all space at the end of the container occupied by free pages, including the allocation page itself if all of it's pages are free. 1) Find last 2 allocation pages in container (last if there is only one). 2) invalidate the allocation information cached by the container. Without the cache no page can be gotten from the container. Pages already in the page cache are not affected. Thus by latching the allocPage and invalidating the allocation cache, this NTT blocks out all page gets from this container until it commits. 3) the allocPage determines which pages can be released to the OS, mark that in its data structure (the alloc extent). Mark the contiguous block of nallocated/free pages at the end of the file as unallocated. This change is associated with the NTT. 4) The NTT calls the OS to deallocate the space from the file. Note that the system can handle being booted and asked to get an allocated page which is past end of file, it just extends the file automatically. 5) If freeing all space on the alloc page, and there is more than one alloc page, then free the alloc page - this requires an update to the previous alloc page which the loop has kept latched also. 6) if the last alloc page was deleted, restart loop at #1 All NTT latches are released before this routine returns. If we use an NTT, the caller has to commit the NTT to release the allocPage latch. If we don't use an NTT, the allocPage latch is released as this routine returns.- Specified by:
compressContainerin classBaseContainer
newPage
protected BasePage newPage(BaseContainerHandle userHandle, org.apache.derby.iapi.store.raw.xact.RawTransaction ntt, BaseContainerHandle allocHandle, boolean isOverflow) throws org.apache.derby.iapi.error.StandardException
- Create a new page in the container.
MT - thread aware - It is assumed that our caller (our super class) has already arranged a logical lock on page allocation to only allow a single thread through here. Adding a new page involves 2 transactions and 2 pages. The User Transaction (UT) initiated the addPage call and expects a latched page (owns by the UT) to be returned. The Nested Top Transaction (NTT) is the transaction started by RawStore inside an addPage call. This NTT is committed before the page is returned. The NTT is used to accessed high traffic data structure such as the AllocPage. This is outline of the algorithm used in adding a page: 1) find or make an allocPage which can handle the addding of a new page. Latch the allocPage with the NTT. 2) invalidate the allocation information cached by the container. Without the cache no page can be gotten from the container. Pages already in the page cache is not affected. Thus by latching the allocPage and invalidating the allocation cache, this NTT blocks out all page gets from this container until it commits. 3) the allocPage determines which page can be allocated, mark that in its data structure (the alloc extent) and returns the page number of the new page. This change is associated with the NTT. 4) the NTT gets or creates the new page in the page cache (bypassing the lookup of the allocPage since that is already latched by the NTT and will deadlock). 5) the NTT initializes the page (mark it is being a VALID page). 6) the page latch is transfered to the UT from the NTT. 7) the new page is returned, latched by UT If we use an NTT, the caller has to commit the NTT to release the allocPage latch. If we don't use an NTT, the allocPage latch is released as this routine returns.- Specified by:
newPagein classBaseContainer
clearPreallocThreshold
protected void clearPreallocThreshold()
- Description copied from class:
BaseContainer - The container will have no pre-allocate threshold, i.e., if the
implementation supports it, page preallocation will happen
the next time a new page is allocated.
- Specified by:
clearPreallocThresholdin classBaseContainer
prepareForBulkLoad
protected void prepareForBulkLoad(BaseContainerHandle handle, int numPage)
- Description copied from class:
BaseContainer - The container will be grown vastly, prepare for it.
- Specified by:
prepareForBulkLoadin classBaseContainer
pageValid
private boolean pageValid(BaseContainerHandle handle, long pagenum) throws org.apache.derby.iapi.error.StandardException
getLastPageNumber
private long getLastPageNumber(BaseContainerHandle handle) throws org.apache.derby.iapi.error.StandardException
findAllocPageForAdd
private AllocPage findAllocPageForAdd(BaseContainerHandle allocHandle, org.apache.derby.iapi.store.raw.xact.RawTransaction ntt, long lastAllocatedPage) throws org.apache.derby.iapi.error.StandardException
findLastAllocPage
private AllocPage findLastAllocPage(BaseContainerHandle handle, org.apache.derby.iapi.store.raw.xact.RawTransaction tran)
- Find the last alloc page, returns null if no alloc page is found
makeAllocPage
private AllocPage makeAllocPage(org.apache.derby.iapi.store.raw.xact.RawTransaction ntt, BaseContainerHandle handle, long pageNumber, long pageOffset, int containerInfoSize)
JAVADOC