core/src/main/java/com/orientechnologies/orient/core/index/OIndexAbstract.java
public OIndexInternal<?> create(final OIndexDefinition indexDefinition, final String clusterIndexName,
      final Set<String> clustersToIndex, boolean rebuild, final OProgressListener progressListener,
      final OBinarySerializer valueSerializer) {
    acquireExclusiveLock();
    try {
      configuration = indexConfigurationInstance(new ODocument().setTrackingChanges(false));

      this.indexDefinition = indexDefinition;

      if (clustersToIndex != null)
        this.clustersToIndex = new HashSet<>(clustersToIndex);
      else
        this.clustersToIndex = new HashSet<>();

      // do not remove this, it is needed to remove index garbage if such one exists
      try {
        if (apiVersion == 0) {
          removeValuesContainer();
        }
      } catch (Exception e) {
        OLogManager.instance().error(this, "Error during deletion of index '%s'", e, name);
      }

      indexId = storage.addIndexEngine(name, algorithm, type, indexDefinition, valueSerializer, isAutomatic(), true, version, 1,
          this instanceof OIndexMultiValues, getEngineProperties(), clustersToIndex, metadata);
      apiVersion = OAbstractPaginatedStorage.extractEngineAPIVersion(indexId);

      assert indexId >= 0;
      assert apiVersion >= 0;

      onIndexEngineChange(indexId);

      if (rebuild)
        fillIndex(progressListener, false);

      updateConfiguration();
    } catch (Exception e) {
      OLogManager.instance().error(this, "Exception during index '%s' creation", e, name);

      while (true)
        try {
          if (indexId >= 0)
            storage.deleteIndexEngine(indexId);
          break;
        } catch (OInvalidIndexEngineIdException ignore) {
          doReloadIndexEngine();
        } catch (Exception ex) {
          OLogManager.instance().error(this, "Exception during index '%s' deletion", ex, name);
        }

      if (e instanceof OIndexException)
        throw (OIndexException) e;

      throw OException.wrapException(new OIndexException("Cannot create the index '" + name + "'"), e);

    } finally {
      releaseExclusiveLock();
    }

    return this;
  }
public OIndexInternal<?> create(final OIndexDefinition indexDefinition, final String clusterIndexName,
      final Set<String> clustersToIndex, boolean rebuild, final OProgressListener progressListener,
      final OBinarySerializer valueSerializer) {
    acquireExclusiveLock();
    try {
      configuration = indexConfigurationInstance(new ODocument().setTrackingChanges(false));

      this.indexDefinition = indexDefinition;

      if (clustersToIndex != null)
        this.clustersToIndex = new HashSet<>(clustersToIndex);
      else
        this.clustersToIndex = new HashSet<>();

      // do not remove this, it is needed to remove index garbage if such one exists
      try {
        if (apiVersion == 0) {
          removeValuesContainer();
        }
      } catch (Exception e) {
        OLogManager.instance().error(this, "Error during deletion of index '%s'", e, name);
      }

      indexId = storage.addIndexEngine(name, algorithm, type, indexDefinition, valueSerializer, isAutomatic(), true, version, 1,
          this instanceof OIndexMultiValues, getEngineProperties(), clustersToIndex, metadata);
      apiVersion = OAbstractPaginatedStorage.extractEngineAPIVersion(indexId);

      assert indexId >= 0;
      assert apiVersion >= 0;

      onIndexEngineChange(indexId);

      if (rebuild)
        fillIndex(progressListener, false);

      updateConfiguration();
    } catch (Exception e) {
      OLogManager.instance().error(this, "Exception during index '%s' creation", e, name);

      while (true)
        try {
          if (indexId >= 0)
            storage.deleteIndexEngine(indexId);
          break;
        } catch (OInvalidIndexEngineIdException ignore) {
          doReloadIndexEngine();
        } catch (Exception ex) {
          OLogManager.instance().error(this, "Exception during index '%s' deletion", ex, name);
        }

      if (e instanceof OIndexException)
        throw (OIndexException) e;

      throw OException.wrapException(new OIndexException("Cannot create the index '" + name + "'"), e);

    } finally {
      releaseExclusiveLock();
    }

    return this;
  }
public OIndexInternal < ? > create ( final OIndexDefinition indexDefinition , final String clusterIndexName , final Set < String > clustersToIndex , boolean rebuild , final OProgressListener progressListener , final OBinarySerializer valueSerializer ) { acquireExclusiveLock ( ) ; try { configuration = indexConfigurationInstance ( new ODocument ( ) . setTrackingChanges ( false ) ) ; this . indexDefinition = indexDefinition ; if ( clustersToIndex != null ) this . clustersToIndex = new HashSet <> ( clustersToIndex ) ; else this . clustersToIndex = new HashSet <> ( ) ; // do not remove this, it is needed to remove index garbage if such one exists try { if ( apiVersion == 0 ) { removeValuesContainer ( ) ; } } catch ( Exception e ) { OLogManager . instance ( ) . error ( this , "Error during deletion of index '%s'" , e , name ) ; } indexId = storage . addIndexEngine ( name , algorithm , type , indexDefinition , valueSerializer , isAutomatic ( ) , true , version , 1 , this instanceof OIndexMultiValues , getEngineProperties ( ) , clustersToIndex , metadata ) ; apiVersion = OAbstractPaginatedStorage . extractEngineAPIVersion ( indexId ) ; assert indexId >= 0 ; assert apiVersion >= 0 ; onIndexEngineChange ( indexId ) ; if ( rebuild ) fillIndex ( progressListener , false ) ; updateConfiguration ( ) ; } catch ( Exception e ) { OLogManager . instance ( ) . error ( this , "Exception during index '%s' creation" , e , name ) ; while ( true ) try { if ( indexId >= 0 ) storage . deleteIndexEngine ( indexId ) ; break ; } catch ( OInvalidIndexEngineIdException ignore ) { doReloadIndexEngine ( ) ; } catch ( Exception ex ) { OLogManager . instance ( ) . error ( this , "Exception during index '%s' deletion" , ex , name ) ; } if ( e instanceof OIndexException ) throw ( OIndexException ) e ; throw OException . wrapException ( new OIndexException ( "Cannot create the index '" + name + "'" ) , e ) ; } finally { releaseExclusiveLock ( ) ; } return this ; }
Creates the index.

@param clusterIndexName Cluster name where to place the TreeMap
Creates the index .