org.apache.derby.impl.sql.catalog
Class TabInfoImpl

java.lang.Object
  extended by org.apache.derby.impl.sql.catalog.TabInfoImpl

 class TabInfoImpl
extends java.lang.Object

A poor mans structure used in DataDictionaryImpl.java. Used to save heapId, name pairs for non core tables.


Field Summary
private  boolean computedStreamStorableHeapColIds
           
private  CatalogRowFactory crf
           
private  long heapConglomerate
           
private  boolean heapSet
           
private  IndexInfoImpl[] indexes
           
private  int numIndexesSet
           
(package private) static int ROWNOTDUPLICATE
          ROWNOTDUPLICATE is out of range for a row number.
private  int[] streamStorableHeapColIds
           
 
Constructor Summary
TabInfoImpl(CatalogRowFactory crf)
          Constructor
 
Method Summary
(package private)  int deleteRow(TransactionController tc, ExecIndexRow key, int indexNumber)
          Given a key row, delete all matching heap rows and their index rows.
(package private)  int deleteRow(TransactionController tc, ExecIndexRow key, int indexNumber, boolean wait)
           
(package private)  int deleteRows(TransactionController tc, ExecIndexRow startKey, int startOp, Qualifier[][] qualifier, TupleFilter filter, ExecIndexRow stopKey, int stopOp, int indexNumber)
          Delete the set of rows defined by a scan on an index from the table.
private  int deleteRows(TransactionController tc, ExecIndexRow startKey, int startOp, Qualifier[][] qualifier, TupleFilter filter, ExecIndexRow stopKey, int stopOp, int indexNumber, boolean wait)
           
(package private)  int getBaseColumnPosition(int indexNumber, int colNumber)
          Get the base column position for a column within a catalog given the (0-based) index number for this catalog and the (0-based) column number for the column within the index.
(package private)  CatalogRowFactory getCatalogRowFactory()
          Get the CatalogRowFactory for this.
(package private)  java.util.Properties getCreateHeapProperties()
          Get the Properties associated with creating the heap.
(package private)  java.util.Properties getCreateIndexProperties(int indexNumber)
          Get the Properties associated with creating the specified index.
(package private)  long getHeapConglomerate()
          Get the conglomerate for the heap.
(package private)  int getIndexColumnCount(int indexNumber)
          Get the column count for the specified index number.
(package private)  long getIndexConglomerate(int indexID)
          Get the conglomerate for the specified index.
(package private)  java.lang.String getIndexName(int indexId)
          Get the index name.
private  ExecIndexRow getIndexRowFromHeapRow(IndexRowGenerator irg, RowLocation rl, ExecRow heapRow)
          Get an index row based on a row from the heap.
(package private)  IndexRowGenerator getIndexRowGenerator(int indexNumber)
          Get the IndexRowGenerator for the specified index number.
(package private)  int getNumberOfIndexes()
          Get the number of indexes on this catalog.
(package private)  ExecRow getRow(TransactionController tc, ConglomerateController heapCC, ExecIndexRow key, int indexNumber)
          Given a key row, return the first matching heap row.
(package private)  ExecRow getRow(TransactionController tc, ExecIndexRow key, int indexNumber)
          Given a key row, return the first matching heap row.
private  RowChanger getRowChanger(TransactionController tc, int[] changedCols, ExecRow baseRow)
          Gets a row changer for this catalog.
private  ExecRow getRowInternal(TransactionController tc, ConglomerateController heapCC, ExecIndexRow key, int indexNumber, RowLocation[] rl)
           
(package private)  RowLocation getRowLocation(TransactionController tc, ExecIndexRow key, int indexNumber)
          Given an index row and index number return the RowLocation in the heap of the first matching row.
private  int[] getStreamStorableHeapColIds(ExecRow baseRow)
           
(package private)  java.lang.String getTableName()
          Get the table name.
(package private)  int insertRow(ExecRow row, TransactionController tc)
          Inserts a base row into a catalog and inserts all the corresponding index rows.
(package private)  int insertRowList(ExecRow[] rowList, TransactionController tc)
          Inserts a list of base rows into a catalog and inserts all the corresponding index rows.
private  int insertRowListImpl(ExecRow[] rowList, TransactionController tc, RowLocation[] rowLocationOut)
          Insert logic to insert a list of rows into a table.
