org.axiondb.engine.tables
Class BaseDiskTable

java.lang.Object
  extended by org.axiondb.event.BaseTableModificationPublisher
      extended by org.axiondb.engine.tables.AbstractBaseTable
          extended by org.axiondb.engine.tables.BaseTable
              extended by org.axiondb.engine.tables.BaseDiskTable
All Implemented Interfaces:
RowSource, Table
Direct Known Subclasses:
BaseFlatfileTable, DiskTable

public abstract class BaseDiskTable
extends BaseTable
implements Table

Abstract base disk-resident implementation of Table. BaseDiskTable manages the column meta-data for a disk-based table.

Version:
$Revision: 1.36 $ $Date: 2005/12/22 09:02:31 $

Field Summary
protected  java.io.File _dataFile
          The name of my ".data" file.
protected  java.io.File _dbdir
           
protected  org.apache.commons.collections.primitives.IntList _freeIds
          List of free ids.
protected  boolean _readOnly
           
protected  int _rowCount
           
protected static int CURRENT_META_VERSION
           
protected static java.lang.String FRID_FILE_EXT
           
protected static AxionFileSystem FS
           
protected static java.lang.String INDICES_DIR_NAME
           
protected static long INVALID_OFFSET
           
protected static java.lang.String META_FILE_EXT
           
protected static java.lang.String PIDX_FILE_EXT
           
protected static java.lang.String SEQ_FILE_EXT
           
protected static java.lang.String TYPE_FILE_EXT
           
 
Fields inherited from interface org.axiondb.Table
REGULAR_TABLE_TYPE, SYSTEM_TABLE_TYPE
 
Constructor Summary
BaseDiskTable(java.lang.String name, Database db, TableFactory factory)
           
 
Method Summary
 void addColumn(Column col)
          Add the given Columnto this table.
 void addColumn(Column col, boolean metaUpdateNeeded)
           
 void addConstraint(Constraint constraint)
           
 void applyDeletes(org.apache.commons.collections.primitives.IntCollection rowIds)
          Remove the specified rows from this table and any associated indices.
 void applyInserts(RowCollection rows)
          Insert the given rows into this table and any associated indices.
 void applyUpdates(RowCollection rows)
          Update the given rows in this table and any associated indices.
 void checkpoint()
           
protected  void clearDataFileReference()
           
protected  void closeFiles()
           
protected  void createOrLoadDataFile()
           
protected  void createOrLoadFreeIdsFile()
           
 void drop()
          Drop this table from the database.
 void freeRowId(int id)
          Un-reserve a row id.
protected abstract  java.io.File getDataFile()
           
protected  java.lang.String getDefaultDataFileExtension()
           
protected  BufferedDataInputStream getInputStream()
           
protected abstract  java.io.File getLobDir()
           
 int getNextRowId()
          Reserve a row id.
protected  BufferedDataOutputStream getOutputStream()
           
protected  AxionFileSystem.PidxList getPidxList()
           
protected  java.io.File getRootDir()
           
 Row getRow(int id)
           
protected abstract  Row getRowByOffset(int idToAssign, long ptr)
           
 int getRowCount()
          Return the number of Rows I contain.
protected  RowIterator getRowIterator()
           
protected  java.io.File getTableFile(java.lang.String extension)
           
protected  void initFiles(java.io.File basedir, boolean datafilesonly)
           
protected  void initializeRowCount()
           
protected  boolean isReadOnly()
           
protected  void loadOrMigrateMetaFile(Database db)
           
 void migrate(Database db)
          Migrate from older version to newer version for this table
protected  AxionFileSystem.PidxList parsePidxFile(java.io.File pidxFile)
           
protected  void parseTableProperties(java.io.ObjectInputStream in)
           
 void populateIndex(Index index)
          Populate an Index, adding my current rows to it.
protected abstract  void reloadFilesAfterTruncate()
           
 void remount(java.io.File newdir, boolean datafilesonly)
          Notify this table that its disk-location has moved.
 void removeIndex(Index index)
          Remove an index, both from the indices and as a TableModificationListener
 void rename(java.lang.String oldName, java.lang.String newName)
           
