Top Description Fields Constructors Methods
org.apache.derby.iapi.sql.dictionary

public Class IndexRowGenerator

extends Object
implements IndexDescriptor, Formatable
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.services.io.Formatable, org.apache.derby.iapi.services.io.TypedFormat, java.io.Externalizable, java.io.Serializable, org.apache.derby.catalog.IndexDescriptor
Imports
java.io.IOException, .ObjectInput, .ObjectOutput, org.apache.derby.catalog.IndexDescriptor, org.apache.derby.catalog.types.IndexDescriptorImpl, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.services.context.Context, .ContextService, org.apache.derby.iapi.services.io.Formatable, .FormatableBitSet, .StoredFormatIds, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.sql.execute.ExecIndexRow, .ExecRow, .ExecutionContext, .ExecutionFactory, org.apache.derby.iapi.types.RowLocation, .StringDataValue, .DataTypeDescriptor

This class extends IndexDescriptor for internal use by the DataDictionary.

For a description of how deferrable and non-deferrable constraints are backed differently, including the meaning of the boolean attributes used here, see org.apache.derby.catalog.IndexDescriptor.

Field Summary

Modifier and TypeField and Description
private ExecutionFactory
private IndexDescriptor

Constructor Summary

AccessConstructor and Description
public
IndexRowGenerator(String
The type of index
indexType
,
boolean
True means the index is unique
isUnique
,
boolean
means the index is almost unique i.e. unique only for non null keys
isUniqueWithDuplicateNulls
,
boolean
True means the index represents a PRIMARY KEY or a UNIQUE NOT NULL constraint which is deferrable.
isUniqueDeferrable
,
boolean
True if the index is used to back a deferrable constraint
hasDeferrableChecking
,
int[]
An array of column positions in the base table. Each index column corresponds to a column position in the base table.
baseColumnPositions
,
boolean[]
An array of booleans telling asc/desc on each column.
isAscending
,
int
In the future, it will be possible to store non-ordered columns in an index. These will be useful for covered queries.
numberOfOrderedColumns
)

Constructor for an IndexRowGeneratorImpl

public
IndexRowGenerator(IndexDescriptor
An IndexDescriptor to delegate calls to
indexDescriptor
)

Constructor for an IndexRowGeneratorImpl

public
IndexRowGenerator()

Zero-argument constructor for Formatable interface

Method Summary

Modifier and TypeMethod and Description
public int[]
baseColumnPositions()

Implements org.apache.derby.catalog.IndexDescriptor.baseColumnPositions.

Returns an array of column positions in the base table.

public boolean

Returns:

true if this indexrowgenerator has the same value as other
equals
(Object
The other indexrowgenerator to compare this one with
other
)

Overrides java.lang.Object.equals.

Test for value equality

public int[]
getColumnCollationIds(ColumnDescriptorList
ColumnDescriptors describing the base table.
columnList
)

Return an array of collation ids for this table.

private static Context
getContext(final String contextID)

Must be private so that user code can't call this entry point.

private ExecutionFactory
public IndexDescriptor
getIndexDescriptor()

Get the IndexDescriptor that this IndexRowGenerator is based on.

public void
getIndexRow(ExecRow
A row in the base table
baseRow
,
RowLocation
The RowLocation of the row in the base table
rowLocation
,
ExecIndexRow
A template for the index row. It must have the correct number of columns.
indexRow
,
FormatableBitSet
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!!!

bitSet
)

Get an index row for this index given a row from the base table and the RowLocation of the base row.

public ExecIndexRow

Returns:

A row template for the index row.
getIndexRowTemplate
()

Get a template for the index row, to be used with getIndexRow.

public int
getKeyColumnPosition(int
Position of column in heap row
heapColumnPosition
)

Implements org.apache.derby.catalog.IndexDescriptor.getKeyColumnPosition.

Returns the postion of a column.

public ExecIndexRow
getNullIndexRow(ColumnDescriptorList
ColumnDescriptors describing the base table.
columnList
,
RowLocation
empty row location.
rowLocation
)

Get a NULL Index Row for this index.

public int
getTypeFormatId()

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Get a universally unique identifier for the type of this object.

public boolean
hasDeferrableChecking()

Implements org.apache.derby.catalog.IndexDescriptor.hasDeferrableChecking.

