Top Description Fields Constructors Methods
org.apache.derby.impl.store.raw.data

pack-priv Class StreamFileContainer

extends Object
implements TypedFormat
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.services.io.TypedFormat
Imports
org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.context.ContextService, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.services.io.Storable, .StreamStorable, .FormatIdInputStream, .FormatIdOutputStream, .StoredFormatIds, .TypedFormat, .FormatableBitSet, .CompressedNumber, .DynamicByteArrayOutputStream, .LimitInputStream, org.apache.derby.iapi.services.monitor.Monitor, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.store.access.AccessFactory, .RowSource, .TransactionController, org.apache.derby.iapi.store.raw.ContainerKey, .RawStoreFactory, .StreamContainerHandle, org.apache.derby.io.StorageFile, org.apache.derby.iapi.services.property.PropertyUtil, java.util.Properties, java.io.InputStream, .BufferedInputStream, .OutputStream, .IOException, .EOFException, .InvalidClassException, .Externalizable, .FileNotFoundException

The format of this stream file is: (RH) (FH) (field data) (FH) (field data) ........ (FH) (field data) Record header is stored once at the beginning of the file for all the rows stored in this file. Record Header indicates how many fields are in each row. Then we just stored all the column from each row. Field header stored on this file is fixed size with fieldDataLength size set to LARGE_SLOT_SIZE (4) bytes.

Note

No locks are used in this container. All transaction are not logged.

Field Summary

Modifier and TypeField and Description
private int
private StorageFile
private BufferedInputStream
private int
private byte[]
private BaseDataFileFactory
private DecryptInputStream
protected static final int
protected static final int
private StorageFile
private InputStream
private OutputStream
protected static int
formatIdInteger

Constant Fields of the class

protected ContainerKey
identity

Fields of the class

protected static final int
private LimitInputStream
private FormatIdInputStream
private FormatIdOutputStream
protected static final int
private DynamicByteArrayOutputStream
private StoredRecordHeader
private static final int
private static final int
private static final int
private static final int
private static final int
private byte[]

Constructor Summary

AccessConstructor and Description
pack-priv
StreamFileContainer(ContainerKey identity, BaseDataFileFactory dataFactory)

Constructor.

pack-priv
StreamFileContainer(ContainerKey identity, BaseDataFileFactory dataFactory, Properties prop)

Constructor

when rowSource is passed to the constructor, it will be loaded into the container after the container has been created.

Method Summary

Modifier and TypeMethod and Description
protected void
close()

Close the stream file.

public boolean
public void
getContainerProperties(Properties
Property list to fill in.
prop
)

Request the system properties associated with a stream container.

private static ContextService
getContextService()

Must be private so that user code can't call this entry point.

protected StorageFile
getFileName(ContainerKey identity, boolean forCreate, boolean errorOK)

Return a file name for the identity.

public ContainerKey
getIdentity()

Request the container key associated with the stream container.

private static Object
getServiceModule(final Object serviceModule, final String factoryInterface)

Must be private so that user code can't call this entry point.

public int
public void
load(RowSource
The row source to get rows to load into this container.
rowSource
)

load data into this container.

protected StreamFileContainer

Returns:

The opened StreamFileContainer.
open
(boolean
Currently only accepts false, updating and existing stream file container is not currently supported.
forUpdate
)

Open a stream file container.

private synchronized boolean
private synchronized boolean
private synchronized InputStream
private synchronized OutputStream
private synchronized boolean
public boolean
removeContainer()

Close the stream file and remove the file.

public Object
run()

protected boolean
use(StreamContainerHandle handle)

Can I use this container?

private void
private void
writeToFile()

Write the buffer to the file.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

actionCodeback to summary
private int actionCode
actionStorageFileback to summary
private StorageFile actionStorageFile
bufferedInback to summary
private BufferedInputStream bufferedIn
bufferSizeback to summary
private int bufferSize
ciphertextback to summary
private byte[] ciphertext
dataFactoryback to summary
private BaseDataFileFactory dataFactory
decryptInback to summary
private DecryptInputStream decryptIn
FIELD_HEADER_SIZEback to summary
protected static final int FIELD_HEADER_SIZE
FIELD_STATUSback to summary
protected static final int FIELD_STATUS
fileback to summary
private StorageFile file
fileInback to summary
private InputStream fileIn
fileOutback to summary
private OutputStream fileOut
formatIdIntegerback to summary
protected static int formatIdInteger

Constant Fields of the class