protected  void renameTableFiles(java.lang.String oldName, java.lang.String name)
           
protected  void resetLobColumns()
           
protected  void saveIndicesAfterTruncate()
           
 void setSequence(Sequence seq)
           
 void shutdown()
          The database is shutting down, shutdown this table also.
 void truncate()
          Unconditionally delete all rows in this table.
protected  void tryToRemove(RowIterator iter)
           
protected  void writeFridFile()
           
protected  void writeMetaFile()
           
protected  void writeNameToFile(java.io.File file, java.lang.Object obj)
           
protected abstract  void writeRow(BufferedDataOutputStream buffer, Row row)
           
protected  void writeTableProperties(java.io.ObjectOutputStream out)
           
 
Methods inherited from class org.axiondb.engine.tables.BaseTable
addIndex, addRow, applyDeletesToIndices, applyInsertsToIndices, applyUpdatesToIndices, clearCache, deleteRow, getColumn, getColumn, getColumnCount, getColumnIdentifiers, getColumnIndex, getConstraint, getConstraints, getIndexedRows, getIndexedRows, getIndexForColumn, getIndices, getName, getRowIterator, getSequence, getType, hasColumn, hasIndex, isColumnIndexed, isPrimaryKeyConstraintExists, isUniqueConstraintExists, makeRowDecorator, makeTransactableTable, notifyColumnsOfNewLobDir, readColumns, readConstraints, recreateIndices, removeConstraint, setName, setType, toString, truncateIndices, updateRow, writeColumns, writeConstraints
 
Methods inherited from class org.axiondb.engine.tables.AbstractBaseTable
checkConstraints, checkConstraints, checkConstraints, getMatchingRows, hasDeferredConstraint, isDeferAll, migrate
 
Methods inherited from class org.axiondb.event.BaseTableModificationPublisher
addTableModificationListener, getTableModificationListeners, publishEvent, removeTableModificationListener, setDeferAllConstraints
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.axiondb.Table
addIndex, addRow, addTableModificationListener, deleteRow, getColumn, getColumn, getColumnCount, getColumnIdentifiers, getColumnIndex, getConstraint, getConstraints, getIndexedRows, getIndexedRows, getIndexForColumn, getIndices, getMatchingRows, getName, getRowIterator, getSequence, getTableModificationListeners, getType, hasColumn, hasIndex, isColumnIndexed, isPrimaryKeyConstraintExists, isUniqueConstraintExists, makeRowDecorator, makeTransactableTable, migrate, removeConstraint, removeTableModificationListener, setDeferAllConstraints, updateRow
 

Field Detail

FS

protected static AxionFileSystem FS

INVALID_OFFSET

protected static final long INVALID_OFFSET
See Also:
Constant Field Values

CURRENT_META_VERSION

protected static final int CURRENT_META_VERSION
See Also:
Constant Field Values

FRID_FILE_EXT

protected static final java.lang.String FRID_FILE_EXT
See Also:
Constant Field Values

INDICES_DIR_NAME

protected static final java.lang.String INDICES_DIR_NAME
See Also:
Constant Field Values

META_FILE_EXT

protected static final java.lang.String META_FILE_EXT
See Also:
Constant Field Values

PIDX_FILE_EXT

protected static final java.lang.String PIDX_FILE_EXT
See Also:
Constant Field Values

SEQ_FILE_EXT

protected static final java.lang.String SEQ_FILE_EXT
See Also:
Constant Field Values

TYPE_FILE_EXT

protected static final java.lang.String TYPE_FILE_EXT
See Also:
Constant Field Values

_dataFile

protected java.io.File _dataFile
The name of my ".data" file.


_dbdir

protected java.io.File _dbdir

_freeIds

protected org.apache.commons.collections.primitives.IntList _freeIds
List of free ids.


_readOnly

protected boolean _readOnly

_rowCount

protected int _rowCount
Constructor Detail

