## org.h2.index
Class BaseIndex

    java.lang.Object
      org.h2.engine.DbObjectBase
          org.h2.schema.SchemaObjectBase
              org.h2.index.BaseIndex

All Implemented Interfaces:
  DbObject, Index, SchemaObject

Direct Known Subclasses:
  FunctionIndex, HashIndex, LinkedIndex, MetaIndex, PageIndex, RangeIndex, ScanIndex, TreeIndex, ViewIndex

    public abstract class BaseIndex

extends SchemaObjectBase
implements Index

Most index implementations extend the base index.

Field Summary
`protected int[]` `columnIds`
`protected Column[]` `columns`
`protected IndexColumn[]` `indexColumns`
`protected IndexType` `indexType`
`protected boolean` `isMultiVersion`
`protected Table` `table`

Fields inherited from class org.h2.engine.DbObjectBase
`comment, database, trace`

Fields inherited from interface org.h2.engine.DbObject
`AGGREGATE, COMMENT, CONSTANT, CONSTRAINT, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, TABLE_OR_VIEW, TRIGGER, USER, USER_DATATYPE`

Constructor Summary
`BaseIndex()`

Method Summary
`boolean` `canFindNext()` Check if the index can get the next higher value.
`boolean` `canScan()` Can this index iterate over all rows?
`void` `commit(int operation, Row row)` Commit the operation for a row.
`int` `compareRows(SearchRow rowData, SearchRow compare)` Compare two rows.
`Cursor` `find(TableFilter filter, SearchRow first, SearchRow last)` Find a row or a list of rows and create a cursor to iterate over the result.
`Cursor` `findNext(Session session, SearchRow higherThan, SearchRow last)` Find a row or a list of rows that is larger and create a cursor to iterate over the result.
`int` `getColumnIndex(Column col)` Get the index of a column in the list of index columns
`Column[]` `getColumns()` Get the indexed columns.
`java.lang.String` `getCreateSQL()` Build a SQL statement to re-create this object.
`java.lang.String` `getCreateSQLForCopy(Table targetTable, java.lang.String quotedName)` Build a SQL statement to re-create the object, or to create a copy of the object with a different name or referencing a different table
`java.lang.String` `getDropSQL()` Build a SQL statement to drop this object.
`IndexColumn[]` `getIndexColumns()` Get the indexed columns as index columns (with ordering information).
`IndexType` `getIndexType()` Get the index type.
`java.lang.String` `getPlanSQL()` Get the message to show in a EXPLAIN statement.
`Row` `getRow(Session session, long key)` Get the row with the given key.
`Table` `getTable()` Get the table on which this index is based.
`int` `getType()` Get the object type.
`protected void` `initBaseIndex(Table newTable, int id, java.lang.String name, IndexColumn[] newIndexColumns, IndexType newIndexType)` Initialize the base index.
`boolean` `isHidden()` Check whether this is a hidden object that doesn't appear in the meta data and in the script, and is not dropped on DROP ALL OBJECTS.
`boolean` `isRowIdIndex()` Does this index support lookup by row id?
`void` `removeChildrenAndResources(Session session)` Remove all dependent objects and free all resources (files, blocks in files) of this object.
`void` `setSortedInsertMode(boolean sortedInsertMode)` Enable or disable the 'sorted insert' optimizations (rows are inserted in ascending or descending order) if applicable for this index implementation.

Methods inherited from class org.h2.schema.SchemaObjectBase
`getSchema, getSQL, initSchemaObjectBase`

