org.apache.derby.iapi.sql.dictionary
Class IndexRowGenerator

java.lang.Object
  extended byorg.apache.derby.iapi.sql.dictionary.IndexRowGenerator
All Implemented Interfaces:
java.io.Externalizable, Formatable, IndexDescriptor, java.io.Serializable, TypedFormat

public class IndexRowGenerator
extends java.lang.Object
implements IndexDescriptor, Formatable

This class extends IndexDescriptor for internal use by the DataDictionary.

See Also:
Serialized Form

Field Summary
private  ExecutionFactory ef
           
(package private)  IndexDescriptor id
           
 
Constructor Summary
IndexRowGenerator()
          Zero-argument constructor for Formatable interface
IndexRowGenerator(IndexDescriptor indexDescriptor)
          Constructor for an IndexRowGeneratorImpl
IndexRowGenerator(java.lang.String indexType, boolean isUnique, int[] baseColumnPositions, boolean[] isAscending, int numberOfOrderedColumns)
          Constructor for an IndexRowGeneratorImpl
 
Method Summary
 int[] baseColumnPositions()
          Returns an array of column positions in the base table.
 boolean equals(java.lang.Object other)
          Test for value equality
private  ExecutionFactory getExecutionFactory()
           
 IndexDescriptor getIndexDescriptor()
          Get the IndexDescriptor that this IndexRowGenerator is based on.
 void getIndexRow(ExecRow baseRow, RowLocation rowLocation, ExecIndexRow indexRow, FormatableBitSet bitSet)
          Get an index row for this index given a row from the base table and the RowLocation of the base row.
 ExecIndexRow getIndexRowTemplate()
          Get a template for the index row, to be used with getIndexRow.
 int getKeyColumnPosition(int heapColumnPosition)
          Returns the position of a column within the key (1-based). 0 means that the column is not in the key.
 java.lang.Integer getKeyColumnPosition(java.lang.Integer heapColumnPosition)
          Returns the position of a column within the key (1-based). 0 means that the column is not in the key.
 ExecIndexRow getNullIndexRow(ColumnDescriptorList columnList, RowLocation rowLocation)
          Get a NULL Index Row for this index.
 int getTypeFormatId()
          Get a universally unique identifier for the type of this object.
 int hashCode()
           
 boolean indexChanged(int[] changedColumnIds)
          Return true iff a change to a set of columns changes the index for this IndexRowGenerator.
 java.lang.String indexType()
          Returns the type of the index.
 boolean[] isAscending()
          Returns array of boolean telling asc/desc info for each index key column for convenience of using together with baseColumnPositions method.
 boolean isAscending(java.lang.Integer keyColumnPosition)
          Returns true if the specified column is ascending in the index (1-based).
 boolean isDescending(java.lang.Integer keyColumnPosition)
          Returns true if the specified column is descending in the index (1-based).
 boolean isUnique()
          Returns true if the index is unique.
 int numberOfOrderedColumns()
          Returns the number of ordered columns.
 void readExternal(java.io.ObjectInput in)
           
 void setBaseColumnPositions(int[] baseColumnPositions)
          set the baseColumnPositions field of the index descriptor.
 void setIsAscending(boolean[] isAscending)
          set the isAscending field of the index descriptor.
 void setNumberOfOrderedColumns(int numberOfOrderedColumns)
          set the numberOfOrderedColumns field of the index descriptor.
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

id

IndexDescriptor id

ef

private ExecutionFactory ef
Constructor Detail

IndexRowGenerator

public IndexRowGenerator(java.lang.String indexType,
                         boolean isUnique,
                         int[] baseColumnPositions,
                         boolean[] isAscending,
                         int numberOfOrderedColumns)
Constructor for an IndexRowGeneratorImpl

