com.zolltov.zdb.file
Interface ColumnLoader

All Known Implementing Classes:
SimpleColumnLoader

public interface ColumnLoader

FileDataBase uses implementations of this interface to perform all low level file I/O. Like DataBases, methods in this interface must be safe to call from multiple threads.

All implementations are free to choose their own layout but it is strongly recommended that all implementations use the following rules:


Method Summary
 void append(java.lang.String tableName, ColumnInfo info, Date date, Column column)
          Append data to a column file.
 void dropColumn(java.lang.String tableName, ColumnInfo info)
          Delete a column previously saved to file.
 java.util.List<Date> listDates()
          Returns a list of all dates known to this ColumnLoader.
 Column loadColumn(java.lang.String tableName, ColumnInfo info, Date date)
          Load a column from file.
 DataBaseInfo loadMetaData()
          Load all metadata for this database.
 void saveColumn(java.lang.String tableName, ColumnInfo info, Date date, Column column)
          Save a column to file.
 void saveMetaData(DataBaseInfo meta)
          Save all metadata for this database.
 

Method Detail

loadColumn

Column loadColumn(java.lang.String tableName,
                  ColumnInfo info,
                  Date date)
                  throws java.io.IOException
Load a column from file. If there is no data for the given date, an empty column with correct type is returned.

Parameters:
tableName - A string giving the table to load a column for.
info - A ColumnInfo describing the type of column to load.
date - A date to load for, or null if the table is not partitioned.
Returns:
The loaded column.
Throws:
java.io.IOException - if there is an error when reading data from file.

saveColumn

void saveColumn(java.lang.String tableName,
                ColumnInfo info,
                Date date,
                Column column)
                throws java.io.IOException
Save a column to file.

Parameters:
tableName - A string giving the table to load a column for.
info - A ColumnInfo describing the type of column to load.
date - A date to load for, or null if the table is not partitioned.
column - The Column object containing data to be written.
Throws:
java.io.IOException - if there is an error when writing data to file.

dropColumn

void dropColumn(java.lang.String tableName,
                ColumnInfo info)
                throws java.io.IOException
Delete a column previously saved to file.

Parameters:
tableName - A string giving the table to delete a column from.
info - A ColumnInfo describing the no longer existing column.
Throws:
java.io.IOException - if there is an error when deleting the file.

append

void append(java.lang.String tableName,
            ColumnInfo info,
            Date date,
            Column column)
            throws java.io.IOException
Append data to a column file. This method should be implemented in a way that avoids reading and writing the already existing column data.

Parameters:
tableName - A string giving the table to append data for.
info - A ColumnInfo describing the column to append.
date - A date to append for, or null if the table is not partitioned.
column - A column containing all new data to append to the end of the file.
Throws:
java.io.IOException - if there is an error when appending data.

listDates

java.util.List<Date> listDates()
Returns a list of all dates known to this ColumnLoader. The order of elements are unspecified.

Returns:
A list of all dates known to this ColumnLoader.

loadMetaData

DataBaseInfo loadMetaData()
                          throws java.io.IOException
Load all metadata for this database.

Returns:
All metadata for this database.
Throws:
java.io.IOException - if there is an error when loading meta data from file.

saveMetaData

void saveMetaData(DataBaseInfo meta)
                  throws java.io.IOException
Save all metadata for this database.

Parameters:
meta - The new metadata contents
Throws:
java.io.IOException - if there is an error when saving meta data from file.