identityback to summary
protected ContainerKey identity

Fields of the class

LARGE_SLOT_SIZEback to summary
protected static final int LARGE_SLOT_SIZE
limitInback to summary
private LimitInputStream limitIn
logicalDataInback to summary
private FormatIdInputStream logicalDataIn
logicalDataOutback to summary
private FormatIdOutputStream logicalDataOut
MIN_BUFFER_SIZEback to summary
protected static final int MIN_BUFFER_SIZE
outback to summary
private DynamicByteArrayOutputStream out
recordHeaderback to summary
private StoredRecordHeader recordHeader
STORAGE_FILE_DELETE_ACTIONback to summary
private static final int STORAGE_FILE_DELETE_ACTION
STORAGE_FILE_EXISTS_ACTIONback to summary
private static final int STORAGE_FILE_EXISTS_ACTION
STORAGE_FILE_GET_INPUT_STREAM_ACTIONback to summary
private static final int STORAGE_FILE_GET_INPUT_STREAM_ACTION
STORAGE_FILE_GET_OUTPUT_STREAM_ACTIONback to summary
private static final int STORAGE_FILE_GET_OUTPUT_STREAM_ACTION
STORAGE_FILE_MKDIRS_ACTIONback to summary
private static final int STORAGE_FILE_MKDIRS_ACTION
zeroBytesback to summary
private byte[] zeroBytes

Constructor Detail

StreamFileContainerback to summary
pack-priv StreamFileContainer(ContainerKey identity, BaseDataFileFactory dataFactory)

Constructor.

Exceptions
StandardException:
Standard exception policy.
StreamFileContainerback to summary
pack-priv StreamFileContainer(ContainerKey identity, BaseDataFileFactory dataFactory, Properties prop) throws StandardException

Constructor

when rowSource is passed to the constructor, it will be loaded into the container after the container has been created.

Exceptions
StandardException:
Standard exception policy.

Method Detail

closeback to summary
protected void close()

Close the stream file.

Close this stream file, and all streams associated with it.

fetchNextback to summary
public boolean fetchNext(Object[] row) throws StandardException
getContainerPropertiesback to summary
public void getContainerProperties(Properties prop) throws StandardException

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:Properties

Property list to fill in.

Exceptions
StandardException:
Standard exception policy.
getContextServiceback to summary
private static ContextService getContextService()

Must be private so that user code can't call this entry point.

getFileNameback to summary
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

Exceptions
StandardException:
Segment directory cannot be created
getIdentityback to summary
public ContainerKey getIdentity()

Request the container key associated with the stream container.

getServiceModuleback to summary
private static Object getServiceModule(final Object serviceModule, final String factoryInterface)

Must be private so that user code can't call this entry point.

getTypeFormatIdback to summary
public int getTypeFormatId()

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Return my format identifier.

Returns:int

Doc from org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

The identifier. (A UUID stuffed in an array of 16 bytes).

loadback to summary
public void load(RowSource rowSource) throws StandardException

load data into this container.

populate the stream container with data in the rowSource

Parameters
rowSource:RowSource

The row source to get rows to load into this container.

Exceptions
StandardException:
Standard exception policy.
openback to summary
protected StreamFileContainer open(boolean forUpdate) throws StandardException

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:boolean

Currently only accepts false, updating and existing stream file container is not currently supported.

Returns:StreamFileContainer

The opened StreamFileContainer.

Exceptions
StandardException:
Standard exception policy.
privDeleteback to summary
private synchronized boolean privDelete(StorageFile file)
privExistsback to summary
private synchronized boolean privExists(StorageFile file)
privGetInputStreamback to summary
private synchronized InputStream privGetInputStream(StorageFile file) throws FileNotFoundException
privGetOutputStreamback to summary
private synchronized OutputStream privGetOutputStream(StorageFile file) throws FileNotFoundException
privMkdirsback to summary
private synchronized boolean privMkdirs(StorageFile file) throws IOException
removeContainerback to summary
public boolean removeContainer() throws StandardException

Close the stream file and remove the file.

Exceptions
StandardException:
Segment directory cannot be created
runback to summary
public Object run() throws IOException
useback to summary
protected boolean use(StreamContainerHandle handle) throws StandardException

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.

Exceptions
StandardException:
Standard exception policy.
writeColumnback to summary
private void writeColumn(Object column) throws StandardException, IOException
writeToFileback to summary
private void writeToFile() throws StandardException

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.

Exceptions
StandardException:
Standard exception policy.