org.apache.cassandra.db.index
Class SecondaryIndex

java.lang.Object
  extended by org.apache.cassandra.db.index.SecondaryIndex
Direct Known Subclasses:
PerColumnSecondaryIndex, PerRowSecondaryIndex

public abstract class SecondaryIndex
extends java.lang.Object

Abstract base class for different types of secondary indexes. Do not extend this directly, please pick from PerColumnSecondaryIndex or PerRowSecondaryIndex


Field Summary
protected  ColumnFamilyStore baseCfs
          Base CF that has many indexes
protected  java.util.Set<ColumnDefinition> columnDefs
          The column definitions which this index is responsible for
static java.lang.String CUSTOM_INDEX_OPTION_NAME
           
 
Constructor Summary
SecondaryIndex()
           
 
Method Summary
 java.util.concurrent.Future<?> buildIndexAsync()
          Builds the index using the data in the underlying CF, non blocking
protected  void buildIndexBlocking()
          Builds the index using the data in the underlying CFS Blocks till it's complete
static SecondaryIndex createInstance(ColumnFamilyStore baseCfs, ColumnDefinition cdef)
          This is the primary way to create a secondary index instance for a CF column.
protected abstract  SecondaryIndexSearcher createSecondaryIndexSearcher(java.util.Set<java.nio.ByteBuffer> columns)
          Called at query time Creates a implementation specific searcher instance for this index type
abstract  void forceBlockingFlush()
          Forces this indexes in memory data to disk
 ColumnFamilyStore getBaseCFStore()
           
abstract  java.lang.String getIndexName()
           
abstract  java.lang.String getNameForSystemTable(java.nio.ByteBuffer columnName)
          Return the unique name for this index and column to be stored in the SystemTable that tracks if each column is built
abstract  ColumnFamilyStore getUnderlyingCfs()
          Allow access to the underlying column family store if there is one
abstract  void init()
          Perform any initialization work
 boolean isIndexBuilt(java.nio.ByteBuffer columnName)
          Checks if the index for specified column is fully built
abstract  void removeIndex(java.nio.ByteBuffer columnName)
          Delete all files and references to this index
abstract  void renameIndex(java.lang.String newCfName)
          Renames the underlying index files to reflect the new CF name
abstract  void unregisterMbean()
          Unregisters this index's mbean if one exists
abstract  void validateOptions()
          Validates the index_options passed in the ColumnDef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CUSTOM_INDEX_OPTION_NAME

public static final java.lang.String CUSTOM_INDEX_OPTION_NAME
See Also:
Constant Field Values

baseCfs

protected ColumnFamilyStore baseCfs
Base CF that has many indexes


columnDefs

protected java.util.Set<ColumnDefinition> columnDefs
The column definitions which this index is responsible for

Constructor Detail

SecondaryIndex

public SecondaryIndex()
Method Detail

init

public abstract void init()
Perform any initialization work


validateOptions

public abstract void validateOptions()
                              throws ConfigurationException
Validates the index_options passed in the ColumnDef

Throws:
ConfigurationException

getIndexName

public abstract java.lang.String getIndexName()
Returns:
The name of the index

getNameForSystemTable

public abstract java.lang.String getNameForSystemTable(java.nio.ByteBuffer columnName)
Return the unique name for this index and column to be stored in the SystemTable that tracks if each column is built

Parameters:
columnName - the name of the column
Returns:
the unique name

isIndexBuilt

public boolean isIndexBuilt(java.nio.ByteBuffer columnName)
Checks if the index for specified column is fully built

Parameters:
columnName - the column
Returns:
true if the index is fully built

createSecondaryIndexSearcher

protected abstract SecondaryIndexSearcher createSecondaryIndexSearcher(java.util.Set<java.nio.ByteBuffer> columns)
Called at query time Creates a implementation specific searcher instance for this index type

Parameters:
columns - the list of columns which belong to this index type
Returns:
the secondary index search impl

forceBlockingFlush

public abstract void forceBlockingFlush()
                                 throws java.io.IOException
Forces this indexes in memory data to disk

Throws:
java.io.IOException

getUnderlyingCfs

public abstract ColumnFamilyStore getUnderlyingCfs()
Allow access to the underlying column family store if there is one

Returns:
the underlying column family store or null

removeIndex

public abstract void removeIndex(java.nio.ByteBuffer columnName)
                          throws java.io.IOException
Delete all files and references to this index

Parameters:
columnName - the indexed column to remove
Throws:
java.io.IOException

renameIndex

public abstract void renameIndex(java.lang.String newCfName)
                          throws java.io.IOException
Renames the underlying index files to reflect the new CF name

Parameters:
newCfName - new column family name.
Throws:
java.io.IOException - on any I/O error.

unregisterMbean

public abstract void unregisterMbean()
Unregisters this index's mbean if one exists


buildIndexBlocking

protected void buildIndexBlocking()
                           throws java.io.IOException
Builds the index using the data in the underlying CFS Blocks till it's complete

Throws:
java.io.IOException

buildIndexAsync

public java.util.concurrent.Future<?> buildIndexAsync()
Builds the index using the data in the underlying CF, non blocking

Returns:
A future object which the caller can block on (optional)

getBaseCFStore

public ColumnFamilyStore getBaseCFStore()

createInstance

public static SecondaryIndex createInstance(ColumnFamilyStore baseCfs,
                                            ColumnDefinition cdef)
                                     throws ConfigurationException
This is the primary way to create a secondary index instance for a CF column. It will validate the index_options before initializing.

Parameters:
baseCfs - the source of data for the Index
cdef - the meta information about this column (index_type, index_options, name, etc...)
Returns:
The secondary index instance for this column
Throws:
ConfigurationException


Copyright © 2011 The Apache Software Foundation