org.apache.cassandra.db.index
Class SecondaryIndexManager

java.lang.Object
  extended by 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
static interface SecondaryIndexManager.Updater
           
 
Field Summary
 ColumnFamilyStore baseCfs
          The underlying column family containing the source data for these indexes
static SecondaryIndexManager.Updater nullUpdater
           
 
Constructor Summary
SecondaryIndexManager(ColumnFamilyStore baseCfs)
           
 
Method Summary
 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<IColumn> 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.nio.ByteBuffer getColumnByIdxName(java.lang.String idxName)
           
 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 hasIndexFor(java.util.List<org.apache.cassandra.thrift.IndexExpression> clause)
           
 boolean indexes(java.nio.ByteBuffer name)
           
 boolean indexes(java.nio.ByteBuffer name, java.util.Collection<SecondaryIndex> indexes)
           
 boolean indexes(IColumn column)
           
 SecondaryIndex indexFor(java.nio.ByteBuffer name)
           
 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(java.util.List<org.apache.cassandra.thrift.IndexExpression> clause, AbstractBounds<RowPosition> range, int maxResults, IDiskAtomFilter dataFilter, boolean countCQL3Rows)
          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, boolean includeRowIndexes)
          This helper acts as a closure around the indexManager and row key to ensure that down in Memtable's ColumnFamily implementation, the index can get updated.
 boolean validate(org.apache.cassandra.thrift.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 SecondaryIndex indexFor(java.nio.ByteBuffer name,
                               java.util.Collection<SecondaryIndex> indexes)

indexes

public boolean indexes(IColumn column)

indexes

public boolean indexes(java.nio.ByteBuffer name)

indexFor

public SecondaryIndex indexFor(java.nio.ByteBuffer name)

hasIndexFor

public boolean hasIndexFor(java.util.List<org.apache.cassandra.thrift.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)

getColumnByIdxName

public java.nio.ByteBuffer getColumnByIdxName(java.lang.String idxName)

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.

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<IColumn> 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,
                                                boolean includeRowIndexes)
This helper acts as a closure around the indexManager and row key 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.


search

public java.util.List<Row> search(java.util.List<org.apache.cassandra.thrift.IndexExpression> clause,
                                  AbstractBounds<RowPosition> range,
                                  int maxResults,
                                  IDiskAtomFilter dataFilter,
                                  boolean countCQL3Rows)
Performs a search across a number of column indexes TODO: add support for querying across index types

Parameters:
clause - the index query clause
range - the row range to restrict to
dataFilter - 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(org.apache.cassandra.thrift.Column column)


Copyright © 2013 The Apache Software Foundation