Class StreamFileContainer
- All Implemented Interfaces:
PrivilegedExceptionAction<Object>, TypedFormat
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate StorageFileprivate BufferedInputStreamprivate intprivate byte[]private BaseDataFileFactoryprivate DecryptInputStreamprotected static final intprotected static final intprivate StorageFileprivate InputStreamprivate OutputStreamprotected static intConstant Fields of the classprotected ContainerKeyFields of the classprotected static final intprivate LimitInputStreamprivate FormatIdInputStreamprivate FormatIdOutputStreamprotected static final intprivate DynamicByteArrayOutputStreamprivate StoredRecordHeaderprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate byte[] -
Constructor Summary
ConstructorsConstructorDescriptionStreamFileContainer(ContainerKey identity, BaseDataFileFactory dataFactory) Constructor.StreamFileContainer(ContainerKey identity, BaseDataFileFactory dataFactory, Properties prop) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected voidclose()Close the stream file.booleanvoidRequest the system properties associated with a stream container.private static ContextServicePrivileged lookup of the ContextService.protected StorageFilegetFileName(ContainerKey identity, boolean forCreate, boolean errorOK) Return a file name for the identity.Request the container key associated with the stream container.private static ObjectgetServiceModule(Object serviceModule, String factoryInterface) Privileged module lookup.intReturn my format identifier.voidload data into this container.protected StreamFileContaineropen(boolean forUpdate) Open a stream file container.private booleanprivDelete(StorageFile file) private booleanprivExists(StorageFile file) private InputStreamprivate OutputStreamprivate booleanprivMkdirs(StorageFile file) booleanClose the stream file and remove the file.run()protected booleanuse(StreamContainerHandle handle) Can I use this container?private voidwriteColumn(Object column) private voidWrite the buffer to the file.
-
Field Details
-
formatIdInteger
protected static int formatIdIntegerConstant Fields of the class -
LARGE_SLOT_SIZE
protected static final int LARGE_SLOT_SIZE- See Also:
-
MIN_BUFFER_SIZE
protected static final int MIN_BUFFER_SIZE- See Also:
-
FIELD_STATUS
protected static final int FIELD_STATUS -
FIELD_HEADER_SIZE
protected static final int FIELD_HEADER_SIZE -
identity
Fields of the class -
dataFactory
-
bufferSize
private int bufferSize -
file
-
fileOut
-
out
-
logicalDataOut
-
fileIn
-
bufferedIn
-
decryptIn
-
limitIn
-
logicalDataIn
-
recordHeader
-
ciphertext
private byte[] ciphertext -
zeroBytes
private byte[] zeroBytes -
STORAGE_FILE_EXISTS_ACTION
private static final int STORAGE_FILE_EXISTS_ACTION- See Also:
-
STORAGE_FILE_DELETE_ACTION
private static final int STORAGE_FILE_DELETE_ACTION- See Also:
-
STORAGE_FILE_MKDIRS_ACTION
private static final int STORAGE_FILE_MKDIRS_ACTION- See Also:
-
STORAGE_FILE_GET_OUTPUT_STREAM_ACTION
private static final int STORAGE_FILE_GET_OUTPUT_STREAM_ACTION- See Also:
-
STORAGE_FILE_GET_INPUT_STREAM_ACTION
private static final int STORAGE_FILE_GET_INPUT_STREAM_ACTION- See Also:
-
actionCode
private int actionCode -
actionStorageFile
-
-
Constructor Details
-
StreamFileContainer
StreamFileContainer(ContainerKey identity, BaseDataFileFactory dataFactory) Constructor.- Throws:
StandardException- Standard exception policy.
-
StreamFileContainer
StreamFileContainer(ContainerKey identity, BaseDataFileFactory dataFactory, Properties prop) throws StandardException Constructorwhen rowSource is passed to the constructor, it will be loaded into the container after the container has been created.
- Throws:
StandardException- Standard exception policy.
-
-
Method Details
-
open
Open a stream file container.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 and return. If the file exists but we have trouble opening it then we throw some exception.
- Parameters:
forUpdate- Currently only accepts false, updating and existing stream file container is not currently supported.- Returns:
- The opened StreamFileContainer.
- Throws:
StandardException- Standard exception policy.
-
close
protected void close()Close the stream file.Close this stream file, and all streams associated with it.
-
getTypeFormatId
public int getTypeFormatId()Return my format identifier.- Specified by:
getTypeFormatIdin interfaceTypedFormat- Returns:
- The identifier. (A UUID stuffed in an array of 16 bytes).
-
getContainerProperties
Request the system properties associated with a stream container.Request the value of properties associated with a stream container. The following properties can be requested: derby.storage.streamFileBufferSize
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.streamFileBufferSize", ""); cc.getContainerProperties(prop); System.out.println( "stream table's buffer size = " + prop.getProperty("derby.storage.streamFileBufferSize"); }
- Parameters:
prop- Property list to fill in.- Throws:
StandardException- Standard exception policy.
-
getIdentity
Request the container key associated with the stream container. -
use
Can I use this container?This method always return true right now. In the future when there are different uses for this container, we may need to add qualifications for this.
- Throws:
StandardException- Standard exception policy.
-
load
load data into this container.populate the stream container with data in the rowSource
- Parameters:
rowSource- The row source to get rows to load into this container.- Throws:
StandardException- Standard exception policy.
-
writeToFile
Write the buffer to the file.If the database is encrypted, the dataFactory.getEncryptionBlockSize() - 1 reserved bytes will be used to pad the byte array to be dataFactory.getEncryptionBlockSize() aligned. Before the bytes are encrypted and written to the file stream, the actual length of the byte array is written out as a compressed integer. This number will be used when decrypting the data. If the database is not encrypted, then, we don't reserve the bytes upfront, and we simple just write the bytes out to the file stream.
- Throws:
StandardException- Standard exception policy.
-
writeColumn
- Throws:
StandardExceptionIOException
-
fetchNext
- Throws:
StandardException
-
removeContainer
Close the stream file and remove the file.- Throws:
StandardException- Segment directory cannot be created
-
getFileName
protected StorageFile getFileName(ContainerKey identity, boolean forCreate, boolean errorOK) throws StandardException Return a file name for the identity.Return a valid file name for the identity, or null if the data directory for this segment cannot be created
- Throws:
StandardException- Segment directory cannot be created
-
privExists
-
privMkdirs
- Throws:
IOException
-
privDelete
-
privGetOutputStream
- Throws:
FileNotFoundException
-
privGetInputStream
- Throws:
FileNotFoundException
-
run
- Specified by:
runin interfacePrivilegedExceptionAction<Object>- Throws:
IOException
-
getContextService
Privileged lookup of the ContextService. Must be private so that user code can't call this entry point. -
getServiceModule
-