Methods inherited from class org.h2.engine.DbObjectBase
`checkRename, getChildren, getComment, getDatabase, getId, getModificationId, getName, initDbObjectBase, invalidate, isTemporary, rename, setComment, setModified, setObjectName, setTemporary, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.h2.index.Index
`add, canGetFirstOrLast, close, find, findFirstOrLast, getCost, getRowCount, getRowCountApproximation, needRebuild, remove, remove, truncate`

Methods inherited from interface org.h2.schema.SchemaObject
`getSchema`

Methods inherited from interface org.h2.engine.DbObject
`checkRename, getChildren, getComment, getDatabase, getId, getName, getSQL, isTemporary, rename, setComment, setTemporary`

Field Detail

### indexColumns

    protected IndexColumn[] indexColumns

### columns

    protected Column[] columns

### columnIds

    protected int[] columnIds

### table

    protected Table table

### indexType

    protected IndexType indexType

### isMultiVersion

    protected boolean isMultiVersion

Constructor Detail

### BaseIndex

    public BaseIndex()

Method Detail

### initBaseIndex

    protected void initBaseIndex(Table newTable,
                                 int id,
                                 java.lang.String name,
                                 IndexColumn[] newIndexColumns,
                                 IndexType newIndexType)

  Initialize the base index.

  Parameters:
    `newTable` - the table
    `id` - the object id
    `name` - the index name
    `newIndexColumns` - the columns that are indexed or null if this is not yet known
    `newIndexType` - the index type

### getDropSQL

    public java.lang.String getDropSQL()

  Description copied from class: `DbObjectBase`
  Build a SQL statement to drop this object.

  Specified by:
    `getDropSQL` in interface `DbObject`
  Specified by:
    `getDropSQL` in class `DbObjectBase`
  Returns:
    the SQL statement

### getPlanSQL

    public java.lang.String getPlanSQL()

  Description copied from interface: `Index`
  Get the message to show in a EXPLAIN statement.

  Specified by:
    `getPlanSQL` in interface `Index`
  Returns:
    the plan

### removeChildrenAndResources

    public void removeChildrenAndResources(Session session)

  Description copied from class: `DbObjectBase`
  Remove all dependent objects and free all resources (files, blocks in files) of this object.

  Specified by:
    `removeChildrenAndResources` in interface `DbObject`
  Specified by:
    `removeChildrenAndResources` in class `DbObjectBase`
  Parameters:
    `session` - the session

### canFindNext

    public boolean canFindNext()

  Description copied from interface: `Index`
  Check if the index can get the next higher value.

  Specified by:
    `canFindNext` in interface `Index`
  Returns:
    true if it can

### find

    public Cursor find(TableFilter filter,
                       SearchRow first,
                       SearchRow last)

  Description copied from interface: `Index`
  Find a row or a list of rows and create a cursor to iterate over the result.

  Specified by:
    `find` in interface `Index`
  Parameters:
    `filter` - the table filter (which possibly knows about additional conditions)
    `first` - the first row, or null for no limit
    `last` - the last row, or null for no limit
  Returns:
    the cursor to iterate over the results

### findNext

    public Cursor findNext(Session session,
                           SearchRow higherThan,
                           SearchRow last)

  Find a row or a list of rows that is larger and create a cursor to iterate over the result. The base implementation doesn't support this feature.

  Specified by:
    `findNext` in interface `Index`
  Parameters:
    `session` - the session
    `higherThan` - the lower limit (excluding)
    `last` - the last row, or null for no limit
  Returns:
    the cursor
  Throws:
    `DbException` - always

### compareRows

    public int compareRows(SearchRow rowData,
                           SearchRow compare)

  Description copied from interface: `Index`
  Compare two rows.

  Specified by:
    `compareRows` in interface `Index`
  Parameters:
    `rowData` - the first row
    `compare` - the second row
  Returns:
    0 if both rows are equal, -1 if the first row is smaller, otherwise 1

### getColumnIndex

    public int getColumnIndex(Column col)

  Description copied from interface: `Index`
  Get the index of a column in the list of index columns

  Specified by:
    `getColumnIndex` in interface `Index`
  Parameters:
    `col` - the column
  Returns:
    the index (0 meaning first column)

### getCreateSQLForCopy

    public java.lang.String getCreateSQLForCopy(Table targetTable,
                                                java.lang.String quotedName)

  Description copied from interface: `DbObject`
  Build a SQL statement to re-create the object, or to create a copy of the object with a different name or referencing a different table

  Specified by:
    `getCreateSQLForCopy` in interface `DbObject`
  Parameters:
    `targetTable` - the new table
    `quotedName` - the quoted name
  Returns:
    the SQL statement

### getCreateSQL

    public java.lang.String getCreateSQL()

  Description copied from class: `DbObjectBase`
  Build a SQL statement to re-create this object.

  Specified by:
    `getCreateSQL` in interface `DbObject`
  Specified by:
    `getCreateSQL` in class `DbObjectBase`
  Returns:
    the SQL statement

### getIndexColumns

    public IndexColumn[] getIndexColumns()

  Description copied from interface: `Index`
  Get the indexed columns as index columns (with ordering information).

  Specified by:
    `getIndexColumns` in interface `Index`
  Returns:
    the index columns

### getColumns

    public Column[] getColumns()

  Description copied from interface: `Index`
  Get the indexed columns.

  Specified by:
    `getColumns` in interface `Index`
  Returns:
    the columns

### getIndexType

    public IndexType getIndexType()

  Description copied from interface: `Index`
  Get the index type.

  Specified by:
    `getIndexType` in interface `Index`
  Returns:
    the index type

### getType

    public int getType()

  Description copied from interface: `DbObject`
  Get the object type.

  Specified by:
    `getType` in interface `DbObject`
  Returns:
    the object type

### getTable

    public Table getTable()

  Description copied from interface: `Index`
  Get the table on which this index is based.

  Specified by:
    `getTable` in interface `Index`
  Returns:
    the table

### commit

    public void commit(int operation,
                       Row row)

  Description copied from interface: `Index`
  Commit the operation for a row. This is only important for multi-version indexes.

  Specified by:
    `commit` in interface `Index`
  Parameters:
    `operation` - the operation type
    `row` - the row

### getRow

    public Row getRow(Session session,
                      long key)

  Description copied from interface: `Index`
  Get the row with the given key.

  Specified by:
    `getRow` in interface `Index`
  Parameters:
    `session` - the session
    `key` - the unique key
  Returns:
    the row

### isHidden

    public boolean isHidden()

  Description copied from interface: `SchemaObject`
  Check whether this is a hidden object that doesn't appear in the meta data and in the script, and is not dropped on DROP ALL OBJECTS.

  Specified by:
    `isHidden` in interface `SchemaObject`
  Overrides:
    `isHidden` in class `SchemaObjectBase`
  Returns:
    true if it is hidden

### isRowIdIndex

    public boolean isRowIdIndex()

  Description copied from interface: `Index`
  Does this index support lookup by row id?

  Specified by:
    `isRowIdIndex` in interface `Index`
  Returns:
    true if it does

### canScan

    public boolean canScan()

  Description copied from interface: `Index`
  Can this index iterate over all rows?

  Specified by:
    `canScan` in interface `Index`
  Returns:
    true if it can

### setSortedInsertMode

    public void setSortedInsertMode(boolean sortedInsertMode)

  Description copied from interface: `Index`
  Enable or disable the 'sorted insert' optimizations (rows are inserted in ascending or descending order) if applicable for this index implementation.

  Specified by:
    `setSortedInsertMode` in interface `Index`
  Parameters:
    `sortedInsertMode` - the new value