public OIndex<?> createIndex(final String iName, final String iType, final OIndexDefinition iIndexDefinition,
final int[] iClusterIdsToIndex, final OProgressListener progressListener, ODocument metadata, String engine) {
String createIndexDDL;
if (iIndexDefinition != null)
createIndexDDL = iIndexDefinition.toCreateIndexDDL(iName, iType, engine);
else
createIndexDDL = new OSimpleKeyIndexDefinition().toCreateIndexDDL(iName, iType, engine);
if (metadata != null)
createIndexDDL += " " + OCommandExecutorSQLCreateIndex.KEYWORD_METADATA + " " + metadata.toJSON();
acquireExclusiveLock();
try {
if (progressListener != null)
progressListener.onBegin(this, 0, false);
getDatabase().command(createIndexDDL).close();
ORecordInternal.setIdentity(document, new ORecordId(getDatabase().getStorage().getConfiguration().getIndexMgrRecordId()));
if (progressListener != null)
progressListener.onCompletition(this, true);
reload();
return preProcessBeforeReturn(getDatabase(), indexes.get(iName));
} catch (OCommandExecutionException x) {
throw new OIndexException(x.getMessage());
} finally {
releaseExclusiveLock();
}
}