Class InputStreamContainer
java.lang.Object
org.apache.derby.impl.store.raw.data.BaseContainer
org.apache.derby.impl.store.raw.data.FileContainer
org.apache.derby.impl.store.raw.data.InputStreamContainer
- All Implemented Interfaces:
Cacheable, TypedFormat, Lockable
A class that uses a ZipEntry to be a single container file,
but read-only.
-
Field Summary
FieldsFields inherited from class FileContainer
allocCache, canUpdate, CHECKSUM_SIZE, CONTAINER_INFO_SIZE, containerCache, containerInfo, containerVersion, dataFactory, estimatedRowCount, FIRST_ALLOC_PAGE_NUMBER, FIRST_ALLOC_PAGE_OFFSET, firstAllocPageNumber, firstAllocPageOffset, formatIdInteger, initialPages, isDirty, lastLogInstant, minimumRecordSize, pageCache, pageSize, preDirty, SPACE_TRACE, spareSpaceFields inherited from class BaseContainer
identity, isCommittedDrop, isDropped, isReusableRecordId -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbackupContainer(BaseContainerHandle handle, String backupLocation) Backup the container.final voidclean(boolean forRemove) Write out the header information for this container.(package private) void(package private) voidcreateContainer(ContainerKey newIdentity) 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.protected voidencryptOrDecryptContainer(BaseContainerHandle handle, String newFilePath, boolean doEncrypt) Encrypts or decrypts the container.protected final voidflushAll()Flush all outstanding changes in this container to persistent storage.protected InputStreamGet an input stream positioned at the beginning of the file(package private) final booleanopenContainer(ContainerKey newIdentity) Open a container.protected final intpreAllocate(long lastPreallocPagenum, int preAllocSize) Preallocate page.protected final voidreadPage(long pageNumber, byte[] pageData) Read a page into the supplied array.protected voidreadPositionedPage(long pageOffset, byte[] pageData) Read the page at the positioned offset.protected final voidremoveContainer(LogInstant instant, boolean leaveStub) Remove the container.protected voidtruncatePages(long lastValidPagenum) protected final voidwritePage(long pageNumber, byte[] pageData, boolean syncPage) Write a page from the supplied array.Methods inherited from class FileContainer
bumpContainerVersion, canUpdate, clearIdentity, clearPreallocThreshold, compressContainer, createIdent, createIdentity, deallocatePage, decryptPage, doPreAllocatePages, dropContainer, encryptPage, getAllocPage, getAnyPage, getContainerProperties, getContainerVersion, getContextService, getEmbryonicPage, getEmbryonicPage, getEncryptionBuffer, getEstimatedPageCount, getEstimatedRowCount, getFirstHeadPage, getHeadPage, getLastPageNumber, getLatchedPage, getMinimumRecordSize, getNextHeadPage, getPage, getPageForCompress, getPageForInsert, getPageSize, getReusableRecordIdSequenceNumber, getSpaceInfo, getSpareSpace, getTypeFormatId, incrementReusableRecordIdSequenceNumber, initPage, isDirty, latchPage, letGo, logCreateContainerInfo, newPage, preDirty, prepareForBulkLoad, readHeader, reCreatePageForRedoRecovery, setDirty, setEstimatedRowCount, setIdent, setIdentity, trackUnfilledPage, updateEstimatedRowCount, writeAtOffset, writeHeader, writeHeaderMethods inherited from class BaseContainer
addPage, compressContainer, fillInIdentity, getAllocPage, getAnyPage, getCommittedDropState, getContainerId, getContainerStatus, getDeallocLock, getDroppedState, getFirstPage, getIdentity, getNextPage, getSegmentId, isReusableRecordId, lockAttributes, lockerAlwaysCompatible, lockEvent, removePage, requestCompatible, setCommittedDropState, setDroppedState, setReusableRecordIdState, truncate, unlockEvent, useMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Cacheable
getIdentity
-
Field Details
-
containerPath
-
-
Constructor Details
-
InputStreamContainer
InputStreamContainer(BaseDataFileFactory factory)
-
-
Method Details
-
openContainer
Description copied from class:FileContainerOpen 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.- Specified by:
openContainerin classFileContainer- Throws:
StandardException- Standard exception policy.
-
closeContainer
void closeContainer()- Specified by:
closeContainerin classFileContainer
-
clean
Write out the header information for this container. If an i/o exception occurs then ...- Throws:
StandardException- Standard Derby error policy- See Also:
-
preAllocate
protected final int preAllocate(long lastPreallocPagenum, int preAllocSize) Preallocate page.- Specified by:
preAllocatein classFileContainer- Parameters:
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.- Returns:
- number of successfully preallocated page, or 0 if no page has been preallocated
-
truncatePages
protected void truncatePages(long lastValidPagenum) - Specified by:
truncatePagesin classBaseContainer
-
createContainer
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.- Specified by:
createContainerin classFileContainer- Throws:
StandardException- Derby Standard error policy
-
removeContainer
protected final void removeContainer(LogInstant instant, boolean leaveStub) throws StandardException Remove the container.- Specified by:
removeContainerin classBaseContainer- Parameters:
leaveStub- if true, leave a stub. If false, remove everything- Throws:
StandardException- Standard Derby error policy- See Also:
-
readPage
protected final void readPage(long pageNumber, byte[] pageData) throws IOException, StandardException Read a page into the supplied array.
MT - thread safe- Specified by:
readPagein classFileContainer- Throws:
IOException- error reading pageStandardException- standard Derby error message
-
readPositionedPage
Read the page at the positioned offset. This default implementation, opens the stream and skips to the offset and then reads the data into pageData.- Throws:
IOException
-
writePage
protected final void writePage(long pageNumber, byte[] pageData, boolean syncPage) throws IOException, StandardException Write a page from the supplied array.
MT - thread safe- Specified by:
writePagein classFileContainer- Throws:
IOException- error writing pageStandardException- Standard Derby error policy
-
flushAll
protected final void flushAll()Description copied from class:BaseContainerFlush all outstanding changes in this container to persistent storage.- Specified by:
flushAllin classBaseContainer
-
getInputStream
Get an input stream positioned at the beginning of the file- Throws:
IOException
-
backupContainer
protected void backupContainer(BaseContainerHandle handle, String backupLocation) throws StandardException Backup the container. There is no support to backup this type of containers. It may not be any real use for users because users can simply make copies of the read only database in Zip files easily using OS utilities.- Specified by:
backupContainerin classFileContainer- Parameters:
handle- the container handle.backupLocation- location of the backup container.- Throws:
StandardException- Standard Derby error policy
-
encryptOrDecryptContainer
protected void encryptOrDecryptContainer(BaseContainerHandle handle, String newFilePath, boolean doEncrypt) throws StandardException Encrypts or decrypts the container.These operations are unsupported for this type of container.
- Specified by:
encryptOrDecryptContainerin classBaseContainer- Parameters:
handle- the container handlenewFilePath- file to store the new version of the containerdoEncrypt- tells whether to encrypt or decrypt- Throws:
StandardException- STORE_FEATURE_NOT_IMPLEMENTED
-