Cacheable
, TypedFormat
, Lockable
InputStreamContainer
, RAFContainer
abstract class FileContainer extends BaseContainer implements Cacheable, TypedFormat
Modifier and Type | Field | Description |
---|---|---|
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 reusable recordId sequence number
8 bytes long spare3
8 bytes long checksum
container info size is 80 bytes, with 10 bytes of spare space
|
protected 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 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 CacheManager |
pageCache |
|
protected int |
pageSize |
|
private static int |
PRE_ALLOC_THRESHOLD |
|
private int |
PreAllocSize |
|
private int |
PreAllocThreshold |
|
protected boolean |
preDirty |
|
private long |
reusableRecordIdSequenceNumber |
The sequence number for reusable recordIds .
|
protected static java.lang.String |
SPACE_TRACE |
|
protected int |
spareSpace |
identity, isCommittedDrop, isDropped, isReusableRecordId
Constructor | Description |
---|---|
FileContainer(BaseDataFileFactory factory) |
Modifier and Type | Method | Description |
---|---|---|
protected abstract void |
backupContainer(BaseContainerHandle handle,
java.lang.String backupLocation) |
backup the container.
|
protected void |
bumpContainerVersion(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.
|
(package private) abstract void |
closeContainer() |
|
protected void |
compressContainer(RawTransaction ntt,
BaseContainerHandle allocHandle) |
Compress free space from container.
|
(package private) abstract void |
createContainer(ContainerKey newIdentity) |
Create a new container.
|
protected Cacheable |
createIdent(ContainerKey newIdentity,
java.lang.Object createParameter) |
|
Cacheable |
createIdentity(java.lang.Object key,
java.lang.Object createParameter) |
Create a new item.
|
private void |
createInfoFromLog(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(LogInstant instant,
boolean isDropped) |
Drop Container.
|
protected byte[] |
encryptPage(byte[] pageData,
int pageSize,
byte[] encryptionBuffer,
boolean newEngine) |
Encrypts a page.
|
private AllocPage |
findAllocPageForAdd(BaseContainerHandle allocHandle,
RawTransaction ntt,
long lastAllocatedPage) |
|
private AllocPage |
findLastAllocPage(BaseContainerHandle handle,
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.
|
(package private) static ContextService |
getContextService() |
Privileged lookup of the ContextService.
|
protected byte[] |
getEmbryonicPage(java.io.DataInput fileData) |
Get an embryonic page from the dataInput stream.
|
(package private) byte[] |
getEmbryonicPage(StorageRandomAccessFile file,
long offset) |
Read an embryonic page (that is, a section of the first alloc page that
is so large that we know all the borrowed space is included in it) from
the specified offset in a
StorageRandomAccessFile . |
protected byte[] |
getEncryptionBuffer() |
Get encryption buffer.
|
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() |
|
protected long |
getLastPageNumber(BaseContainerHandle handle) |
|
private long |
getLastUnfilledPage() |
|
protected BasePage |
getLatchedPage(BaseContainerHandle handle,
long pageNumber) |
Get a latched page.
|
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) |
Get candidate page to move a row for compressing the table.
|
protected BasePage |
getPageForInsert(BaseContainerHandle handle,
int flag) |
Get a potentially suitable page for insert and latch it.
|
protected int |
getPageSize() |
|
long |
getReusableRecordIdSequenceNumber() |
Get the reusable RecordId sequence number for the container.
|
private static java.lang.Object |
getServiceModule(java.lang.Object serviceModule,
java.lang.String factoryInterface) |
Privileged module lookup.
|
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.
|
protected void |
incrementReusableRecordIdSequenceNumber() |
Increment the reusable RecordId version sequence number.
|
private void |
initContainerHeader(boolean changeContainer) |
|
private void |
initializeLastInsertedPage(int size) |
|
protected BasePage |
initPage(BaseContainerHandle allochandle,
PageKey pkey,
PageCreationArgs 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 ByteArray |
logCreateContainerInfo() |
Log all information on the container creation necessary to recreate the
container during a load tran.
|
private AllocPage |
makeAllocPage(RawTransaction ntt,
BaseContainerHandle handle,
long pageNumber,
long pageOffset,
int containerInfoSize) |
|
protected BasePage |
newPage(BaseContainerHandle userHandle,
RawTransaction ntt,
BaseContainerHandle allocHandle,
boolean isOverflow) |
Create a new page in the container.
|
(package private) abstract boolean |
openContainer(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(byte[] epage) |
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 |
reCreatePageForRedoRecovery(BaseContainerHandle handle,
int pageFormat,
long pageNumber,
long pageOffset) |
ReCreate a page for rollforward recovery.
|
protected void |
setDirty(boolean dirty) |
|
void |
setEstimatedRowCount(long count,
int flag) |
|
protected Cacheable |
setIdent(ContainerKey newIdentity) |
Open the container.
|
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.
|
(package private) void |
writeAtOffset(StorageRandomAccessFile file,
byte[] bytes,
long offset) |
Write a sequence of bytes at the given offset in a file.
|
protected void |
writeHeader(java.lang.Object identity,
byte[] pageData) |
Write the container header to a page array (the first allocation page)
|
protected void |
writeHeader(java.lang.Object identity,
StorageRandomAccessFile file,
boolean create,
byte[] epage) |
Write the container header directly to file.
|
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.
|
addPage, compressContainer, encryptOrDecryptContainer, 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
clean, getIdentity
protected static final int formatIdInteger
protected final CacheManager pageCache
protected final CacheManager containerCache
protected final BaseDataFileFactory dataFactory
protected int pageSize
protected int spareSpace
protected int minimumRecordSize
protected short initialPages
protected boolean canUpdate
private int PreAllocThreshold
private int PreAllocSize
private boolean bulkIncreaseContainerSize
private static final int PRE_ALLOC_THRESHOLD
private static final int MIN_PRE_ALLOC_SIZE
private static final int DEFAULT_PRE_ALLOC_SIZE
private static final int MAX_PRE_ALLOC_SIZE
protected long firstAllocPageNumber
protected long firstAllocPageOffset
protected long containerVersion
protected long estimatedRowCount
protected LogInstant lastLogInstant
private long reusableRecordIdSequenceNumber
private long[] lastInsertedPage
private int lastInsertedPage_index
private long lastUnfilledPage
private long lastAllocatedPage
private long estimatedPageCount
protected boolean preDirty
protected boolean isDirty
protected AllocationCache allocCache
byte[] containerInfo
private java.util.zip.CRC32 checksum
private byte[] encryptionBuffer
private static final int CONTAINER_FORMAT_ID_SIZE
protected static final int CHECKSUM_SIZE
protected static final int CONTAINER_INFO_SIZE
public static final long FIRST_ALLOC_PAGE_NUMBER
public static final long FIRST_ALLOC_PAGE_OFFSET
private static final int FILE_DROPPED
private static final int FILE_COMMITTED_DROP
private static final int FILE_REUSABLE_RECORDID
protected static final java.lang.String SPACE_TRACE
FileContainer(BaseDataFileFactory factory)
public int getTypeFormatId()
getTypeFormatId
in interface TypedFormat
public SpaceInfo getSpaceInfo(BaseContainerHandle handle) throws StandardException
getSpaceInfo
in class BaseContainer
StandardException
public Cacheable setIdentity(java.lang.Object key) throws StandardException
setIdentity
in interface Cacheable
StandardException
- Some problem in opening a container.Cacheable.setIdentity(java.lang.Object)
protected Cacheable setIdent(ContainerKey newIdentity) throws StandardException
Open the container with key "newIdentity".
should be same name as setIdentity but seems to cause method resolution ambiguities
StandardException
- Some problem in opening a container.Cacheable.setIdentity(java.lang.Object)
public Cacheable createIdentity(java.lang.Object key, java.lang.Object createParameter) throws StandardException
Cacheable
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.
createIdentity
in interface Cacheable
StandardException
- If forCreate is true and the object cannot be created.CacheManager.create(java.lang.Object, java.lang.Object)
protected Cacheable createIdent(ContainerKey newIdentity, java.lang.Object createParameter) throws StandardException
StandardException
public void clearIdentity()
Cacheable
clearIdentity
in interface Cacheable
clearIdentity
in class BaseContainer
public boolean isDirty()
isDirty
in interface Cacheable
Cacheable.isDirty()
public void preDirty(boolean preDirtyOn)
BaseContainer
preDirty
in class BaseContainer
protected void setDirty(boolean dirty)
abstract void createContainer(ContainerKey newIdentity) throws StandardException
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.
StandardException
- Derby Standard error policyabstract boolean openContainer(ContainerKey newIdentity) throws StandardException
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.
StandardException
- Standard exception policy.abstract void closeContainer()
protected void dropContainer(LogInstant instant, boolean isDropped)
dropContainer
in class BaseContainer
Transaction.dropContainer(org.apache.derby.iapi.store.raw.ContainerKey)
protected final void bumpContainerVersion(LogInstant instant)
protected long getContainerVersion()
BaseContainer
getContainerVersion
in class BaseContainer
public void getContainerProperties(java.util.Properties prop) throws StandardException
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 derby.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"); }
getContainerProperties
in class BaseContainer
prop
- Property list to fill in.StandardException
- Standard exception policy.protected void readHeader(byte[] epage) throws java.io.IOException, StandardException
epage
- the embryonic page to read the header fromStandardException
- Derby Standard error policyjava.io.IOException
- error in reading the header from fileprivate void initContainerHeader(boolean changeContainer)
private void readHeaderFromArray(byte[] a) throws StandardException, java.io.IOException
StandardException
- Derby Standard error policyjava.io.IOException
- error in reading the header from fileprotected void writeHeader(java.lang.Object identity, byte[] pageData) throws StandardException, java.io.IOException
StandardException
- Derby Standard error policyjava.io.IOException
- error in writing the header to fileprotected void writeHeader(java.lang.Object identity, StorageRandomAccessFile file, boolean create, byte[] epage) throws java.io.IOException, StandardException
StandardException
- Derby Standard error policyjava.io.IOException
- error in writing the header to filevoid writeAtOffset(StorageRandomAccessFile file, byte[] bytes, long offset) throws java.io.IOException, StandardException
file
- the file to write tobytes
- the bytes to writeoffset
- the offset to start writing atjava.io.IOException
- if an I/O error occurs while writingStandardException
- Derby Standard error policyprotected byte[] getEmbryonicPage(java.io.DataInput fileData) throws java.io.IOException, StandardException
java.io.IOException
- error in read the embryonic page from fileStandardException
- Derby Standard error policybyte[] getEmbryonicPage(StorageRandomAccessFile file, long offset) throws java.io.IOException, StandardException
StorageRandomAccessFile
. This method
is not thread safe, so the caller must make sure that no other thread
is performing operations that may change current position in the file.file
- the file to read fromoffset
- where to start reading (normally
FileContainer.FIRST_ALLOC_PAGE_OFFSET
)java.io.IOException
- if an I/O error occurs while readingStandardException
- Derby Standard error policyprivate void writeHeaderToArray(byte[] a) throws java.io.IOException
java.io.IOException
- error in writing the headerprotected ByteArray logCreateContainerInfo() throws StandardException
logCreateContainerInfo
in class BaseContainer
StandardException
- Derby Standard error policyprivate void createInfoFromLog(ByteArray byteArray) throws StandardException
StandardException
private void createInfoFromProp(java.util.Properties createArgs) throws StandardException
StandardException
protected boolean canUpdate()
BaseContainer
canUpdate
in class BaseContainer
protected void deallocatePage(BaseContainerHandle handle, BasePage page) throws StandardException
deallocatePage
in class BaseContainer
handle
- the container handle doing the deallocationpage
- the page to be deallocated. It is latched upon entry and
will be unlatched by the caller of this functionStandardException
- Derby Standard error policyprivate void deallocatePagenum(BaseContainerHandle handle, long pnum) throws StandardException
StandardException
protected void compressContainer(RawTransaction ntt, BaseContainerHandle allocHandle) throws StandardException
compressContainer
in class BaseContainer
ntt
- - the nested top transaction for the purpose of freeing space.
If ntt is null, use the user transaction for allocation.
#param allocHandle - the container handle opened by the ntt,
use this to latch the alloc pageStandardException
- Standard Derby error policypublic final long getReusableRecordIdSequenceNumber()
getReusableRecordIdSequenceNumber
in class BaseContainer
BaseContainer.getReusableRecordIdSequenceNumber()
protected final void incrementReusableRecordIdSequenceNumber()
incrementReusableRecordIdSequenceNumber
in class BaseContainer
protected BasePage newPage(BaseContainerHandle userHandle, RawTransaction ntt, BaseContainerHandle allocHandle, boolean isOverflow) throws StandardException
newPage
in class BaseContainer
userHandle
- - the container handle opened by the user transaction,
use this to latch the new user pagentt
- - the nested top transaction for the purpose of allocating the new page
If ntt is null, use the user transaction for allocation.
#param allocHandle - the container handle opened by the ntt,
use this to latch the alloc pageStandardException
- Standard Derby error policyprotected void clearPreallocThreshold()
BaseContainer
clearPreallocThreshold
in class BaseContainer
protected void prepareForBulkLoad(BaseContainerHandle handle, int numPage)
BaseContainer
prepareForBulkLoad
in class BaseContainer
private boolean pageValid(BaseContainerHandle handle, long pagenum) throws StandardException
StandardException
protected long getLastPageNumber(BaseContainerHandle handle) throws StandardException
StandardException
private AllocPage findAllocPageForAdd(BaseContainerHandle allocHandle, RawTransaction ntt, long lastAllocatedPage) throws StandardException
StandardException
private AllocPage findLastAllocPage(BaseContainerHandle handle, RawTransaction tran)
private AllocPage makeAllocPage(RawTransaction ntt, BaseContainerHandle handle, long pageNumber, long pageOffset, int containerInfoSize) throws StandardException
StandardException
protected BasePage initPage(BaseContainerHandle allochandle, PageKey pkey, PageCreationArgs createArgs, long pageOffset, boolean reuse, boolean overflow) throws StandardException
allochandle
- the contianer handle to initialize the page with - the nttpkey
- the page number of the page to be initializedcreateArgs
- the arguments for page creationreuse
- is true if we are reusing a page that has
already been initialized onceStandardException
- Derby Standard error policyprivate BasePage getUserPage(BaseContainerHandle handle, long pageNumber, boolean overflowOK, boolean wait) throws StandardException
handle
- the container handlepageNumber
- the page number of the page to getoverflowOK
- if true then an overflow page is OK,
if false, then only non-overflow page is OKwait
- if true then wait for a latchStandardException
- Standard Derby error policyprotected void trackUnfilledPage(long pagenumber, boolean unfilled)
protected BasePage getPage(BaseContainerHandle handle, long pageNumber, boolean wait) throws StandardException
getPage
in class BaseContainer
StandardException
- Standard Derby error policyprotected BasePage getAnyPage(BaseContainerHandle handle, long pageNumber) throws StandardException
getAnyPage
in class BaseContainer
StandardException
- Derby Standard error policyprotected BasePage reCreatePageForRedoRecovery(BaseContainerHandle handle, int pageFormat, long pageNumber, long pageOffset) throws StandardException
During redo recovery it is possible for the system to try to redo the creation of a page (ie. going from non-existence to version 0). It first trys to read the page from disk, but a few different types of errors can occur: o the page does not exist at all on disk, this can happen during rollforward recovery applied to a backup where the file was copied and the page was added to the file during the time frame of the backup but after the physical file was copied. o space in the file exists, but it was never initalized. This can happen if you happen to crash at just the right moment during the allocation process. Also on some OS's it is possible to read from a part of the file that was not ever written - resulting in garbage from the store's point of view (often the result is all 0's). All these errors are easy to recover from as the system can easily create a version 0 from scratch and write it to disk. Because the system does not sync allocation of data pages, it is also possible at this point that whlie writing the version 0 to disk to create it we may encounter an out of disk space error (caught in this routine as a StandardException from the create() call. We can't recovery from this without help from outside, so the caught exception is nested and a new exception thrown which the recovery system will output to the user asking them to check their disk for space/errors.
reCreatePageForRedoRecovery
in class BaseContainer
StandardException
- Standard exception policy.protected BasePage getAllocPage(long pageNumber) throws StandardException
getAllocPage
in class BaseContainer
StandardException
- Derby Standard error policyprotected BasePage getHeadPage(BaseContainerHandle handle, long pageNumber, boolean wait) throws StandardException
getHeadPage
in class BaseContainer
StandardException
- Derby Standard error policyprotected BasePage getFirstHeadPage(BaseContainerHandle handle, boolean wait) throws StandardException
getFirstHeadPage
in class BaseContainer
StandardException
- Derby Standard error policyprotected BasePage getNextHeadPage(BaseContainerHandle handle, long pageNumber, boolean wait) throws StandardException
getNextHeadPage
in class BaseContainer
StandardException
- Standard Derby error policyprivate BasePage getInsertablePage(BaseContainerHandle handle, long pageNumber, boolean wait, boolean overflowOK) throws StandardException
StandardException
protected BasePage getPageForCompress(BaseContainerHandle handle, int flag, long pageno) throws StandardException
The caller is moving rows from the end of the table toward the beginning, with the goal of freeing up a block of empty pages at the end of the container which can be returned to the OS.
On entry pageno will be latched by the caller. Only return pages with numbers below pageno. Attempting to return pageno will result in a latch/latch deadlock on the same thread.
getPageForCompress
in class BaseContainer
StandardException
- Standard exception policy.protected BasePage getPageForInsert(BaseContainerHandle handle, int flag) throws StandardException
getPageForInsert
in class BaseContainer
StandardException
- Standard Derby error policyprotected BasePage getLatchedPage(BaseContainerHandle handle, long pageNumber) throws StandardException
handle
- the container handle used to latch the pagepageNumber
- the page number of the page to getStandardException
- Standard Derby error policyprivate long getUnfilledPageNumber(BaseContainerHandle handle, long pagenum) throws StandardException
StandardException
public long getEstimatedRowCount(int flag)
getEstimatedRowCount
in class BaseContainer
ContainerHandle.getEstimatedRowCount(int)
public void setEstimatedRowCount(long count, int flag)
setEstimatedRowCount
in class BaseContainer
ContainerHandle.setEstimatedRowCount(long, int)
protected void updateEstimatedRowCount(int delta)
public long getEstimatedPageCount(BaseContainerHandle handle, int flag) throws StandardException
getEstimatedPageCount
in class BaseContainer
StandardException
- Standard Derby error policyContainerHandle.getEstimatedPageCount(int)
protected abstract void readPage(long pageNumber, byte[] pageData) throws java.io.IOException, StandardException
java.io.IOException
- error reading pageStandardException
- standard Derby error messageprotected abstract void writePage(long pageNumber, byte[] pageData, boolean syncPage) throws java.io.IOException, StandardException
java.io.IOException
- error writing pageStandardException
- Standard Derby error policyprotected void decryptPage(byte[] pageData, int pageSize) throws StandardException
StandardException
- Standard Derby error policyprotected byte[] encryptPage(byte[] pageData, int pageSize, byte[] encryptionBuffer, boolean newEngine) throws StandardException
StandardException
- Standard Derby error policyprotected byte[] getEncryptionBuffer()
protected abstract int preAllocate(long lastPreallocPagenum, int preAllocSize)
lastPreallocPagenum
- the last preallocated page number as known
by the allocation pagepreAllocSize
- try to preallocate this page number of pages.
Since only the container knows how many pages are actually on
disk, it may determine that certain number of pages that the
allocation page thinks need to be preallocated is already
allocated, in those case, act as if the preallocation is
successful.protected int doPreAllocatePages(long lastPreallocPagenum, int preAllocSize)
protected int getPageSize()
protected int getSpareSpace()
protected int getMinimumRecordSize()
private void switchToMultiInsertPageMode(BaseContainerHandle handle) throws StandardException
StandardException
private long getLastInsertedPage()
private long getLastUnfilledPage()
private void initializeLastInsertedPage(int size)
private void setLastInsertedPage(long val)
private void setLastUnfilledPage(long val)
protected void letGo(BaseContainerHandle handle)
letGo
in class BaseContainer
protected BasePage latchPage(BaseContainerHandle handle, BasePage foundPage, boolean wait) throws StandardException
latchPage
in class BaseContainer
StandardException
protected abstract void backupContainer(BaseContainerHandle handle, java.lang.String backupLocation) throws StandardException
backupContainer
in class BaseContainer
handle
- the container handle.backupLocation
- location of the backup container.StandardException
- Standard Derby error policystatic ContextService getContextService()
private static java.lang.Object getServiceModule(java.lang.Object serviceModule, java.lang.String factoryInterface)
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.