Index

An index. Indexes are used to speed up searching data.

Methods
void add(Session session, Row row)
Add a row to the index.
void add(Session session, Row row)
Add a row to the index.
Parameters:
session - the session to use
row - the row to add
boolean canFindNext()
Check if the index can get the next higher value.
boolean canFindNext()
Check if the index can get the next higher value.
Returns:
true if it can
boolean canGetFirstOrLast()
Check if the index can directly look up the lowest or highest value of a column.
boolean canGetFirstOrLast()
Check if the index can directly look up the lowest or highest value of a column.
Returns:
true if it can
boolean canScan()
Can this index iterate over all rows?
boolean canScan()
Can this index iterate over all rows?
Returns:
true if it can
void close(Session session)
Close this index.
void close(Session session)
Close this index.
Parameters:
session - the session used to write data
void commit(int operation, Row row)
Commit the operation for a row.
void commit(int operation, Row row)
Commit the operation for a row. This is only important for multi-version indexes. The method is only called if multi-version is enabled.
Parameters:
operation - the operation type
row - the row
int compareRows(SearchRow rowData, SearchRow compare)
Compare two rows.
int compareRows(SearchRow rowData, SearchRow compare)
Compare two rows.
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
IndexLookupBatch createLookupBatch(TableFilter[] filters, int filter)
Creates new lookup batch.
IndexLookupBatch createLookupBatch(TableFilter[] filters, int filter)
Creates new lookup batch. Note that returned {@link IndexLookupBatch} instance can be used multiple times.
Parameters:
filters - the table filters
filter - the filter index (0, 1,...)
Returns:
created batch or {@code null} if batched lookup is not supported by this index.
Cursor find(Session session, SearchRow first, SearchRow last)
Find a row or a list of rows and create a cursor to iterate over the result.
Cursor find(Session session, SearchRow first, SearchRow last)
Find a row or a list of rows and create a cursor to iterate over the result.
Parameters:
session - the session
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
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 find(TableFilter filter, SearchRow first, SearchRow last)
Find a row or a list of rows and create a cursor to iterate over the result.
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
Cursor findFirstOrLast(Session session, boolean first)
Find the first (or last) value of this index.
Cursor findFirstOrLast(Session session, boolean first)
Find the first (or last) value of this index. The cursor returned is positioned on the correct row, or on null if no row has been found.
Parameters:
session - the session
first - true if the first (lowest for ascending indexes) or last value should be returned
Returns:
a cursor (never null)
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.
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.
Parameters:
session - the session
higherThan - the lower limit (excluding)
last - the last row, or null for no limit
Returns:
the cursor
int getColumnIndex(Column col)
Get the index of a column in the list of index columns
int getColumnIndex(Column col)
Get the index of a column in the list of index columns
Parameters:
col - the column
Returns:
the index (0 meaning first column)
Column[] getColumns()
Get the indexed columns.
Column[] getColumns()
Get the indexed columns.
Returns:
the columns
double getCost(Session session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, HashSet allColumnsSet)
Estimate the cost to search for rows given the search mask.
double getCost(Session session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, HashSet allColumnsSet)
Estimate the cost to search for rows given the search mask. There is one element per column in the search mask. For possible search masks, see IndexCondition.
Parameters:
session - the session
masks - per-column comparison bit masks, null means 'always false', see constants in IndexCondition
filters - all joined table filters
filter - the current table filter index
sortOrder - the sort order
allColumnsSet - the set of all columns
Returns:
the estimated cost
long getDiskSpaceUsed()
Get the used disk space for this index.
long getDiskSpaceUsed()
Get the used disk space for this index.
Returns:
the estimated number of bytes
IndexColumn[] getIndexColumns()
Get the indexed columns as index columns (with ordering information).
IndexColumn[] getIndexColumns()
Get the indexed columns as index columns (with ordering information).
Returns:
the index columns
IndexType getIndexType()
Get the index type.
IndexType getIndexType()
Get the index type.
Returns:
the index type
String getPlanSQL()
Get the message to show in a EXPLAIN statement.
String getPlanSQL()
Get the message to show in a EXPLAIN statement.
Returns:
the plan
Row getRow(Session session, long key)
Get the row with the given key.
Row getRow(Session session, long key)
Get the row with the given key.
Parameters:
session - the session
key - the unique key
Returns:
the row
long getRowCount(Session session)
Get the row count of this table, for the given session.
long getRowCount(Session session)
Get the row count of this table, for the given session.
Parameters:
session - the session
Returns:
the row count
long getRowCountApproximation()
Get the approximated row count for this table.
long getRowCountApproximation()
Get the approximated row count for this table.
Returns:
the approximated row count
Table getTable()
Get the table on which this index is based.
Table getTable()
Get the table on which this index is based.
Returns:
the table
boolean isFindUsingFullTableScan()
Returns
boolean isFindUsingFullTableScan()
Returns {@code true} if {@code find()} implementation performs scan over all index, {@code false} if {@code find()} performs the fast lookup.
Returns:
{@code true} if {@code find()} implementation performs scan over all index, {@code false} if {@code find()} performs the fast lookup
boolean isFirstColumn(Column column)
Check if the given column is the first for this index
boolean isFirstColumn(Column column)
Check if the given column is the first for this index
Parameters:
column - the column
Returns:
true if the given columns is the first
boolean isRowIdIndex()
Does this index support lookup by row id?
boolean isRowIdIndex()
Does this index support lookup by row id?
Returns:
true if it does
boolean needRebuild()
Check if the index needs to be rebuilt.
boolean needRebuild()
Check if the index needs to be rebuilt. This method is called after opening an index.
Returns:
true if a rebuild is required.
void remove(Session session, Row row)
Remove a row from the index.
void remove(Session session, Row row)
Remove a row from the index.
Parameters:
session - the session
row - the row
void remove(Session session)
Remove the index.
void remove(Session session)
Remove the index.
Parameters:
session - the session
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.
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.
Parameters:
sortedInsertMode - the new value
void truncate(Session session)
Remove all rows from the index.
void truncate(Session session)
Remove all rows from the index.
Parameters:
session - the session