net.sf.farrago.session
Interface FarragoSessionIndexMap

All Known Implementing Classes:
DdlReloadTableStmt.ReloadTableIndexMap, FarragoDbSessionIndexMap

public interface FarragoSessionIndexMap

FarragoSessionIndexMap defines a means for mapping CWM index definitions to corresponding physical storage.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/session/FarragoSessionIndexMap.java#20 $
Author:
John V. Sichi

Method Summary
 FarragoMedLocalIndexStats computeIndexStats(FarragoDataWrapperCache wrapperCache, FemLocalIndex index, boolean estimate)
          Verifies an index and records returns page count for the index.
 void createIndexStorage(FarragoDataWrapperCache wrapperCache, FemLocalIndex index)
          Creates an index and records its root in this map.
 long createIndexStorage(FarragoDataWrapperCache wrapperCache, FemLocalIndex index, boolean updateMap)
          Creates an index and optionally records its root in this map.
 void dropIndexStorage(FarragoDataWrapperCache wrapperCache, FemLocalIndex index, boolean truncate)
          Drops an index and removes its root from this map.
 void dropIndexStorage(FarragoDataWrapperCache wrapperCache, String indexMofId, boolean truncate)
          Drops an index by MOFID and removes its root from this map.
 FemLocalIndex getIndexById(long id)
          Gets an index by its repository ID.
 long getIndexRoot(FemLocalIndex index)
          Gets the root PageId of an index to be used for reading.
 long getIndexRoot(FemLocalIndex index, boolean write)
          Gets the root PageId of an index to be used for reading or for writing.
 CwmTable getOldTableStructure()
          For ALTER TABLE ADD COLUMN, retrieves the old table structure corresponding to the table being modified.
 CwmTable getReloadTable()
          For ALTER TABLE ADD COLUMN or REBUILD, retrieves the target table.
 void instantiateTemporaryTable(FarragoDataWrapperCache wrapperCache, CwmTable table)
          Called on every reference to a temporary table.
 void onCommit()
          Commit hook.
 void setIndexRoot(FemLocalIndex index, long pageId)
          Sets the root PageId of an index.
 void versionIndexRoot(FarragoDataWrapperCache wrapperCache, FemLocalIndex index, Long newRoot)
          Versions an index root page.
 

Method Detail

getIndexById

FemLocalIndex getIndexById(long id)
Gets an index by its repository ID.

Parameters:
id - index ID in repository
Returns:
corresponding index

getIndexRoot

long getIndexRoot(FemLocalIndex index)
Gets the root PageId of an index to be used for reading.

Parameters:
index - the index of interest
Returns:
root PageId as a long

getIndexRoot

long getIndexRoot(FemLocalIndex index,
                  boolean write)
Gets the root PageId of an index to be used for reading or for writing.

Parameters:
index - the index of interest
write - whether to access a root for reading or writing. A root for reading reflects the index before modifications. A root for writing may be the same root, or may reflect an updated index, depending on the implementation of the session index map.
Returns:
root PageId as a long

setIndexRoot

void setIndexRoot(FemLocalIndex index,
                  long pageId)
Sets the root PageId of an index.

Parameters:
index - the index to be updated
pageId - the root PageId

instantiateTemporaryTable

void instantiateTemporaryTable(FarragoDataWrapperCache wrapperCache,
                               CwmTable table)
Called on every reference to a temporary table. Some implementations may use this to create empty temporary indexes on first reference.

Parameters:
wrapperCache - cache for looking up data wrappers
table - the temporary table

getReloadTable

CwmTable getReloadTable()
For ALTER TABLE ADD COLUMN or REBUILD, retrieves the target table.

Returns:
target table, or null if not executing ALTER TABLE ADD COLUMN or REBUILD

getOldTableStructure

CwmTable getOldTableStructure()
For ALTER TABLE ADD COLUMN, retrieves the old table structure corresponding to the table being modified. Be warned that the old table structure is not a complete copy; it consists of only the column definitions and their datatypes (without default values). Additional logical constructs such as constraints are not present on the returned object, nor are physical constructs such as indexes.

Returns:
copy of old table, or null if not executing ALTER TABLE ADD COLUMN

createIndexStorage

void createIndexStorage(FarragoDataWrapperCache wrapperCache,
                        FemLocalIndex index)
Creates an index and records its root in this map.

Parameters:
wrapperCache - cache for looking up data wrappers
index - the index to create

createIndexStorage

long createIndexStorage(FarragoDataWrapperCache wrapperCache,
                        FemLocalIndex index,
                        boolean updateMap)
Creates an index and optionally records its root in this map.

Parameters:
wrapperCache - cache for looking up data wrappers
index - the index to create
updateMap - whether to record the new root in the map
Returns:
the root of the newly created index storage

dropIndexStorage

void dropIndexStorage(FarragoDataWrapperCache wrapperCache,
                      FemLocalIndex index,
                      boolean truncate)
Drops an index and removes its root from this map.

Parameters:
wrapperCache - cache for looking up data wrappers
index - the index to drop
truncate - if true, only truncate storage; if false, drop storage entirely

dropIndexStorage

void dropIndexStorage(FarragoDataWrapperCache wrapperCache,
                      String indexMofId,
                      boolean truncate)
Drops an index by MOFID and removes its root from this map. This method is used in contexts (e.g. TRUNCATE) where it is undesirable to hold a catalog lock across the entire operation. (Really, this should be the case for all callers, so eventually we should deprecate the version which takes a direct index reference.)

Parameters:
wrapperCache - cache for looking up data wrappers
indexMofId - MOFID of the index to drop
truncate - if true, only truncate storage; if false, drop storage entirely

computeIndexStats

FarragoMedLocalIndexStats computeIndexStats(FarragoDataWrapperCache wrapperCache,
                                            FemLocalIndex index,
                                            boolean estimate)
Verifies an index and records returns page count for the index.

Parameters:
wrapperCache - cache for looking up data wrappers
index - the index to verify
Returns:
page count for the index

onCommit

void onCommit()
Commit hook.


versionIndexRoot

void versionIndexRoot(FarragoDataWrapperCache wrapperCache,
                      FemLocalIndex index,
                      Long newRoot)
Versions an index root page.

Parameters:
wrapperCache - Wrapper cache
index - Index definition
newRoot - new index root ids