(package private)  boolean isComplete()
          Is this fully initialized.
(package private)  boolean isIndexUnique(int indexNumber)
          Return whether or not this index is declared unique
(package private)  void setHeapConglomerate(long heapConglomerate)
          Set the heap conglomerate for this.
(package private)  void setIndexConglomerate(ConglomerateDescriptor cd)
          Set the index conglomerate for the table.
(package private)  void setIndexConglomerate(int index, long indexConglomerate)
          Set the index conglomerate for the table.
(package private)  void setIndexRowGenerator(int indexNumber, IndexRowGenerator irg)
          Set the IndexRowGenerator for the specified index number.
 java.lang.String toString()
           
(package private)  void updateRow(ExecIndexRow key, ExecRow[] newRows, int indexNumber, boolean[] indicesToUpdate, int[] colsToUpdate, TransactionController tc)
          Updates a set of base rows in a catalog with the same key on an index and updates all the corresponding index rows.
(package private)  void updateRow(ExecIndexRow key, ExecRow newRow, int indexNumber, boolean[] indicesToUpdate, int[] colsToUpdate, TransactionController tc)
          Updates a base row in a catalog and updates all the corresponding index rows.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ROWNOTDUPLICATE

static final int ROWNOTDUPLICATE
ROWNOTDUPLICATE is out of range for a row number. If a return code does not equal this value, then it refers to the row that is a duplicate.

See Also:
Constant Field Values

indexes

private IndexInfoImpl[] indexes

heapConglomerate

private long heapConglomerate

numIndexesSet

private int numIndexesSet

heapSet

private boolean heapSet

crf

private final CatalogRowFactory crf

computedStreamStorableHeapColIds

private boolean computedStreamStorableHeapColIds

streamStorableHeapColIds

private int[] streamStorableHeapColIds
Constructor Detail

TabInfoImpl

TabInfoImpl(CatalogRowFactory crf)
Constructor

Parameters:
crf - the associated CatalogRowFactory
Method Detail

getHeapConglomerate

long getHeapConglomerate()
Get the conglomerate for the heap.

Returns:
long The conglomerate for the heap.

setHeapConglomerate

void setHeapConglomerate(long heapConglomerate)
Set the heap conglomerate for this.

Parameters:
heapConglomerate - The new heap conglomerate.

getIndexConglomerate

long getIndexConglomerate(int indexID)
Get the conglomerate for the specified index.

Returns:
long The conglomerate for the specified index.

setIndexConglomerate

void setIndexConglomerate(int index,
                          long indexConglomerate)
Set the index conglomerate for the table.

Parameters:
index - Index number for index for table
indexConglomerate - The conglomerate for that index

setIndexConglomerate

void setIndexConglomerate(ConglomerateDescriptor cd)
Set the index conglomerate for the table.

Parameters:
cd - The ConglomerateDescriptor for one of the index for this table.

getTableName

java.lang.String getTableName()
Get the table name.

Returns:
String The table name.

getIndexName

java.lang.String getIndexName(int indexId)
Get the index name.

Parameters:
indexId - Index number for index for table
Returns:
String The index name.

getCatalogRowFactory

CatalogRowFactory getCatalogRowFactory()
Get the CatalogRowFactory for this.

Returns:
CatalogRowFactory The CatalogRowFactory for this.

isComplete

boolean isComplete()
Is this fully initialized. (i.e., is all conglomerate info initialized)

Returns:
boolean Whether or not this is fully initialized.

getIndexColumnCount

int getIndexColumnCount(int indexNumber)
Get the column count for the specified index number.

Parameters:
indexNumber - The index number.
Returns:
int The column count for the specified index.

getIndexRowGenerator

IndexRowGenerator getIndexRowGenerator(int indexNumber)
Get the IndexRowGenerator for the specified index number.

Parameters:
indexNumber - The index number.
Returns:
IndexRowGenerator The IRG for the specified index number.

setIndexRowGenerator

void setIndexRowGenerator(int indexNumber,
                          IndexRowGenerator irg)
Set the IndexRowGenerator for the specified index number.

Parameters:
indexNumber - The index number.
irg - The IndexRowGenerator for the specified index number.

getNumberOfIndexes

int getNumberOfIndexes()
Get the number of indexes on this catalog.

Returns:
int The number of indexes on this catalog.

