Creates the index on table.

@param tableInfo
the table info
542981
private void createIndexOnTable(TableInfo tableInfo)
    {

        List<IndexInfo> indexColumns = tableInfo.getColumnsToBeIndexed();
        for (IndexInfo indexInfo : indexColumns)
        {
            if (indexInfo.getIndexType() != null && indexInfo.getIndexType().toLowerCase().equals(Constants.COMPOSITE))
            {
                String[] columnNames = indexInfo.getColumnName().split(Constants.COMMA);
                createIndex(tableInfo.getTableName(), indexInfo.getIndexName(), columnNames);
            }
            else
            {
                createIndex(tableInfo.getTableName(), indexInfo.getIndexName(), indexInfo.getColumnName());
            }
        }
    }
158206
public void setInfo(SortedMap<String, Object> addInfo) {

        m_addInfoEditable = new TreeMap<String, Object>(addInfo);
    }
675624
@Override
    protected void create(List<TableInfo> tableInfos)
    {
        try
        {
            HttpResponse response = null;
            createDatabaseIfNotExist(true);
            for (TableInfo tableInfo : tableInfos)
            {
                CouchDBDesignDocument designDocument = new CouchDBDesignDocument();
                Map<String, MapReduce> views = new HashMap<String, CouchDBDesignDocument.MapReduce>();
                designDocument.setLanguage(CouchDBConstants.LANGUAGE);
                String id = CouchDBConstants.DESIGN + tableInfo.getTableName();
                for (IndexInfo indexInfo : tableInfo.getColumnsToBeIndexed())
                {
                    createView(views, indexInfo.getColumnName());
                }

                // for id column.
                createView(views, tableInfo.getIdColumnName());

                // for select all.
                createViewForSelectAll(tableInfo, views);

                // for selecting specific field
                createViewForSelectSpecificFields(views);

                designDocument.setViews(views);
                URI uri = new URI(CouchDBConstants.PROTOCOL, null, httpHost.getHostName(), httpHost.getPort(),
                        CouchDBConstants.URL_SEPARATOR + databaseName.toLowerCase() + CouchDBConstants.URL_SEPARATOR
                                + id, null, null);
                HttpPut put = new HttpPut(uri);

                String jsonObject = gson.toJson(designDocument);
                StringEntity entity = new StringEntity(jsonObject);
                put.setEntity(entity);
                try
                {
                    response = httpClient.execute(httpHost, put, CouchDBUtils.getContext(httpHost));
                }
                finally
                {
                    CouchDBUtils.closeContent(response);
                }
            }
            // creating views for various aggregations in the following
            // order:
            // -- COUNT SUM MAX MIN AVG
            // IMPORTANT: The aggregations does not support WHERE clause
            createDesignDocForAggregations();

        }
        catch (Exception e)
        {
            logger.error("Error while creating database {} , caused by {}.", databaseName, e);
            throw new SchemaGenerationException("Error while creating database", e, "couchDB");
        }
    }
12995
protected void createTable(){
        sqlManager.executeUpdate(
                new StringSqlResource(String.format("CREATE TABLE %s (VERSION NUMERIC NOT NULL)", tableName)));

        sqlManager.executeUpdate(
                new StringSqlResource(String.format("INSERT INTO %s (0))", tableName)));
    }
335127
@Override
    protected void create(List<TableInfo> tableInfos)
    {
        StatementResult result = null;
        String statement = null;

        for (TableInfo tableInfo : tableInfos)
        {
            try
            {
                result = tableAPI.executeSync("DROP TABLE IF EXISTS " + tableInfo.getTableName());
                if (!result.isSuccessful())
                {
                    throw new SchemaGenerationException("Unable to DROP TABLE " + tableInfo.getTableName());
                }
                statement = buildCreateDDLQuery(tableInfo);
                result = tableAPI.executeSync(statement);
                if (!result.isSuccessful())
                {
                    throw new SchemaGenerationException("Unable to CREATE TABLE " + tableInfo.getTableName());
                }
                createIndexOnTable(tableInfo);
            }
            catch (IllegalArgumentException e)
            {
                logger.error("Invalid Statement. Caused By: ", e);
                throw new SchemaGenerationException(e, "Invalid Statement. Caused By: ");
            }
            catch (FaultException e)
            {
                logger.error("Statement couldn't be executed. Caused By: ", e);
                throw new SchemaGenerationException(e, "Statement couldn't be executed. Caused By: ");
            }
        }
    }
