Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.impl.store.raw.data
Class StreamFileContainer  view StreamFileContainer download StreamFileContainer.java

java.lang.Object
  extended byorg.apache.derby.impl.store.raw.data.StreamFileContainer
All Implemented Interfaces:
org.apache.derby.iapi.services.io.TypedFormat

public class StreamFileContainer
extends java.lang.Object
implements org.apache.derby.iapi.services.io.TypedFormat

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
private  java.io.BufferedInputStream bufferedIn
           
private  int bufferSize
           
private  byte[] ciphertext
           
private  BaseDataFileFactory dataFactory
           
private  DecryptInputStream decryptIn
           
protected static int FIELD_HEADER_SIZE
           
protected static int FIELD_STATUS
           
private  org.apache.derby.io.StorageFile file
           
private  java.io.InputStream fileIn
           
private  java.io.OutputStream fileOut
           
protected static int formatIdInteger
          Constant Fields of the class
protected  org.apache.derby.iapi.store.raw.ContainerKey identity
          Fields of the class
protected static int LARGE_SLOT_SIZE
           
private  org.apache.derby.iapi.services.io.LimitInputStream limitIn
           
private  org.apache.derby.iapi.services.io.FormatIdInputStream logicalDataIn
           
private  org.apache.derby.iapi.services.io.FormatIdOutputStream logicalDataOut
           
protected static int MIN_BUFFER_SIZE
           
private  org.apache.derby.iapi.services.io.DynamicByteArrayOutputStream out
           
private  StoredRecordHeader recordHeader
           
private  byte[] zeroBytes
           
 
Constructor Summary
(package private) StreamFileContainer(org.apache.derby.iapi.store.raw.ContainerKey identity, BaseDataFileFactory dataFactory)
          Constructor.
(package private) StreamFileContainer(org.apache.derby.iapi.store.raw.ContainerKey identity, BaseDataFileFactory dataFactory, java.util.Properties prop)
          Constructor
 
Method Summary
protected  void close()
          Close the stream file.
 boolean fetchNext(java.lang.Object[] row)
           
 void getContainerProperties(java.util.Properties prop)
          Request the system properties associated with a stream container.
protected  org.apache.derby.io.StorageFile getFileName(org.apache.derby.iapi.store.raw.ContainerKey identity, boolean forCreate, boolean errorOK)
          Return a file name for the identity.
 org.apache.derby.iapi.store.raw.ContainerKey getIdentity()
          Request the container key associated with the stream container.
 int getTypeFormatId()
          Return my format identifier.
 void load(org.apache.derby.iapi.store.access.RowSource rowSource)
          load data into this container.
protected  StreamFileContainer open(boolean forUpdate)
          Open a stream file container.
 boolean removeContainer()
          Close the stream file and remove the file.
protected  boolean use(org.apache.derby.iapi.store.raw.StreamContainerHandle handle)
          Can I use this container?
private  void writeColumn(java.lang.Object column)
           
private  void writeToFile()
          Write the buffer to the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

formatIdInteger

protected static int formatIdInteger
Constant Fields of the class


LARGE_SLOT_SIZE

protected static final int LARGE_SLOT_SIZE
See Also:
Constant Field Values

MIN_BUFFER_SIZE

protected static final int MIN_BUFFER_SIZE
See Also:
Constant Field Values

FIELD_STATUS

protected static final int FIELD_STATUS

FIELD_HEADER_SIZE

protected static final int FIELD_HEADER_SIZE

identity

protected org.apache.derby.iapi.store.raw.ContainerKey identity
Fields of the class


dataFactory

private BaseDataFileFactory dataFactory

bufferSize

private int bufferSize

file

private org.apache.derby.io.StorageFile file

fileOut

private java.io.OutputStream fileOut

out

private org.apache.derby.iapi.services.io.DynamicByteArrayOutputStream out

logicalDataOut

private org.apache.derby.iapi.services.io.FormatIdOutputStream logicalDataOut

fileIn

private java.io.InputStream fileIn

bufferedIn

private java.io.BufferedInputStream bufferedIn

decryptIn

private DecryptInputStream decryptIn

limitIn

private org.apache.derby.iapi.services.io.LimitInputStream limitIn

logicalDataIn

private org.apache.derby.iapi.services.io.FormatIdInputStream logicalDataIn

recordHeader

private StoredRecordHeader recordHeader

ciphertext

private byte[] ciphertext

zeroBytes

private byte[] zeroBytes
Constructor Detail

StreamFileContainer

StreamFileContainer(org.apache.derby.iapi.store.raw.ContainerKey identity,
                    BaseDataFileFactory dataFactory)
              throws org.apache.derby.iapi.error.StandardException
Constructor.


StreamFileContainer

StreamFileContainer(org.apache.derby.iapi.store.raw.ContainerKey identity,
                    BaseDataFileFactory dataFactory,
                    java.util.Properties prop)
              throws org.apache.derby.iapi.error.StandardException
Constructor

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

Method Detail

open

protected StreamFileContainer open(boolean forUpdate)
                            throws org.apache.derby.iapi.error.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.


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:
getTypeFormatId in interface org.apache.derby.iapi.services.io.TypedFormat

getContainerProperties

public void getContainerProperties(java.util.Properties prop)
                            throws org.apache.derby.iapi.error.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"); }


getIdentity

public org.apache.derby.iapi.store.raw.ContainerKey getIdentity()
Request the container key associated with the stream container.


use

protected boolean use(org.apache.derby.iapi.store.raw.StreamContainerHandle handle)
               throws org.apache.derby.iapi.error.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.


load

public void load(org.apache.derby.iapi.store.access.RowSource rowSource)
          throws org.apache.derby.iapi.error.StandardException
load data into this container.

populate the stream container with data in the rowSource


writeToFile

private void writeToFile()
                  throws org.apache.derby.iapi.error.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.


writeColumn

private void writeColumn(java.lang.Object column)
                  throws org.apache.derby.iapi.error.StandardException,
                         java.io.IOException

fetchNext

public boolean fetchNext(java.lang.Object[] row)
                  throws org.apache.derby.iapi.error.StandardException

removeContainer

public boolean removeContainer()
                        throws org.apache.derby.iapi.error.StandardException
Close the stream file and remove the file.


getFileName

protected org.apache.derby.io.StorageFile getFileName(org.apache.derby.iapi.store.raw.ContainerKey identity,
                                                      boolean forCreate,
                                                      boolean errorOK)
                                               throws org.apache.derby.iapi.error.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