Returns true if the index is used to support a deferrable constraint.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public String
indexType()

Implements org.apache.derby.catalog.IndexDescriptor.indexType.

Returns the type of the index.

public boolean
isAscending(Integer
Key column number
keyColumnPosition
)

Implements org.apache.derby.catalog.IndexDescriptor.isAscending.

Returns true if the specified column is ascending in the index (1-based).

public boolean[]
isAscending()

Implements org.apache.derby.catalog.IndexDescriptor.isAscending.

Returns array of boolean telling asc/desc info for each index key column for convenience of using together with baseColumnPositions method.

public boolean
isDescending(Integer
Key column number
keyColumnPosition
)

Implements org.apache.derby.catalog.IndexDescriptor.isDescending.

Returns true if the specified column is descending in the index (1-based).

public boolean
isUnique()

Implements org.apache.derby.catalog.IndexDescriptor.isUnique.

Returns true if the index is unique.

public boolean
isUniqueDeferrable()

Implements org.apache.derby.catalog.IndexDescriptor.isUniqueDeferrable.

The index represents a PRIMARY KEY or a UNIQUE NOT NULL constraint which is deferrable.

public boolean
isUniqueWithDuplicateNulls()

Implements org.apache.derby.catalog.IndexDescriptor.isUniqueWithDuplicateNulls.

Returns true if the index is duplicate keys only for null key parts.

public int
public void
readExternal(ObjectInput
the stream to read data from in order to restore the object
in
)

Implements java.io.Externalizable.readExternal.

The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays.

public void
setBaseColumnPositions(int[]
Positions of base columns
baseColumnPositions
)

Implements org.apache.derby.catalog.IndexDescriptor.setBaseColumnPositions.

set the baseColumnPositions field of the index descriptor.

public void
setIsAscending(boolean[]
Set the direction of each column in the key
isAscending
)

Implements org.apache.derby.catalog.IndexDescriptor.setIsAscending.

set the isAscending field of the index descriptor.

public void
setNumberOfOrderedColumns(int
Number of ordered columns
numberOfOrderedColumns
)

Implements org.apache.derby.catalog.IndexDescriptor.setNumberOfOrderedColumns.

set the numberOfOrderedColumns field of the index descriptor.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
writeExternal(ObjectOutput
the stream to write the object to
out
)

Implements java.io.Externalizable.writeExternal.

The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

efback to summary
private ExecutionFactory ef
idback to summary
private IndexDescriptor id

Constructor Detail

IndexRowGeneratorback to summary
public IndexRowGenerator(String indexType, boolean isUnique, boolean isUniqueWithDuplicateNulls, boolean isUniqueDeferrable, boolean hasDeferrableChecking, int[] baseColumnPositions, boolean[] isAscending, int numberOfOrderedColumns)

Constructor for an IndexRowGeneratorImpl

Parameters
indexType:String

The type of index

isUnique:boolean

True means the index is unique

isUniqueWithDuplicateNulls:boolean

means the index is almost unique i.e. unique only for non null keys

isUniqueDeferrable:boolean

True means the index represents a PRIMARY KEY or a UNIQUE NOT NULL constraint which is deferrable.

hasDeferrableChecking:boolean

True if the index is used to back a deferrable constraint

baseColumnPositions:int[]

An array of column positions in the base table. Each index column corresponds to a column position in the base table.

isAscending:boolean[]

An array of booleans telling asc/desc on each column.

numberOfOrderedColumns:int

In the future, it will be possible to store non-ordered columns in an index. These will be useful for covered queries.

IndexRowGeneratorback to summary
public IndexRowGenerator(IndexDescriptor indexDescriptor)

Constructor for an IndexRowGeneratorImpl

Parameters
indexDescriptor:IndexDescriptor

An IndexDescriptor to delegate calls to

IndexRowGeneratorback to summary
public IndexRowGenerator()

Zero-argument constructor for Formatable interface

Method Detail

baseColumnPositionsback to summary
public int[] baseColumnPositions()

Implements org.apache.derby.catalog.IndexDescriptor.baseColumnPositions.

Doc from org.apache.derby.catalog.IndexDescriptor.baseColumnPositions.

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.

Returns:int[]

an array of column positions in the base table