496949
private void onInheritedProperty(TableInfo tableInfo, EntityType entityType)
    {
        String discrColumn = ((AbstractManagedType) entityType).getDiscriminatorColumn();

        if (discrColumn != null)
        {
            ColumnInfo columnInfo = new ColumnInfo();
            columnInfo.setColumnName(discrColumn);
            columnInfo.setType(String.class);
            columnInfo.setIndexable(true);

            IndexInfo idxInfo = new IndexInfo(discrColumn);
            tableInfo.addColumnInfo(columnInfo);
            tableInfo.addToIndexedColumnList(idxInfo);
        }
    }
669041
public void setIndexInfo(String info) {
		//ns=phobos_sindex:set=longevity:indexname=str_100_idx:num_bins=1:bins=str_100_bin:type=TEXT:sync_state=synced:state=RW;
		//ns=test:set=Customers:indexname=mail_index_userss:bin=email:type=STRING:indextype=LIST:path=email:sync_state=synced:state=RW
		if (!info.isEmpty()) {
			String[] parts = info.split(":");
			for (String part : parts) {
				kvPut(part);
			}
		}
	}
449865
public void setColumnInfo(java.util.Collection<ColumnInfo> columnInfo) {
        if (columnInfo == null) {
            this.columnInfo = null;
            return;
        }

        this.columnInfo = new java.util.ArrayList<ColumnInfo>(columnInfo);
    }
337913
protected void create(List<TableInfo> tableInfos)
    {
        for (TableInfo tableInfo : tableInfos)
        {
            DBObject options = setCollectionProperties(tableInfo);
            DB db = mongo.getDB(databaseName);

            if (tableInfo.getLobColumnInfo().isEmpty())
            {
                if (db.collectionExists(tableInfo.getTableName()))
                {
                    db.getCollection(tableInfo.getTableName()).drop();

                    KunderaCoreUtils.printQuery("Drop existing collection: " + tableInfo.getTableName(), showQuery);
                }
                DBCollection collection = db.createCollection(tableInfo.getTableName(), options);
                KunderaCoreUtils.printQuery("Create collection: " + tableInfo.getTableName(), showQuery);

                boolean isCappedCollection = isCappedCollection(tableInfo);
                if (!isCappedCollection)
                {
                    createIndexes(tableInfo, collection);
                }
            }
            else
            {
                /*
                 * In GridFS we have 2 collections. TABLE_NAME.chunks for
                 * storing chunks of data and TABLE_NAME.MongoDBUtils.FILES for
                 * storing it's metadata.
                 */
                checkMultipleLobs(tableInfo);
                if (db.collectionExists(tableInfo.getTableName() + MongoDBUtils.FILES))
                {
                    db.getCollection(tableInfo.getTableName() + MongoDBUtils.FILES).drop();
                    KunderaCoreUtils.printQuery(
                            "Drop existing Grid FS Metadata collection: " + tableInfo.getTableName()
                                    + MongoDBUtils.FILES, showQuery);
                }

                if (db.collectionExists(tableInfo.getTableName() + MongoDBUtils.CHUNKS))
                {
                    db.getCollection(tableInfo.getTableName() + MongoDBUtils.CHUNKS).drop();
                    KunderaCoreUtils.printQuery("Drop existing Grid FS data collection: " + tableInfo.getTableName()
                            + MongoDBUtils.CHUNKS, showQuery);
                }
                coll = db.createCollection(tableInfo.getTableName() + MongoDBUtils.FILES, options);
                createUniqueIndexGFS(coll, tableInfo.getIdColumnName());
                KunderaCoreUtils.printQuery("Create collection: " + tableInfo.getTableName() + MongoDBUtils.FILES,
                        showQuery);
                db.createCollection(tableInfo.getTableName() + MongoDBUtils.CHUNKS, options);
                KunderaCoreUtils.printQuery("Create collection: " + tableInfo.getTableName() + MongoDBUtils.CHUNKS,
                        showQuery);

            }
        }
    }