Parameters:
indexType - The type of index
isUnique - True means the index is unique
baseColumnPositions - An array of column positions in the base table. Each index column corresponds to a column position in the base table.
isAscending - An array of booleans telling asc/desc on each column.
numberOfOrderedColumns - In the future, it will be possible to store non-ordered columns in an index. These will be useful for covered queries.

IndexRowGenerator

public IndexRowGenerator(IndexDescriptor indexDescriptor)
Constructor for an IndexRowGeneratorImpl

Parameters:
indexDescriptor - An IndexDescriptor to delegate calls to

IndexRowGenerator

public IndexRowGenerator()
Zero-argument constructor for Formatable interface

Method Detail

getIndexRowTemplate

public ExecIndexRow getIndexRowTemplate()
Get a template for the index row, to be used with getIndexRow.

Returns:
A row template for the index row.

getIndexRow

public void getIndexRow(ExecRow baseRow,
                        RowLocation rowLocation,
                        ExecIndexRow indexRow,
                        FormatableBitSet bitSet)
                 throws StandardException
Get an index row for this index given a row from the base table and the RowLocation of the base row. This method can be used to get the new index row for inserts, and the old and new index rows for deletes and updates. For updates, the result row has all the old column values followed by all of the new column values, so you must form a row using the new column values to pass to this method to get the new index row.

Parameters:
baseRow - A row in the base table
rowLocation - The RowLocation of the row in the base table
indexRow - A template for the index row. It must have the correct number of columns.
bitSet - If non-null, then baseRow is a partial row and the set bits in bitSet represents the column mapping for the partial row to the complete base row. WARNING: ONE based!!!
Returns:
An index row conforming to this index description containing the column values from the base row and the given row location.
Throws:
StandardException - Thrown on error

getNullIndexRow

public ExecIndexRow getNullIndexRow(ColumnDescriptorList columnList,
                                    RowLocation rowLocation)
                             throws StandardException
Get a NULL Index Row for this index. This is useful to create objects that need to be passed to ScanController.

Parameters:
rowLocation - empty row location.
Throws:
StandardException - thrown on error.

indexChanged

public boolean indexChanged(int[] changedColumnIds)
Return true iff a change to a set of columns changes the index for this IndexRowGenerator.

Parameters:
changedColumnIds - - holds the 1 based column ids for the changed columns.
Returns:
true iff a change to one of the columns in changedColumnIds effects this index.

getIndexDescriptor

public IndexDescriptor getIndexDescriptor()
Get the IndexDescriptor that this IndexRowGenerator is based on.


isUnique

public boolean isUnique()
Description copied from interface: IndexDescriptor
Returns true if the index is unique.

Specified by:
isUnique in interface IndexDescriptor
See Also:
IndexDescriptor.isUnique()

baseColumnPositions

public int[] baseColumnPositions()
Description copied from interface: IndexDescriptor
Returns an array of column positions in the base table. Each index column corresponds to a column position in the base table, except the column representing the location of the row in the base table. The returned array holds the column positions in the base table, so, if entry 2 is the number 4, the second column in the index is the fourth column in the table.

Specified by:
baseColumnPositions in interface IndexDescriptor
See Also:
IndexDescriptor.baseColumnPositions()

getKeyColumnPosition

public java.lang.Integer getKeyColumnPosition(java.lang.Integer heapColumnPosition)
Description copied from interface: IndexDescriptor
Returns the position of a column within the key (1-based). 0 means that the column is not in the key.

Specified by:
getKeyColumnPosition in interface IndexDescriptor
See Also:
IndexDescriptor.getKeyColumnPosition(java.lang.Integer)

getKeyColumnPosition

public int getKeyColumnPosition(int heapColumnPosition)
Description copied from interface: IndexDescriptor
Returns the position of a column within the key (1-based). 0 means that the column is not in the key. Same as the above method, but it uses int instead of Integer.

Specified by:
getKeyColumnPosition in interface IndexDescriptor
See Also:
IndexDescriptor.getKeyColumnPosition(java.lang.Integer)

numberOfOrderedColumns