See Also
IndexDescriptor#baseColumnPositions
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Test for value equality

Parameters
other:Object

The other indexrowgenerator to compare this one with

Returns:boolean

true if this indexrowgenerator has the same value as other

getColumnCollationIdsback to summary
public int[] getColumnCollationIds(ColumnDescriptorList columnList) throws StandardException

Return an array of collation ids for this table.

Return an array of collation ids, one for each column in the columnDescriptorList. This is useful for passing collation id info down to store, for instance in createConglomerate() to create the index. This is only expected to get called during ddl, so object allocation is ok.

Parameters
columnList:ColumnDescriptorList

ColumnDescriptors describing the base table.

Exceptions
StandardException:
Standard exception policy.
getContextback to summary
private static Context getContext(final String contextID)

Must be private so that user code can't call this entry point.

getExecutionFactoryback to summary
private ExecutionFactory getExecutionFactory()
getIndexDescriptorback to summary
public IndexDescriptor getIndexDescriptor()

Get the IndexDescriptor that this IndexRowGenerator is based on.

getIndexRowback to summary
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:ExecRow

A row in the base table

rowLocation:RowLocation

The RowLocation of the row in the base table

indexRow:ExecIndexRow

A template for the index row. It must have the correct number of columns.

bitSet:FormatableBitSet

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!!!

Exceptions
StandardException:
Thrown on error
getIndexRowTemplateback to summary
public ExecIndexRow getIndexRowTemplate()

Get a template for the index row, to be used with getIndexRow.

Returns:ExecIndexRow

A row template for the index row.

getKeyColumnPositionback to summary
public int getKeyColumnPosition(int heapColumnPosition)

Implements org.apache.derby.catalog.IndexDescriptor.getKeyColumnPosition.

Doc from org.apache.derby.catalog.IndexDescriptor.getKeyColumnPosition.

Returns the postion of a column.

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.

Parameters
heapColumnPosition:int

Position of column in heap row

Returns:int

the position of the column in the key

See Also
IndexDescriptor#getKeyColumnPosition
getNullIndexRowback to summary
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
columnList:ColumnDescriptorList

ColumnDescriptors describing the base table.

rowLocation:RowLocation

empty row location.

Exceptions
StandardException:
thrown on error.
getTypeFormatIdback to summary
public int getTypeFormatId()

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Doc from org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Get a universally unique identifier for the type of this object.

Returns:int

The identifier. (A UUID stuffed in an array of 16 bytes).

hasDeferrableCheckingback to summary
public boolean hasDeferrableChecking()

Implements org.apache.derby.catalog.IndexDescriptor.hasDeferrableChecking.

Doc from org.apache.derby.catalog.IndexDescriptor.hasDeferrableChecking.

Returns true if the index is used to support a deferrable constraint.

Returns:boolean

true if the index is used to support a deferrable constraint

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

See Also
java.lang.Object#hashCode
indexTypeback to summary
public String indexType()

Implements org.apache.derby.catalog.IndexDescriptor.indexType.

Doc from org.apache.derby.catalog.IndexDescriptor.indexType.

Returns the type of the index. For now, we only support B-Trees, so the value "BTREE" is returned.

Returns:String

the type of the index

See Also
IndexDescriptor#indexType
isAscendingback to summary
public boolean isAscending(Integer keyColumnPosition)

Implements org.apache.derby.catalog.IndexDescriptor.isAscending.

Doc from org.apache.derby.catalog.IndexDescriptor.isAscending.

Returns true if the specified column is ascending in the index (1-based).

Parameters
keyColumnPosition:Integer

Key column number

Returns:boolean

true if the specified column is ascending in the index

See Also
IndexDescriptor#isAscending
isAscendingback to summary
public boolean[] isAscending()

Implements org.apache.derby.catalog.IndexDescriptor.isAscending.

Doc from org.apache.derby.catalog.IndexDescriptor.isAscending.

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.

Returns:boolean[]

array of boolean telling asc/desc info for each index key

See Also
IndexDescriptor#isAscending
isDescendingback to summary
public boolean isDescending(Integer keyColumnPosition)

Implements org.apache.derby.catalog.IndexDescriptor.isDescending.

Doc from org.apache.derby.catalog.IndexDescriptor.isDescending.