910918
private IndexMetadata buildModernIndex(
      CqlIdentifier keyspaceId, CqlIdentifier tableId, AdminRow row) {
    CqlIdentifier name = CqlIdentifier.fromInternal(row.getString("index_name"));
    IndexKind kind = IndexKind.valueOf(row.getString("kind"));
    Map<String, String> options = row.getMapOfStringToString("options");
    String target = options.get("target");
    return new DefaultIndexMetadata(keyspaceId, tableId, name, kind, target, options);
  }
376034
private TableIndex getOrCreateTableIndex() {
		TableIndex tableIndex = getTableIndex();

		if (tableIndex == null) {
			try {
				if (!tableIndexDao.isTableExists()) {
					geoPackage.createTableIndexTable();
				}

				tableIndex = new TableIndex();
				tableIndex.setTableName(tableName);
				tableIndex.setLastIndexed(null);

				tableIndexDao.create(tableIndex);
			} catch (SQLException e) {
				throw new GeoPackageException(
						"Failed to create Table Index for GeoPackage: "
								+ geoPackage.getName() + ", Table Name: "
								+ tableName + ", Column Name: " + columnName, e);
			}
		}

		return tableIndex;
	}
235921
private int getTableIndex(String tableName) {

        int index;

        // System.out.println("begin searching for "+tableName);
        for (index = 0; index < vHoldTableNames.size(); index++) {

            // System.out.println("in getTableIndex searching for "+tableName+", index: "+index);
            if (tableName.equals((String) vHoldTableNames.elementAt(index))) {
                return index;
            }    // end of if (tableName.equals(vHoldTableNames.elementAt(index)))
        }        // end of for (index = 0; index < vHoldTableNames.size(); index ++)

        return -1;
    }
1254867
@Override
    protected void update(List<TableInfo> tableInfos)
    {
        StatementResult result = null;
        String statement = null;
        for (TableInfo tableInfo : tableInfos)
        {
            try
            {
                Table table = tableAPI.getTable(tableInfo.getTableName());
                if (table == null)
                {
                    statement = buildCreateDDLQuery(tableInfo);
                    result = tableAPI.executeSync(statement);
                    if (!result.isSuccessful())
                    {
                        throw new SchemaGenerationException("Unable to CREATE TABLE " + tableInfo.getTableName());
                    }
                }
                else
                {
                    List<ColumnInfo> columnInfos = tableInfo.getColumnMetadatas();
                    Map<String, String> newColumns = new HashMap<String, String>();
                    for (ColumnInfo column : columnInfos)
                    {
                        if (table.getField(column.getColumnName()) == null)
                        {
                            newColumns.put(column.getColumnName(), column.getType().getSimpleName());
                        }
                    }

                    List<EmbeddedColumnInfo> embeddedColumnInfos = tableInfo.getEmbeddedColumnMetadatas();
                    for (EmbeddedColumnInfo embeddedColumnInfo : embeddedColumnInfos)
                    {
                        for (ColumnInfo column : embeddedColumnInfo.getColumns())
                        {
                            if (table.getField(column.getColumnName()) == null)
                            {
                                newColumns.put(column.getColumnName(), column.getType().getSimpleName());
                            }
                        }
                    }
                    if (!newColumns.isEmpty())
                    {
                        statement = buildAlterDDLQuery(tableInfo, newColumns);
                        result = tableAPI.executeSync(statement);

                        if (!result.isSuccessful())
                        {
                            throw new SchemaGenerationException("Unable to ALTER TABLE " + tableInfo.getTableName());
                        }
                    }
                }
                createIndexOnTable(tableInfo);
            }
            catch (IllegalArgumentException e)
            {
                logger.error("Invalid Statement. Caused By: ", e);
                throw new SchemaGenerationException(e, "Invalid Statement. Caused By: ");
            }
            catch (FaultException e)
            {
                logger.error("Statement couldn't be executed. Caused By: ", e);
                throw new SchemaGenerationException(e, "Statement couldn't be executed. Caused By: ");
            }
        }
    }
