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
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `SecondaryIndexManager.Updater`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `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

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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<Cell> indexedColumnsInRow, OpOrder.Group opGroup)` Delete all columns from all indexes for this row.
    `void` | `flushIndexesBlocking()` Flush all indexes to disk
    `SecondaryIndexManager.Updater` | `gcUpdaterFor(DecoratedKey key)` Updated closure with only the modified row key.
    `java.util.List<java.lang.String>` | `getBuiltIndexes()`
    `SecondaryIndexSearcher` | `getHighestSelectivityIndexSearcher(java.util.List<IndexExpression> clause)`
    `SecondaryIndex` | `getIndexByName(java.lang.String name)`
    `java.util.Collection<SecondaryIndex>` | `getIndexes()`
    `java.util.Set<ColumnFamilyStore>` | `getIndexesBackedByCfs()`
    `java.util.Set<SecondaryIndex>` | `getIndexesByNames(java.util.Set<java.lang.String> idxNames)`
    `java.util.Set<SecondaryIndex>` | `getIndexesNotBackedByCfs()`
    `SecondaryIndex` | `getIndexForColumn(java.nio.ByteBuffer column)`
    `java.util.List<SecondaryIndexSearcher>` | `getIndexSearchersForQuery(java.util.List<IndexExpression> clause)` Get a list of IndexSearchers from the union of expression index types
    `boolean` | `hasIndexes()`
    `boolean` | `hasIndexFor(java.util.List<IndexExpression> clause)`
    `boolean` | `indexes(Cell cell)`
    `boolean` | `indexes(CellName name)`
    `boolean` | `indexes(CellName name, java.util.Collection<SecondaryIndex> indexes)`
    `java.util.Set<SecondaryIndex>` | `indexFor(CellName name)`
    `java.util.Set<SecondaryIndex>` | `indexFor(CellName name, java.util.Collection<SecondaryIndex> indexes)`
    `void` | `indexRow(java.nio.ByteBuffer key, ColumnFamily cf, OpOrder.Group opGroup)` 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
    `void` | `setIndexBuilt(java.util.Set<java.lang.String> idxNames)`
    `void` | `setIndexRemoved(java.util.Set<java.lang.String> idxNames)`
    `SecondaryIndexManager.Updater` | `updaterFor(DecoratedKey key, ColumnFamily cf, OpOrder.Group opGroup)` 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.
    `SecondaryIndex` | `validate(java.nio.ByteBuffer rowKey, Cell cell)`
    `void` | `validateIndexSearchersForQuery(java.util.List<IndexExpression> clause)` Validates an union of expression index types.
    `void` | `validateRowLevelIndexes(java.nio.ByteBuffer key, ColumnFamily cf)`

    - ### 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(CellName name,
                                 java.util.Collection<SecondaryIndex> indexes)

    - #### indexFor

          public java.util.Set<SecondaryIndex> indexFor(CellName name,
                                                        java.util.Collection<SecondaryIndex> indexes)

    - #### indexes

          public boolean indexes(Cell cell)

    - #### indexes

          public boolean indexes(CellName name)

    - #### indexFor

          public java.util.Set<SecondaryIndex> indexFor(CellName name)

    - #### hasIndexFor

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

      Returns:
        true if at least one of 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.Set<ColumnFamilyStore> getIndexesBackedByCfs()

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

    - #### getIndexesNotBackedByCfs

          public java.util.Set<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.

    - #### getIndexByName

          public SecondaryIndex getIndexByName(java.lang.String name)

    - #### hasIndexes

          public boolean hasIndexes()

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

    - #### indexRow

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

      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<Cell> indexedColumnsInRow,
                                        OpOrder.Group opGroup)

      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,
                                                          OpOrder.Group opGroup)

      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.

    - #### gcUpdaterFor

          public SecondaryIndexManager.Updater gcUpdaterFor(DecoratedKey key)

      Updated closure with only the modified row key.

    - #### getIndexSearchersForQuery

          public java.util.List<SecondaryIndexSearcher> getIndexSearchersForQuery(java.util.List<IndexExpression> clause)

      Get a list of IndexSearchers from the union of expression index types
      Parameters:
        `clause` - the query clause
      Returns:
        the searchers needed to query the index

    - #### validateIndexSearchersForQuery

          public void validateIndexSearchersForQuery(java.util.List<IndexExpression> clause)
                                              throws InvalidRequestException

      Validates an union of expression index types. It will throw a `RuntimeException` if any of the expressions in the provided clause is not valid for its index implementation.
      Parameters:
        `clause` - the query clause
      Throws:
        `InvalidRequestException` - in case of validation errors

    - #### search

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

      Performs a search across a number of column indexes
      Parameters:
        `filter` - the column range to restrict to
      Returns:
        found indexed rows

    - #### getIndexesByNames

          public java.util.Set<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 SecondaryIndex validate(java.nio.ByteBuffer rowKey,
                                         Cell cell)

    - #### validateRowLevelIndexes

          public void validateRowLevelIndexes(java.nio.ByteBuffer key,
                                              ColumnFamily cf)
                                       throws InvalidRequestException

      Throws:
        `InvalidRequestException`

    - #### getHighestSelectivityIndexSearcher

          public SecondaryIndexSearcher getHighestSelectivityIndexSearcher(java.util.List<IndexExpression> clause)

Copyright © 2018 The Apache Software Foundation