Returns true if the specified column is descending in the index (1-based). In the current release, only ascending columns are supported.

Parameters
keyColumnPosition:Integer

Key column number

Returns:boolean

true if the specified column is descending in the index

See Also
IndexDescriptor#isDescending
isUniqueback to summary
public boolean isUnique()

Implements org.apache.derby.catalog.IndexDescriptor.isUnique.

Doc from org.apache.derby.catalog.IndexDescriptor.isUnique.

Returns true if the index is unique.

Returns:boolean

true if the index is unique

See Also
IndexDescriptor#isUnique
isUniqueDeferrableback to summary
public boolean isUniqueDeferrable()

Implements org.apache.derby.catalog.IndexDescriptor.isUniqueDeferrable.

Doc from org.apache.derby.catalog.IndexDescriptor.isUniqueDeferrable.

The index represents a PRIMARY KEY or a UNIQUE NOT NULL constraint which is deferrable. true implies isUnique() == false and isUniqueWithDuplicateNulls() == false and hasDeferrableChecking() == true.

Returns:boolean

true if the index represents such a constraint

isUniqueWithDuplicateNullsback to summary
public boolean isUniqueWithDuplicateNulls()

Implements org.apache.derby.catalog.IndexDescriptor.isUniqueWithDuplicateNulls.

Doc from org.apache.derby.catalog.IndexDescriptor.isUniqueWithDuplicateNulls.

Returns true if the index is duplicate keys only for null key parts. This is effective only if isUnique is false.

Returns:boolean

true if the index is duplicate keys only for null key parts

See Also
IndexDescriptor#isUniqueWithDuplicateNulls
numberOfOrderedColumnsback to summary
public int numberOfOrderedColumns()

Implements org.apache.derby.catalog.IndexDescriptor.numberOfOrderedColumns.

Doc from org.apache.derby.catalog.IndexDescriptor.numberOfOrderedColumns.

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.

Returns:int

the number of ordered columns

See Also
IndexDescriptor#numberOfOrderedColumns
readExternalback to summary
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException

Implements java.io.Externalizable.readExternal.

Doc from java.io.Externalizable.readExternal.

The object implements the readExternal method to restore its contents by calling the methods of DataInput for primitive types and readObject for objects, strings and arrays. The readExternal method must read the values in the same sequence and with the same types as were written by writeExternal.

Parameters
in:ObjectInput

the stream to read data from in order to restore the object

Exceptions
IOException:
Thrown on read error
ClassNotFoundException:
Thrown on read error
See Also
java.io.Externalizable#readExternal
setBaseColumnPositionsback to summary
public void setBaseColumnPositions(int[] baseColumnPositions)

Implements org.apache.derby.catalog.IndexDescriptor.setBaseColumnPositions.

Doc from org.apache.derby.catalog.IndexDescriptor.setBaseColumnPositions.

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.

Parameters
baseColumnPositions:int[]

Positions of base columns

See Also
IndexDescriptor#setBaseColumnPositions
setIsAscendingback to summary
public void setIsAscending(boolean[] isAscending)

Implements org.apache.derby.catalog.IndexDescriptor.setIsAscending.

Doc from org.apache.derby.catalog.IndexDescriptor.setIsAscending.

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.

Parameters
isAscending:boolean[]

Set the direction of each column in the key

See Also
IndexDescriptor#setIsAscending
setNumberOfOrderedColumnsback to summary
public void setNumberOfOrderedColumns(int numberOfOrderedColumns)

Implements org.apache.derby.catalog.IndexDescriptor.setNumberOfOrderedColumns.

Doc from org.apache.derby.catalog.IndexDescriptor.setNumberOfOrderedColumns.

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.

Parameters
numberOfOrderedColumns:int

Number of ordered columns

See Also
IndexDescriptor#setNumberOfOrderedColumns
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

writeExternalback to summary
public void writeExternal(ObjectOutput out) throws IOException

Implements java.io.Externalizable.writeExternal.

Doc from java.io.Externalizable.writeExternal.

The object implements the writeExternal method to save its contents by calling the methods of DataOutput for its primitive values or calling the writeObject method of ObjectOutput for objects, strings, and arrays.

Parameters
out:ObjectOutput

the stream to write the object to

Exceptions
IOException:
Thrown on write error