private void createIndexUsingCql(TableInfo tableInfo) throws Exception
    {

        List<String> embeddedIndexes = new ArrayList<String>();
        for (EmbeddedColumnInfo embeddedColumnInfo : tableInfo.getEmbeddedColumnMetadatas())
        {
            for (ColumnInfo columnInfo : embeddedColumnInfo.getColumns())
            {
                if (columnInfo.isIndexable())
                {
                    embeddedIndexes.add(columnInfo.getColumnName());
                }
            }
        }

        StringBuilder indexQueryBuilder = new StringBuilder("create index if not exists on \"");
        indexQueryBuilder.append(tableInfo.getTableName());
        indexQueryBuilder.append("\"(\"$COLUMN_NAME\")");
        tableInfo.getColumnsToBeIndexed();
        for (IndexInfo indexInfo : tableInfo.getColumnsToBeIndexed())
        {
            ColumnInfo columnInfo = new ColumnInfo();
            columnInfo.setColumnName(indexInfo.getColumnName());

            // indexes on embeddables not supported in cql3
            if (!embeddedIndexes.contains(indexInfo.getColumnName()))
            {
                String replacedWithindexName = StringUtils.replace(indexQueryBuilder.toString(), "$COLUMN_NAME",
                        indexInfo.getColumnName());

                try
                {
                    KunderaCoreUtils.printQuery(replacedWithindexName, showQuery);
                    cassandra_client.execute_cql3_query(ByteBuffer.wrap(replacedWithindexName.getBytes()),
                            Compression.NONE, ConsistencyLevel.ONE);
                }
                catch (InvalidRequestException ire)
                {
                    if (ire.getWhy() != null && !ire.getWhy().equals("Index already exists")
                            && operation.equalsIgnoreCase(SchemaOperationType.update.name()))
                    {
                        log.error("Error occurred while creating indexes on column{} of table {}, , Caused by: .",
                                indexInfo.getColumnName(), tableInfo.getTableName(), ire);
                        throw new SchemaGenerationException("Error occurred while creating indexes on column "
                                + indexInfo.getColumnName() + " of table " + tableInfo.getTableName(), ire,
                                "Cassandra", databaseName);
                    }
                }
            }

        }
    }
private void createIndexUsingCql ( TableInfo tableInfo ) throws Exception { List < String > embeddedIndexes = new ArrayList < String > ( ) ; for ( EmbeddedColumnInfo embeddedColumnInfo : tableInfo . getEmbeddedColumnMetadatas ( ) ) { for ( ColumnInfo columnInfo : embeddedColumnInfo . getColumns ( ) ) { if ( columnInfo . isIndexable ( ) ) { embeddedIndexes . add ( columnInfo . getColumnName ( ) ) ; } } } StringBuilder indexQueryBuilder = new StringBuilder ( "create index if not exists on \"" ) ; indexQueryBuilder . append ( tableInfo . getTableName ( ) ) ; indexQueryBuilder . append ( "\"(\"$COLUMN_NAME\")" ) ; tableInfo . getColumnsToBeIndexed ( ) ; for ( IndexInfo indexInfo : tableInfo . getColumnsToBeIndexed ( ) ) { ColumnInfo columnInfo = new ColumnInfo ( ) ; columnInfo . setColumnName ( indexInfo . getColumnName ( ) ) ; if ( ! embeddedIndexes . contains ( indexInfo . getColumnName ( ) ) ) { String replacedWithindexName = StringUtils . replace ( indexQueryBuilder . toString ( ) , "$COLUMN_NAME" , indexInfo . getColumnName ( ) ) ; try { KunderaCoreUtils . printQuery ( replacedWithindexName , showQuery ) ; cassandra_client . execute_cql3_query ( ByteBuffer . wrap ( replacedWithindexName . getBytes ( ) ) , Compression . NONE , ConsistencyLevel . ONE ) ; } catch ( InvalidRequestException ire ) { if ( ire . getWhy ( ) != null && ! ire . getWhy ( ) . equals ( "Index already exists" ) && operation . equalsIgnoreCase ( SchemaOperationType . update . name ( ) ) ) { log . error ( "Error occurred while creating indexes on column{} of table {}, , Caused by: ." , indexInfo . getColumnName ( ) , tableInfo . getTableName ( ) , ire ) ; throw new SchemaGenerationException ( "Error occurred while creating indexes on column " + indexInfo . getColumnName ( ) + " of table " + tableInfo . getTableName ( ) , ire , "Cassandra" , databaseName ) ; } } } } }
Create secondary indexes on columns.

@param tableInfo
the table info
@throws Exception
the exception