BaseDiskTable

public BaseDiskTable(java.lang.String name,
                     Database db,
                     TableFactory factory)
              throws AxionException
Throws:
AxionException
Method Detail

addColumn

public void addColumn(Column col)
               throws AxionException
Description copied from class: BaseTable
Add the given Columnto this table. This implementation throws an AxionExceptionif rows have already been added to the table.

Specified by:
addColumn in interface Table
Overrides:
addColumn in class BaseTable
Throws:
AxionException

addColumn

public void addColumn(Column col,
                      boolean metaUpdateNeeded)
               throws AxionException
Throws:
AxionException

addConstraint

public void addConstraint(Constraint constraint)
                   throws AxionException
Specified by:
addConstraint in interface Table
Overrides:
addConstraint in class BaseTable
Throws:
AxionException

applyDeletes

public void applyDeletes(org.apache.commons.collections.primitives.IntCollection rowIds)
                  throws AxionException
Description copied from interface: Table
Remove the specified rows from this table and any associated indices. This process is allowed to be destructive, the table my delete values from the given list.

Specified by:
applyDeletes in interface Table
Specified by:
applyDeletes in class BaseTable
Throws:
AxionException

applyInserts

public void applyInserts(RowCollection rows)
                  throws AxionException
Description copied from interface: Table
Insert the given rows into this table and any associated indices. This process is allowed to be destructive, the table my delete rows from the given list.

Specified by:
applyInserts in interface Table
Specified by:
applyInserts in class BaseTable
Parameters:
rows - a collection of Rows
Throws:
AxionException

applyUpdates

public void applyUpdates(RowCollection rows)
                  throws AxionException
Description copied from interface: Table
Update the given rows in this table and any associated indices. This process is allowed to be destructive, the table my delete rows from the given list.

Specified by:
applyUpdates in interface Table
Specified by:
applyUpdates in class BaseTable
Throws:
AxionException

checkpoint

public void checkpoint()
                throws AxionException
Specified by:
checkpoint in interface Table
Overrides:
checkpoint in class BaseTable
Throws:
AxionException

drop

public void drop()
          throws AxionException
Description copied from interface: Table
Drop this table from the database.

Specified by:
drop in interface Table
Overrides:
drop in class BaseTable
Throws:
AxionException

freeRowId

public void freeRowId(int id)
Description copied from interface: Table
Un-reserve a row id.

Specified by:
freeRowId in interface Table
Specified by:
freeRowId in class BaseTable

getNextRowId

public int getNextRowId()
Description copied from interface: Table
Reserve a row id.

Specified by:
getNextRowId in interface Table
Specified by:
getNextRowId in class BaseTable

getRow

public Row getRow(int id)
           throws AxionException
Specified by:
getRow in interface RowSource
Specified by:
getRow in class BaseTable
Throws:
AxionException

migrate

public void migrate(Database db)
             throws AxionException
Migrate from older version to newer version for this table

Throws:
AxionException

getRowCount

public int getRowCount()
Description copied from interface: Table
Return the number of Rows I contain.

Specified by:
getRowCount in interface Table
Specified by:
getRowCount in class BaseTable

populateIndex

public void populateIndex(Index index)
                   throws AxionException
Description copied from interface: Table
Populate an Index, adding my current rows to it. Does not addthe index.

Specified by:
populateIndex in interface Table
Specified by:
populateIndex in class BaseTable
Throws:
AxionException
See Also:
Table.addIndex(org.axiondb.Index)

remount

public void remount(java.io.File newdir,
                    boolean datafilesonly)
             throws AxionException
Description copied from interface: Table
Notify this table that its disk-location has moved.

Specified by:
remount in interface Table
Overrides:
remount in class BaseTable
Throws:
AxionException

removeIndex

public void removeIndex(Index index)
                 throws AxionException
Description copied from interface: Table
Remove an index, both from the indices and as a TableModificationListener

Specified by:
removeIndex in interface Table
Overrides:
removeIndex in class BaseTable
Throws:
AxionException

