src/java/org/apache/cassandra/db/index/SecondaryIndexManager.java
/**
     * Adds and builds a index for a column
     * @param cdef the column definition holding the index data
     * @return a future which the caller can optionally block on signaling the index is built
     */
Adds and builds a index for a column
@param cdef the column definition holding the index data
@return a future which the caller can optionally block on signaling the index is built
Adds and builds a index for a column @param cdef the column definition holding the index data @return a future which the caller can optionally block on signaling the index is built
public synchronized Future<?> addIndexedColumn(ColumnDefinition cdef)
    {
        if (indexesByColumn.containsKey(cdef.name))
            return null;
        assert cdef.getIndexType() != null;
        logger.info("Creating new index : {}",cdef);
        SecondaryIndex index;
        try
        {
            index = SecondaryIndex.createInstance(baseCfs, cdef);
        } catch (ConfigurationException e)
        {
            throw new RuntimeException(e);
        }      
        if (index instanceof PerRowSecondaryIndex)
        {
            SecondaryIndex currentIndex = rowLevelIndexMap.get(index.getClass());
            if (currentIndex == null)
            {
                rowLevelIndexMap.put(index.getClass(), index);
                index.init();
            }
            else
            {
                index = currentIndex;
                index.addColumnDef(cdef);
            }         
        }
        else
        {
            index.init();
        }
        indexesByColumn.put(cdef.name, index);
        if (index.isIndexBuilt(cdef.name))
            return null;
        return index.buildIndexAsync();
    }
public synchronized Future < ? > addIndexedColumn ( ColumnDefinition cdef ) { if ( indexesByColumn . containsKey ( cdef . name ) ) return null ; assert cdef . getIndexType ( ) != null ; logger . info ( "Creating new index : {}" , cdef ) ; SecondaryIndex index ; try { index = SecondaryIndex . createInstance ( baseCfs , cdef ) ; } catch ( ConfigurationException e ) { throw new RuntimeException ( e ) ; } if ( index instanceof PerRowSecondaryIndex ) { SecondaryIndex currentIndex = rowLevelIndexMap . get ( index . getClass ( ) ) ; if ( currentIndex == null ) { rowLevelIndexMap . put ( index . getClass ( ) , index ) ; index . init ( ) ; } else { index = currentIndex ; index . addColumnDef ( cdef ) ; } } else { index . init ( ) ; } indexesByColumn . put ( cdef . name , index ) ; if ( index . isIndexBuilt ( cdef . name ) ) return null ; return index . buildIndexAsync ( ) ; }
Adds and builds a index for a column
 @param cdef the column definition holding the index data
 @return a future which the caller can optionally block on signaling the index is built
Adds and builds a index for a column @param cdef the column definition holding the index data @return a future which the caller can optionally block on signaling the index is built
// Keep a single instance of the index per-cf for row level indexes // since we want all columns to be under the index // link in indexedColumns. this means that writes will add new data to // the index immediately, // so we don't have to lock everything while we do the build. it's up to // the operator to wait // until the index is actually built before using in queries. // if we're just linking in the index to indexedColumns on an // already-built index post-restart, we're done