org.edg.info
Class QueueDiskCache

java.lang.Object
  extended byorg.edg.info.QueueDiskCache

public class QueueDiskCache
extends java.lang.Object

Circular disk cache for storing tuples.


Field Summary
static char COLUMN_DELIMITER
          Character used to separate columns.
static char NULL_COLUMN
          Character used to indicate a NULL column.
static char NUMERIC_COLUMN
          Character used to indicate a numeric column.
static char STRING_COLUMN
          Character used to indicate a string column.
static char TUPLE_DELIMITER
          Character used to separate tuples.
 
Constructor Summary
QueueDiskCache(java.lang.String fileName, int maxFileSizeBytes)
          Creates a new QueueDiskCache object.
 
Method Summary
 void close()
          Closes this disk cache and removes its file.
 boolean isEmpty()
          Determines if the disk cache is full.
 boolean isFull()
          Determines if the disk cache is full.
 java.util.List readTuples(int maxTuplesToRead)
          Reads a list of tuples from this file.
static java.lang.StringBuffer serialize(java.util.List tuples)
          Serializes a list of tuples into a StringBuffer.
static java.lang.StringBuffer serialize(Tuple tuple)
          Serializes a tuple into a StringBuffer.
 void writeTuples(java.util.List tuples)
          Serializes the tuple list to bytes and writes them to the cache.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TUPLE_DELIMITER

public static final char TUPLE_DELIMITER
Character used to separate tuples.

See Also:
Constant Field Values

COLUMN_DELIMITER

public static final char COLUMN_DELIMITER
Character used to separate columns.

See Also:
Constant Field Values

NULL_COLUMN

public static final char NULL_COLUMN
Character used to indicate a NULL column.

See Also:
Constant Field Values

NUMERIC_COLUMN

public static final char NUMERIC_COLUMN
Character used to indicate a numeric column.

See Also:
Constant Field Values

STRING_COLUMN

public static final char STRING_COLUMN
Character used to indicate a string column.

See Also:
Constant Field Values
Constructor Detail

QueueDiskCache

public QueueDiskCache(java.lang.String fileName,
                      int maxFileSizeBytes)
               throws java.io.FileNotFoundException,
                      DiskCacheException
Creates a new QueueDiskCache object.

Parameters:
fileName - Name of cache file to use.
maxFileSizeBytes - Max size of cache file.
Throws:
java.io.FileNotFoundException - If the specified file can not be created/written to.
DiskCacheException - If the file size specified is invalid.
Method Detail

readTuples

public java.util.List readTuples(int maxTuplesToRead)
                          throws DiskCacheException,
                                 java.io.IOException
Reads a list of tuples from this file.

Parameters:
maxTuplesToRead - Maximum number of tuples to read, -1 to read all available tuples. Must not be zero.
Returns:
A List of Tuple objects.
Throws:
java.io.IOException - If the file access fails.
DiskCacheException

writeTuples

public void writeTuples(java.util.List tuples)
                 throws DiskCacheException,
                        java.io.IOException
Serializes the tuple list to bytes and writes them to the cache.

Parameters:
tuples - List of tuples.
Throws:
DiskCacheException - If the cache is full or closed or the tuples to write are bigger than the cache.
java.io.IOException - If the file access fails.

serialize

public static java.lang.StringBuffer serialize(java.util.List tuples)
Serializes a list of tuples into a StringBuffer.

Parameters:
tuples - Tuples to serialize.
Returns:
A StringBuffer representation of the tuples.

serialize

public static java.lang.StringBuffer serialize(Tuple tuple)
Serializes a tuple into a StringBuffer.

Parameters:
tuple - Tuple to serialize.
Returns:
A StringBuffer representation of the tuple.

isFull

public boolean isFull()
Determines if the disk cache is full.

Returns:
true if the disk cache is full.

isEmpty

public boolean isEmpty()
Determines if the disk cache is full.

Returns:
true if the disk cache is full.

close

public void close()
Closes this disk cache and removes its file.