rename

public void rename(java.lang.String oldName,
                   java.lang.String newName)
            throws AxionException
Specified by:
rename in interface Table
Overrides:
rename in class BaseTable
Throws:
AxionException

setSequence

public void setSequence(Sequence seq)
                 throws AxionException
Specified by:
setSequence in interface Table
Overrides:
setSequence in class BaseTable
Throws:
AxionException

shutdown

public void shutdown()
              throws AxionException
Description copied from interface: Table
The database is shutting down, shutdown this table also.

Specified by:
shutdown in interface Table
Overrides:
shutdown in class BaseTable
Throws:
AxionException

truncate

public void truncate()
              throws AxionException
Description copied from interface: Table
Unconditionally delete all rows in this table.

Specified by:
truncate in interface Table
Throws:
AxionException

clearDataFileReference

protected void clearDataFileReference()

closeFiles

protected void closeFiles()

createOrLoadDataFile

protected void createOrLoadDataFile()
                             throws AxionException
Throws:
AxionException

createOrLoadFreeIdsFile

protected void createOrLoadFreeIdsFile()
                                throws AxionException
Throws:
AxionException

loadOrMigrateMetaFile

protected void loadOrMigrateMetaFile(Database db)
                              throws AxionException
Throws:
AxionException

getDataFile

protected abstract java.io.File getDataFile()

getDefaultDataFileExtension

protected java.lang.String getDefaultDataFileExtension()

getInputStream

protected BufferedDataInputStream getInputStream()
                                          throws AxionException
Throws:
AxionException

getLobDir

protected abstract java.io.File getLobDir()

getOutputStream

protected BufferedDataOutputStream getOutputStream()
                                            throws AxionException
Throws:
AxionException

getPidxList

protected AxionFileSystem.PidxList getPidxList()

getRootDir

protected java.io.File getRootDir()

getRowIterator

protected RowIterator getRowIterator()
                              throws AxionException
Specified by:
getRowIterator in class BaseTable
Throws:
AxionException

getRowByOffset

protected abstract Row getRowByOffset(int idToAssign,
                                      long ptr)
                               throws AxionException
Throws:
AxionException

getTableFile

protected java.io.File getTableFile(java.lang.String extension)

isReadOnly

protected boolean isReadOnly()

initFiles

protected void initFiles(java.io.File basedir,
                         boolean datafilesonly)
                  throws AxionException
Throws:
AxionException

initializeRowCount

protected void initializeRowCount()
                           throws AxionException
Throws:
AxionException

parsePidxFile

protected AxionFileSystem.PidxList parsePidxFile(java.io.File pidxFile)
                                          throws AxionException
Throws:
AxionException

parseTableProperties

protected void parseTableProperties(java.io.ObjectInputStream in)
                             throws AxionException
Throws:
AxionException

reloadFilesAfterTruncate

protected abstract void reloadFilesAfterTruncate()
                                          throws AxionException
Throws:
AxionException

renameTableFiles

protected void renameTableFiles(java.lang.String oldName,
                                java.lang.String name)

saveIndicesAfterTruncate

protected void saveIndicesAfterTruncate()
                                 throws AxionException
Throws:
AxionException

tryToRemove

protected void tryToRemove(RowIterator iter)
                    throws AxionException
Throws:
AxionException

writeFridFile

protected final void writeFridFile()
                            throws AxionException
Throws:
AxionException

writeMetaFile

protected void writeMetaFile()
                      throws AxionException
Throws:
AxionException

writeNameToFile

protected void writeNameToFile(java.io.File file,
                               java.lang.Object obj)
                        throws AxionException
Throws:
AxionException

writeRow

protected abstract void writeRow(BufferedDataOutputStream buffer,
                                 Row row)
                          throws AxionException
Throws:
AxionException

writeTableProperties

protected void writeTableProperties(java.io.ObjectOutputStream out)
                             throws AxionException
Throws:
AxionException

resetLobColumns

protected void resetLobColumns()
                        throws AxionException
Throws:
AxionException