Search in sources :

Example 1 with KeysIndex

use of org.apache.cassandra.db.index.keys.KeysIndex in project eiger by wlloyd.

the class SecondaryIndex method createInstance.

/**
     * This is the primary way to create a secondary index instance for a CF column.
     * It will validate the index_options before initializing.
     * 
     * @param baseCfs the source of data for the Index
     * @param cdef the meta information about this column (index_type, index_options, name, etc...)
     *
     * @return The secondary index instance for this column
     * @throws ConfigurationException
     */
public static SecondaryIndex createInstance(ColumnFamilyStore baseCfs, ColumnDefinition cdef) throws ConfigurationException {
    SecondaryIndex index;
    switch(cdef.getIndexType()) {
        case KEYS:
            index = new KeysIndex();
            break;
        case CUSTOM:
            assert cdef.getIndexOptions() != null;
            String class_name = cdef.getIndexOptions().get(CUSTOM_INDEX_OPTION_NAME);
            assert class_name != null;
            try {
                index = (SecondaryIndex) Class.forName(class_name).newInstance();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            break;
        default:
            throw new RuntimeException("Unknown index type: " + cdef.getIndexName());
    }
    index.addColumnDef(cdef);
    index.validateOptions();
    index.setBaseCfs(baseCfs);
    return index;
}
Also used : KeysIndex(org.apache.cassandra.db.index.keys.KeysIndex) IOException(java.io.IOException) ConfigurationException(org.apache.cassandra.config.ConfigurationException)

Aggregations

IOException (java.io.IOException)1 ConfigurationException (org.apache.cassandra.config.ConfigurationException)1 KeysIndex (org.apache.cassandra.db.index.keys.KeysIndex)1