getBaseColumnPosition

int getBaseColumnPosition(int indexNumber,
                          int colNumber)
Get the base column position for a column within a catalog given the (0-based) index number for this catalog and the (0-based) column number for the column within the index.

Parameters:
indexNumber - The index number
colNumber - The column number within the index
Returns:
int The base column position for the column.

isIndexUnique

boolean isIndexUnique(int indexNumber)
Return whether or not this index is declared unique

Parameters:
indexNumber - The index number
Returns:
boolean Whether or not this index is declared unique

insertRow

int insertRow(ExecRow row,
              TransactionController tc)
        throws StandardException
Inserts a base row into a catalog and inserts all the corresponding index rows.

Parameters:
row - row to insert
tc - transaction
Returns:
row number (>= 0) if duplicate row inserted into an index ROWNOTDUPLICATE otherwise
Throws:
StandardException - Thrown on failure

insertRowList

int insertRowList(ExecRow[] rowList,
                  TransactionController tc)
            throws StandardException
Inserts a list of base rows into a catalog and inserts all the corresponding index rows.

Parameters:
rowList - List of rows to insert
tc - transaction controller
Returns:
row number (>= 0) if duplicate row inserted into an index ROWNOTDUPLICATE otherwise
Throws:
StandardException - Thrown on failure

insertRowListImpl

private int insertRowListImpl(ExecRow[] rowList,
                              TransactionController tc,
                              RowLocation[] rowLocationOut)
                       throws StandardException
Insert logic to insert a list of rows into a table. This logic has two odd features.
  1. Returns an indication if any returned row was a duplicate.
  2. Returns the RowLocation of the last row inserted.

Parameters:
rowList - the list of rows to insert
tc - transaction controller
rowLocationOut - on output rowLocationOut[0] is set to the last RowLocation inserted.
Returns:
row number (>= 0) if duplicate row inserted into an index ROWNOTDUPLICATE otherwise
Throws:
StandardException

deleteRow

int deleteRow(TransactionController tc,
              ExecIndexRow key,
              int indexNumber)
        throws StandardException
Given a key row, delete all matching heap rows and their index rows.

LOCKING: row locking if there is a key; otherwise, table locking.

Parameters:
tc - transaction controller
key - key to delete by.
indexNumber - Key is appropriate for this index.
Returns:
the number of rows deleted. If key is not unique, this may be more than one.
Throws:
StandardException - Thrown on failure

deleteRow

int deleteRow(TransactionController tc,
              ExecIndexRow key,
              int indexNumber,
              boolean wait)
        throws StandardException
Throws:
StandardException

deleteRows

int deleteRows(TransactionController tc,
               ExecIndexRow startKey,
               int startOp,
               Qualifier[][] qualifier,
               TupleFilter filter,
               ExecIndexRow stopKey,
               int stopOp,
               int indexNumber)
         throws StandardException
Delete the set of rows defined by a scan on an index from the table. Most of the parameters are simply passed to TransactionController.openScan. Please refer to the TransactionController documentation for details.

LOCKING: row locking if there is a start and a stop key; otherwise, table locking

Parameters:
tc - transaction controller
startKey - key to start the scan.
startOp - operation to start the scan.
stopKey - key to start the scan.
qualifier - a qualifier for the scan.
filter - filter on base rows
stopOp - operation to start the scan.
indexNumber - Key is appropriate for this index.
Returns:
the number of rows deleted.
Throws:
StandardException - Thrown on failure
See Also:
TransactionController.openScan(long, boolean, int, int, int, org.apache.derby.iapi.services.io.FormatableBitSet, org.apache.derby.iapi.types.DataValueDescriptor[], int, org.apache.derby.iapi.store.access.Qualifier[][], org.apache.derby.iapi.types.DataValueDescriptor[], int)

deleteRows

private int deleteRows(TransactionController tc,
                       ExecIndexRow startKey,
                       int startOp,
                       Qualifier[][] qualifier,
                       TupleFilter filter,
                       ExecIndexRow stopKey,
                       int stopOp,
                       int indexNumber,
                       boolean wait)
                throws StandardException
Throws:
StandardException

getRow

ExecRow getRow(TransactionController tc,
               ExecIndexRow key,
               int indexNumber)
         throws StandardException
Given a key row, return the first matching heap row.

LOCKING: shared row locking.