public int numberOfOrderedColumns()
Description copied from interface: IndexDescriptor
Returns the number of ordered columns. In the future, it will be possible to store non-ordered columns in an index. These will be useful for covered queries. The ordered columns will be at the beginning of the index row, and they will be followed by the non-ordered columns. For now, all columns in an index must be ordered.

Specified by:
numberOfOrderedColumns in interface IndexDescriptor
See Also:
IndexDescriptor.numberOfOrderedColumns()

indexType

public java.lang.String indexType()
Description copied from interface: IndexDescriptor
Returns the type of the index. For now, we only support B-Trees, so the value "BTREE" is returned.

Specified by:
indexType in interface IndexDescriptor
See Also:
IndexDescriptor.indexType()

toString

public java.lang.String toString()

isAscending

public boolean isAscending(java.lang.Integer keyColumnPosition)
Description copied from interface: IndexDescriptor
Returns true if the specified column is ascending in the index (1-based).

Specified by:
isAscending in interface IndexDescriptor
See Also:
IndexDescriptor.isAscending()

isDescending

public boolean isDescending(java.lang.Integer keyColumnPosition)
Description copied from interface: IndexDescriptor
Returns true if the specified column is descending in the index (1-based). In the current release, only ascending columns are supported.

Specified by:
isDescending in interface IndexDescriptor
See Also:
IndexDescriptor.isDescending(java.lang.Integer)

isAscending

public boolean[] isAscending()
Description copied from interface: IndexDescriptor
Returns array of boolean telling asc/desc info for each index key column for convenience of using together with baseColumnPositions method. Both methods return an array with subscript starting from 0.

Specified by:
isAscending in interface IndexDescriptor
See Also:
IndexDescriptor.isAscending()

setBaseColumnPositions

public void setBaseColumnPositions(int[] baseColumnPositions)
Description copied from interface: IndexDescriptor
set the baseColumnPositions field of the index descriptor. This is for updating the field in operations such as "alter table drop column" where baseColumnPositions is changed.

Specified by:
setBaseColumnPositions in interface IndexDescriptor
See Also:
IndexDescriptor.setBaseColumnPositions(int[])

setIsAscending

public void setIsAscending(boolean[] isAscending)
Description copied from interface: IndexDescriptor
set the isAscending field of the index descriptor. This is for updating the field in operations such as "alter table drop column" where isAscending is changed.

Specified by:
setIsAscending in interface IndexDescriptor
See Also:
IndexDescriptor.setIsAscending(boolean[])

setNumberOfOrderedColumns

public void setNumberOfOrderedColumns(int numberOfOrderedColumns)
Description copied from interface: IndexDescriptor
set the numberOfOrderedColumns field of the index descriptor. This is for updating the field in operations such as "alter table drop column" where numberOfOrderedColumns is changed.

Specified by:
setNumberOfOrderedColumns in interface IndexDescriptor
See Also:
IndexDescriptor.setNumberOfOrderedColumns(int)

equals

public boolean equals(java.lang.Object other)
Test for value equality

Parameters:
other - The other indexrowgenerator to compare this one with
Returns:
true if this indexrowgenerator has the same value as other

hashCode

public int hashCode()
See Also:
Object.hashCode()

getExecutionFactory

private ExecutionFactory getExecutionFactory()

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException - Thrown on read error
java.lang.ClassNotFoundException - Thrown on read error
See Also:
Externalizable.readExternal(java.io.ObjectInput)

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException - Thrown on write error

getTypeFormatId

public int getTypeFormatId()
Description copied from interface: TypedFormat
Get a universally unique identifier for the type of this object.

Specified by:
getTypeFormatId in interface TypedFormat
Returns:
The identifier. (A UUID stuffed in an array of 16 bytes).


Apache Derby V10.0 Engine Documentation - Copyright © 1997,2004 The Apache Software Foundation or its licensors, as applicable.