Interface IndexDescriptor

All Known Implementing Classes:
IndexDescriptorImpl, IndexRowGenerator

public interface IndexDescriptor
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:

  • Non-deferrable PRIMARY KEY and UNIQUE NOT NULL on all constraint columns
                                \  Value  | Number of index columns | Check
       Attribute                 \        | in physical BTree key   | in
       --------------------------------------------------------------------
       unique                     | true  | N - 1 (row location     |
       isUniqueWithDuplicateNulls | false |        not part of key) | Store
       uniqueDeferrable           | false |                         | Btree
       hasDeferrableChecking      | false |                         | code
      
  • Non-deferrable UNIQUE, where at least one constraint column is nullable.
                                \  Value  | Number of index columns | Check
       Attribute                 \        | in physical BTree key   | in
       ------------------------------------------------------------ -------
       unique                     | false | N                       |
       isUniqueWithDuplicateNulls | true  |                         | Store
       uniqueDeferrable           | false |                         | Btree
       hasDeferrableChecking      | false |                         | code
      
  • Deferrable PRIMARY KEY and UNIQUE NOT NULL on all constraint columns
                                \  Value  | Number of index columns | Check
       Attribute                 \        | in physical BTree key   | in
       ------------------------------------------------------------ -------
       unique                     | false | N                       |
       isUniqueWithDuplicateNulls | false |                         | Lang.
       uniqueDeferrable           | true  |                         | code
       hasDeferrableChecking      | true  |                         |
      
  • Deferrable UNIQUE, where at least one constraint column is nullable.
                                \  Value  | Number of index columns | Check
       Attribute                 \        | in physical BTree key   | in
       ------------------------------------------------------------ -------
       unique                     | false | N                       |
       isUniqueWithDuplicateNulls | true  |                         | Lang.
       uniqueDeferrable           | false |                         | code
       hasDeferrableChecking      | true  |                         |
      
  • Method Summary

    Modifier and Type
    Method
    Description
    int[]
    Returns an array of column positions in the base table.
    int
    getKeyColumnPosition(int heapColumnPosition)
    Returns the postion of a column.
    boolean
    Returns true if the index is used to support a deferrable constraint.
    Returns the type of the index.
    boolean[]
    Returns array of boolean telling asc/desc info for each index key column for convenience of using together with baseColumnPositions method.
    boolean
    isAscending(Integer keyColumnPosition)
    Returns true if the specified column is ascending in the index (1-based).
    boolean
    isDescending(Integer keyColumnPosition)
    Returns true if the specified column is descending in the index (1-based).
    boolean
    Returns true if the index is unique.
    boolean
    The index represents a PRIMARY KEY or a UNIQUE NOT NULL constraint which is deferrable.
    boolean
    Returns true if the index is duplicate keys only for null key parts.
    int
    Returns the number of ordered columns.
    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.
  • Method Details

    • isUnique

      boolean isUnique()
      Returns true if the index is unique.
    • isUniqueWithDuplicateNulls

      boolean isUniqueWithDuplicateNulls()
      Returns true if the index is duplicate keys only for null key parts. This is effective only if isUnique is false.
    • isUniqueDeferrable

      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:
      true if the index represents such a constraint
    • hasDeferrableChecking

      boolean hasDeferrableChecking()
      Returns true if the index is used to support a deferrable constraint.
    • baseColumnPositions

      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.
    • getKeyColumnPosition

      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.

    • numberOfOrderedColumns

      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.

    • indexType

      String indexType()
      Returns the type of the index. For now, we only support B-Trees, so the value "BTREE" is returned.
    • isAscending

      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.
    • isAscending

      boolean isAscending(Integer keyColumnPosition)
      Returns true if the specified column is ascending in the index (1-based).
    • isDescending

      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.
    • setBaseColumnPositions

      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.
    • setIsAscending

      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.
    • setNumberOfOrderedColumns

      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.