public static SecondaryIndex createInstance ( ColumnFamilyStore baseCfs , ColumnDefinition cdef ) throws ConfigurationException { SecondaryIndex index ; switch ( cdef . getIndexType ( ) ) { case KEYS : index = new KeysIndex ( ) ; break ; case COMPOSITES : index = CompositesIndex . create ( cdef ) ; 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 ; }
This is the primary way to create a secondary index instance for a CF column . It will validate the index_options before initializing .