Parameters:
tc - transaction controller
key - key to read by.
indexNumber - Key is appropriate for this index.
Throws:
StandardException - Thrown on failure

getRowLocation

RowLocation getRowLocation(TransactionController tc,
                           ExecIndexRow key,
                           int indexNumber)
                     throws StandardException
Given an index row and index number return the RowLocation in the heap of the first matching row. Used by the autoincrement code to get the RowLocation in syscolumns given a pair.

Parameters:
tc - Transaction Controller to use.
key - Index Row to search in the index.
indexNumber - Identifies the index to use.
Throws:
StandardException - thrown on failure.
See Also:
DataDictionaryImpl.computeRowLocation(TransactionController, TableDescriptor, String)

getRow

ExecRow getRow(TransactionController tc,
               ConglomerateController heapCC,
               ExecIndexRow key,
               int indexNumber)
         throws StandardException
Given a key row, return the first matching heap row.

LOCKING: shared row locking.

Parameters:
tc - transaction controller
heapCC - heap to look in
key - key to read by.
indexNumber - Key is appropriate for this index.
Throws:
StandardException - Thrown on failure

getRowInternal

private ExecRow getRowInternal(TransactionController tc,
                               ConglomerateController heapCC,
                               ExecIndexRow key,
                               int indexNumber,
                               RowLocation[] rl)
                        throws StandardException
Throws:
StandardException - Thrown on failure

updateRow

void updateRow(ExecIndexRow key,
               ExecRow newRow,
               int indexNumber,
               boolean[] indicesToUpdate,
               int[] colsToUpdate,
               TransactionController tc)
         throws StandardException
Updates a base row in a catalog and updates all the corresponding index rows.

Parameters:
key - key row
newRow - new version of the row
indexNumber - index that key operates
indicesToUpdate - array of booleans, one for each index on the catalog. if a boolean is true, that means we must update the corresponding index because changes in the newRow affect it.
colsToUpdate - array of ints indicating which columns (1 based) to update. If null, do all.
tc - transaction controller
Throws:
StandardException - Thrown on failure

updateRow

void updateRow(ExecIndexRow key,
               ExecRow[] newRows,
               int indexNumber,
               boolean[] indicesToUpdate,
               int[] colsToUpdate,
               TransactionController tc)
         throws StandardException
Updates a set of base rows in a catalog with the same key on an index and updates all the corresponding index rows.

Parameters:
key - key row
newRows - new version of the array of rows
indexNumber - index that key operates
indicesToUpdate - array of booleans, one for each index on the catalog. if a boolean is true, that means we must update the corresponding index because changes in the newRow affect it.
colsToUpdate - array of ints indicating which columns (1 based) to update. If null, do all.
tc - transaction controller
Throws:
StandardException - Thrown on failure

getCreateHeapProperties

java.util.Properties getCreateHeapProperties()
Get the Properties associated with creating the heap.

Returns:
The Properties associated with creating the heap.

getCreateIndexProperties

java.util.Properties getCreateIndexProperties(int indexNumber)
Get the Properties associated with creating the specified index.

Parameters:
indexNumber - The specified index number.
Returns:
The Properties associated with creating the specified index.

getRowChanger

private RowChanger getRowChanger(TransactionController tc,
                                 int[] changedCols,
                                 ExecRow baseRow)
                          throws StandardException
Gets a row changer for this catalog.

Parameters:
tc - transaction controller
changedCols - the columns to change (1 based), may be null
baseRow - used to detemine column types at creation time only. The row changer does ***Not*** keep a referance to this row or change it in any way.
Returns:
a row changer for this catalog.
Throws:
StandardException - Thrown on failure

getStreamStorableHeapColIds

private int[] getStreamStorableHeapColIds(ExecRow baseRow)
                                   throws StandardException
Throws:
StandardException

getIndexRowFromHeapRow

private ExecIndexRow getIndexRowFromHeapRow(IndexRowGenerator irg,
                                            RowLocation rl,
                                            ExecRow heapRow)
                                     throws StandardException
Get an index row based on a row from the heap.

Parameters:
irg - IndexRowGenerator to use
rl - RowLocation for heap
heapRow - Row from the heap
Returns:
ExecIndexRow Index row.
Throws:
StandardException - Thrown on error

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Built on Thu 2012-03-29 21:53:33+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.