org.apache.cassandra.db.index

## Class SecondaryIndexManager

- java.lang.Object
- - org.apache.cassandra.db.index.SecondaryIndexManager

    public class SecondaryIndexManager
    extends java.lang.Object

Manages all the indexes associated with a given CFS Different types of indexes can be created across the same CF

### Nested Class Summary

Nested Classes
`static interface` `SecondaryIndexManager.Updater`

### Field Summary

Fields
`ColumnFamilyStore` `baseCfs` The underlying column family containing the source data for these indexes
`static SecondaryIndexManager.Updater` `nullUpdater`

### Constructor Summary

Constructors
Constructor and Description
`SecondaryIndexManager(ColumnFamilyStore baseCfs)`

### Method Summary

Methods
`java.util.concurrent.Future<?>` `addIndexedColumn(ColumnDefinition cdef)` Adds and builds a index for a column
`java.util.Set<java.lang.String>` `allIndexesNames()`
`void` `deleteFromIndexes(DecoratedKey key, java.util.List<Column> indexedColumnsInRow)` Delete all columns from all indexes for this row.
`void` `flushIndexesBlocking()` Flush all indexes to disk
`java.util.List<java.lang.String>` `getBuiltIndexes()`
`java.util.Collection<SecondaryIndex>` `getIndexes()`
`java.util.Collection<ColumnFamilyStore>` `getIndexesBackedByCfs()`
`java.util.Collection<SecondaryIndex>` `getIndexesByNames(java.util.Set<java.lang.String> idxNames)`
`java.util.Collection<SecondaryIndex>` `getIndexesNotBackedByCfs()`
`SecondaryIndex` `getIndexForColumn(java.nio.ByteBuffer column)`
`long` `getTotalLiveSize()`
`boolean` `hasIndexes()`
`boolean` `hasIndexFor(java.util.List<IndexExpression> clause)`
`boolean` `indexes(java.nio.ByteBuffer name)`
`boolean` `indexes(java.nio.ByteBuffer name, java.util.Collection<SecondaryIndex> indexes)`
`boolean` `indexes(Column column)`
`java.util.List<SecondaryIndex>` `indexFor(java.nio.ByteBuffer name)`
`java.util.List<SecondaryIndex>` `indexFor(java.nio.ByteBuffer name, java.util.Collection<SecondaryIndex> indexes)`
`void` `indexRow(java.nio.ByteBuffer key, ColumnFamily cf)` When building an index against existing data, add the given row to the index
`void` `invalidate()` Remove the index
`void` `maybeBuildSecondaryIndexes(java.util.Collection<SSTableReader> sstables, java.util.Set<java.lang.String> idxNames)` Does a full, blocking rebuild of the indexes specified by columns from the sstables.
`void` `reload()` Drops and adds new indexes associated with the underlying CF
`void` `removeIndexedColumn(java.nio.ByteBuffer column)` Removes a existing index
`java.util.List<Row>` `search(ExtendedFilter filter)` Performs a search across a number of column indexes TODO: add support for querying across index types
`void` `setIndexBuilt(java.util.Set<java.lang.String> idxNames)`
`void` `setIndexRemoved(java.util.Set<java.lang.String> idxNames)`
`SecondaryIndexManager.Updater` `updaterFor(DecoratedKey key)` Updated closure with only the modified row key.
`SecondaryIndexManager.Updater` `updaterFor(DecoratedKey key, ColumnFamily cf)` This helper acts as a closure around the indexManager and updated cf data to ensure that down in Memtable's ColumnFamily implementation, the index can get updated.
`boolean` `validate(Column column)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### nullUpdater

    public static final SecondaryIndexManager.Updater nullUpdater

#### baseCfs

    public final ColumnFamilyStore baseCfs

The underlying column family containing the source data for these indexes

### Constructor Detail

#### SecondaryIndexManager

    public SecondaryIndexManager(ColumnFamilyStore baseCfs)

### Method Detail

#### reload

    public void reload()

Drops and adds new indexes associated with the underlying CF

#### allIndexesNames

    public java.util.Set<java.lang.String> allIndexesNames()

#### maybeBuildSecondaryIndexes

    public void maybeBuildSecondaryIndexes(java.util.Collection<SSTableReader> sstables,
                                  java.util.Set<java.lang.String> idxNames)

Does a full, blocking rebuild of the indexes specified by columns from the sstables. Does nothing if columns is empty. Caller must acquire and release references to the sstables used here.

Parameters:
  `sstables` - the data to build from
  `idxNames` - the list of columns to index, ordered by comparator

#### indexes

    public boolean indexes(java.nio.ByteBuffer name,
                  java.util.Collection<SecondaryIndex> indexes)

#### indexFor

    public java.util.List<SecondaryIndex> indexFor(java.nio.ByteBuffer name,
                                          java.util.Collection<SecondaryIndex> indexes)

#### indexes

    public boolean indexes(Column column)

#### indexes

    public boolean indexes(java.nio.ByteBuffer name)

#### indexFor

    public java.util.List<SecondaryIndex> indexFor(java.nio.ByteBuffer name)

#### hasIndexFor

    public boolean hasIndexFor(java.util.List<IndexExpression> clause)

Returns:
  true if the indexes can handle the clause.

#### removeIndexedColumn

    public void removeIndexedColumn(java.nio.ByteBuffer column)

Removes a existing index

Parameters:
  `column` - the indexed column to remove

#### addIndexedColumn

    public java.util.concurrent.Future<?> addIndexedColumn(ColumnDefinition cdef)

Adds and builds a index for a column

Parameters:
  `cdef` - the column definition holding the index data
Returns:
  a future which the caller can optionally block on signaling the index is built

#### getIndexForColumn

    public SecondaryIndex getIndexForColumn(java.nio.ByteBuffer column)

Parameters:
  `column` - the name of indexes column
Returns:
  the index

#### invalidate

    public void invalidate()

Remove the index

#### flushIndexesBlocking

    public void flushIndexesBlocking()

Flush all indexes to disk

#### getBuiltIndexes

    public java.util.List<java.lang.String> getBuiltIndexes()

Returns:
  all built indexes (ready to use)

#### getIndexesBackedByCfs

    public java.util.Collection<ColumnFamilyStore> getIndexesBackedByCfs()

Returns:
  all CFS from indexes which use a backing CFS internally (KEYS)

#### getIndexesNotBackedByCfs

    public java.util.Collection<SecondaryIndex> getIndexesNotBackedByCfs()

Returns:
  all indexes which do *not* use a backing CFS internally

#### getIndexes

    public java.util.Collection<SecondaryIndex> getIndexes()

Returns:
  all of the secondary indexes without distinction to the (non-)backed by secondary ColumnFamilyStore.

#### hasIndexes

    public boolean hasIndexes()

Returns:
  if there are ANY indexes for this table..

#### getTotalLiveSize

    public long getTotalLiveSize()

Returns:
  total current ram size of all indexes

#### indexRow

    public void indexRow(java.nio.ByteBuffer key,
                ColumnFamily cf)

When building an index against existing data, add the given row to the index

Parameters:
  `key` - the row key
  `cf` - the current rows data

#### deleteFromIndexes

    public void deleteFromIndexes(DecoratedKey key,
                         java.util.List<Column> indexedColumnsInRow)

Delete all columns from all indexes for this row. For when cleanup rips a row out entirely.

Parameters:
  `key` - the row key
  `indexedColumnsInRow` - all column names in row

#### updaterFor

    public SecondaryIndexManager.Updater updaterFor(DecoratedKey key,
                                           ColumnFamily cf)

This helper acts as a closure around the indexManager and updated cf data to ensure that down in Memtable's ColumnFamily implementation, the index can get updated. Note: only a CF backed by AtomicSortedColumns implements this behaviour fully, other types simply ignore the index updater.

#### updaterFor

    public SecondaryIndexManager.Updater updaterFor(DecoratedKey key)

Updated closure with only the modified row key.

#### search

    public java.util.List<Row> search(ExtendedFilter filter)

Performs a search across a number of column indexes TODO: add support for querying across index types

Parameters:
  `filter` - the column range to restrict to
Returns:
  found indexed rows

#### getIndexesByNames

    public java.util.Collection<SecondaryIndex> getIndexesByNames(java.util.Set<java.lang.String> idxNames)

#### setIndexBuilt

    public void setIndexBuilt(java.util.Set<java.lang.String> idxNames)

#### setIndexRemoved

    public void setIndexRemoved(java.util.Set<java.lang.String> idxNames)

#### validate

    public boolean validate(Column column)