37154
public void createTables(Connection connection, TableCreationMode mode, boolean createIndexes) {
        ArrayList<Type<?>> sorted = sortTypes();
        try (Statement statement = connection.createStatement()) {
            if (mode == TableCreationMode.DROP_CREATE) {
                ArrayList<Type<?>> reversed = sortTypes();
                Collections.reverse(reversed);
                executeDropStatements(statement, reversed);
            }
            for (Type<?> type : sorted) {
                String sql = tableCreateStatement(type, mode);
                statementListeners.beforeExecuteUpdate(statement, sql, null);
                statement.execute(sql);
                statementListeners.afterExecuteUpdate(statement, 0);
            }
            if (createIndexes) {
                for (Type<?> type : sorted) {
                    createIndexes(connection, mode, type);
                }
            }
        } catch (SQLException e) {
            throw new TableModificationException(e);
        }
    }
295191
@Override
    protected void create(List<TableInfo> tableInfos)
    {
        List dbList = r.dbList().run(connection);
        
        if(!dbList.contains(databaseName)){
            r.dbCreate(databaseName).run(connection);
        }
        
        List listTables = r.db(databaseName).tableList().run(connection);

        for (TableInfo tableInfo : tableInfos)
        {
            try
            {
                if (listTables.contains(tableInfo.getTableName()))
                {
                    r.db(databaseName).tableDrop(tableInfo.getTableName()).run(connection);
                }
            }
            catch (Exception e)
            {
                logger.error("Cannot check table existence for table " + tableInfo.getTableName() + ". Caused By: " + e);
                throw new KunderaException("Cannot check table existence for table " + tableInfo.getTableName()
                        + ". Caused By: " + e);
            }
            r.db(databaseName).tableCreate(tableInfo.getTableName()).run(connection);
        }

    }
408617
protected void update(List<TableInfo> tableInfos)
    {
        for (TableInfo tableInfo : tableInfos)
        {
            DBObject options = setCollectionProperties(tableInfo);
            DB db = mongo.getDB(databaseName);
            DBCollection collection = null;
            if (tableInfo.getLobColumnInfo().isEmpty())
            {
                if (!db.collectionExists(tableInfo.getTableName()))
                {
                    collection = db.createCollection(tableInfo.getTableName(), options);
                    KunderaCoreUtils.printQuery("Create collection: " + tableInfo.getTableName(), showQuery);
                }

                collection = collection != null ? collection : db.getCollection(tableInfo.getTableName());

                boolean isCappedCollection = isCappedCollection(tableInfo);
                if (!isCappedCollection)
                {
                    createIndexes(tableInfo, collection);
                }
            }
            else
            {
                checkMultipleLobs(tableInfo);
                if (!db.collectionExists(tableInfo.getTableName() + MongoDBUtils.FILES))
                {
                    coll = db.createCollection(tableInfo.getTableName() + MongoDBUtils.FILES, options);
                    createUniqueIndexGFS(coll, tableInfo.getIdColumnName());
                    KunderaCoreUtils.printQuery("Create collection: " + tableInfo.getTableName() + MongoDBUtils.FILES,
                            showQuery);
                }

                if (!db.collectionExists(tableInfo.getTableName() + MongoDBUtils.CHUNKS))
                {
                    db.createCollection(tableInfo.getTableName() + MongoDBUtils.CHUNKS, options);
                    KunderaCoreUtils.printQuery("Create collection: " + tableInfo.getTableName() + MongoDBUtils.CHUNKS,
                            showQuery);
                }
            }
        }
    }
1249393
public void addIndexes(StorableInfo<S> info) {
        for (int i=info.getIndexCount(); --i>=0; ) {
            add(info.getIndex(i));
        }
    }