Top Description Methods
org.apache.derby.catalog

public Interface IndexDescriptor

Known Direct Implementers
org.apache.derby.catalog.types.IndexDescriptorImpl, org.apache.derby.iapi.sql.dictionary.IndexRowGenerator

This interface describes an index. It is used in the column SYS.SYSCONGLOMERATES.DESCRIPTOR and describes everything about an index except the index name and the table on which the index is defined. That information is available in the columns NAME and TABLEID of the table SYS.SYSCONGLOMERATES.

Whereas non-deferrable constraints are backed by UNIQUE indexes, deferrable constraints are backed by non-unique indexes. The duplicate checking on inserts and updates for deferrable constraints are handled at the language level, not by the store level. The following table shows the correspondence between the constraint types and the index attributes used:

Method Summary

Modifier and TypeMethod and Description
public int[]

Returns:

an array of column positions in the base table
baseColumnPositions
()

Returns an array of column positions in the base table.

public int

Returns:

the position of the column in the key
getKeyColumnPosition
(int
Position of column in heap row
heapColumnPosition
)

Returns the postion of a column.

public boolean

Returns:

true if the index is used to support a deferrable constraint
hasDeferrableChecking
()

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

public String

Returns:

the type of the index
indexType
()

Returns the type of the index.

public boolean[]

Returns:

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

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

public boolean

Returns:

true if the specified column is ascending in the index
isAscending
(Integer
Key column number
keyColumnPosition
)

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

public boolean

Returns:

true if the specified column is descending in the index
isDescending
(Integer
Key column number
keyColumnPosition
)

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

public boolean

Returns:

true if the index is unique
isUnique
()

Returns true if the index is unique.

public boolean

Returns:

true if the index represents such a constraint
isUniqueDeferrable
()

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

public boolean

Returns:

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

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

public int

Returns:

the number of ordered columns
numberOfOrderedColumns
()

Returns the number of ordered columns.

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

set the baseColumnPositions field of the index descriptor.

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

set the isAscending field of the index descriptor.

public void
setNumberOfOrderedColumns(int
Number of ordered columns
numberOfOrderedColumns
)

set the numberOfOrderedColumns field of the index descriptor.

Method Detail

baseColumnPositionsback to summary
public int[] 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

getKeyColumnPositionback to summary
public int getKeyColumnPosition(int heapColumnPosition)

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

hasDeferrableCheckingback to summary
public boolean 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

indexTypeback to summary
public String 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

isAscendingback to summary
public boolean[] 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

isAscendingback to summary
public boolean isAscending(Integer keyColumnPosition)

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

isDescendingback to summary
public boolean isDescending(Integer keyColumnPosition)

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

isUniqueback to summary
public boolean isUnique()

Returns true if the index is unique.

Returns:boolean

true if the index is unique

isUniqueDeferrableback to summary
public boolean 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()

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

numberOfOrderedColumnsback to summary
public int 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

setBaseColumnPositionsback to summary
public void setBaseColumnPositions(int[] baseColumnPositions)

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

setIsAscendingback to summary
public void setIsAscending(boolean[] isAscending)

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

setNumberOfOrderedColumnsback to summary
public void setNumberOfOrderedColumns(int numberOfOrderedColumns)

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