From c44bbca080721b05af1db86562a16b199916fd3c Mon Sep 17 00:00:00 2001 From: laa Date: Thu, 21 May 2015 15:48:25 +0300 Subject: [PATCH] Issue #4089 is fixed. --- .../core/index/OAbstractIndexDefinition.java | 22 +-- .../OAbstractIndexDefinitionMultiValue.java | 4 +- .../core/index/OCompositeIndexDefinition.java | 4 +- .../core/index/ODefaultIndexFactory.java | 18 +-- .../orient/core/index/OIndexAbstract.java | 67 ++++----- .../orient/core/index/OIndexDefinition.java | 2 - .../core/index/OIndexDefinitionFactory.java | 8 +- .../orient/core/index/OIndexFactory.java | 12 +- .../orient/core/index/OIndexInternal.java | 33 ++-- .../core/index/OIndexManagerShared.java | 72 ++++----- .../orient/core/index/OIndexes.java | 4 +- .../core/index/OPropertyIndexDefinition.java | 4 +- .../index/OPropertyListIndexDefinition.java | 4 +- .../index/OPropertyMapIndexDefinition.java | 5 +- .../index/OPropertyRidBagIndexDefinition.java | 4 +- .../index/ORuntimeKeyIndexDefinition.java | 2 +- .../core/index/OSimpleKeyIndexDefinition.java | 4 +- .../hashindex/local/OHashIndexFactory.java | 13 +- .../index/OCompositeIndexDefinitionTest.java | 142 +++++++++--------- .../index/OPropertyIndexDefinitionTest.java | 4 +- .../OPropertyListIndexDefinitionTest.java | 2 +- .../OPropertyMapIndexDefinitionTest.java | 12 +- ...ertyRidBagAbstractIndexDefinitionTest.java | 2 +- .../impls/orient/OrientBaseGraph.java | 2 +- .../test/database/auto/ClassIndexTest.java | 118 +++++++-------- .../test/database/auto/IndexManagerTest.java | 40 +++-- .../orient/test/database/auto/IndexTest.java | 70 ++++----- 27 files changed, 322 insertions(+), 352 deletions(-) diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OAbstractIndexDefinition.java b/core/src/main/java/com/orientechnologies/orient/core/index/OAbstractIndexDefinition.java index 0f7939df779..c8ef28226b3 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OAbstractIndexDefinition.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OAbstractIndexDefinition.java @@ -27,25 +27,17 @@ /** * Abstract index definiton implementation. - * + * * @author Luca Garulli (l.garulli--at--orientechnologies.com) - * */ public abstract class OAbstractIndexDefinition extends ODocumentWrapperNoClass implements OIndexDefinition { - protected OCollate collate = new ODefaultCollate(); - private boolean nullValuesIgnored = true; - private int version = -1; + protected OCollate collate = new ODefaultCollate(); + private boolean nullValuesIgnored = true; protected OAbstractIndexDefinition() { super(new ODocument()); } - public OAbstractIndexDefinition(int version) { - super(new ODocument()); - - this.version = version; - } - public OCollate getCollate() { return collate; } @@ -98,18 +90,10 @@ public void setNullValuesIgnored(boolean value) { nullValuesIgnored = value; } - @Override - public int getVersion() { - return version; - } protected void serializeToStream() { - document.field("version", version); } protected void serializeFromStream() { - final Integer ver = document.field("version"); - if (ver != null) - version = ver; } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OAbstractIndexDefinitionMultiValue.java b/core/src/main/java/com/orientechnologies/orient/core/index/OAbstractIndexDefinitionMultiValue.java index 451a3307b84..040a0c26d09 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OAbstractIndexDefinitionMultiValue.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OAbstractIndexDefinitionMultiValue.java @@ -30,8 +30,8 @@ public abstract class OAbstractIndexDefinitionMultiValue extends OPropertyIndexD protected OAbstractIndexDefinitionMultiValue() { } - protected OAbstractIndexDefinitionMultiValue(final String iClassName, final String iField, final OType iType, int version) { - super(iClassName, iField, iType, version); + protected OAbstractIndexDefinitionMultiValue(final String iClassName, final String iField, final OType iType) { + super(iClassName, iField, iType); } protected void processAdd(final Object value, final Map keysToAdd, final Map keysToRemove) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OCompositeIndexDefinition.java b/core/src/main/java/com/orientechnologies/orient/core/index/OCompositeIndexDefinition.java index a6ea2391344..3b3783c2f51 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OCompositeIndexDefinition.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OCompositeIndexDefinition.java @@ -57,7 +57,7 @@ public OCompositeIndexDefinition() { * - name of class which is owner of this index */ public OCompositeIndexDefinition(final String iClassName, int version) { - super(version); + super(); indexDefinitions = new ArrayList(5); className = iClassName; @@ -72,7 +72,7 @@ public OCompositeIndexDefinition(final String iClassName, int version) { * List of indexDefinitions to add in given index. */ public OCompositeIndexDefinition(final String iClassName, final List iIndexes, int version) { - super(version); + super(); indexDefinitions = new ArrayList(5); for (OIndexDefinition indexDefinition : iIndexes) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/ODefaultIndexFactory.java b/core/src/main/java/com/orientechnologies/orient/core/index/ODefaultIndexFactory.java index 6d86ee65f83..21b39351119 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/ODefaultIndexFactory.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/ODefaultIndexFactory.java @@ -19,7 +19,6 @@ import java.util.HashSet; import java.util.Set; -import com.orientechnologies.common.log.OLogManager; import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; import com.orientechnologies.orient.core.db.record.OIdentifiable; import com.orientechnologies.orient.core.exception.OConfigurationException; @@ -27,7 +26,6 @@ import com.orientechnologies.orient.core.metadata.schema.OClass; import com.orientechnologies.orient.core.record.impl.ODocument; import com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage; -import com.orientechnologies.orient.core.storage.impl.local.paginated.base.ODurablePage; /** * Default OrientDB index factory for indexes based on MVRBTree.
@@ -94,19 +92,21 @@ public Set getAlgorithms() { } public OIndexInternal createIndex(ODatabaseDocumentInternal database, String indexType, String algorithm, - String valueContainerAlgorithm, ODocument metadata) throws OConfigurationException { + String valueContainerAlgorithm, ODocument metadata, int version) throws OConfigurationException { if (valueContainerAlgorithm == null) valueContainerAlgorithm = NONE_VALUE_CONTAINER; + if (version < 0) + version = getLastVersion(); if (SBTREE_ALGORITHM.equals(algorithm)) return createSBTreeIndex(indexType, valueContainerAlgorithm, metadata, (OAbstractPaginatedStorage) database.getStorage() - .getUnderlying()); + .getUnderlying(), version); throw new OConfigurationException("Unsupported type : " + indexType); } private OIndexInternal createSBTreeIndex(String indexType, String valueContainerAlgorithm, ODocument metadata, - OAbstractPaginatedStorage storage) { + OAbstractPaginatedStorage storage, int version) { Boolean durableInNonTxMode; Object durable = null; @@ -122,16 +122,16 @@ private OIndexInternal createSBTreeIndex(String indexType, String valueContai if (OClass.INDEX_TYPE.UNIQUE.toString().equals(indexType)) { return new OIndexUnique(indexType, SBTREE_ALGORITHM, new OSBTreeIndexEngine(durableInNonTxMode, storage, - getLastVersion()), valueContainerAlgorithm, metadata); + version), valueContainerAlgorithm, metadata); } else if (OClass.INDEX_TYPE.NOTUNIQUE.toString().equals(indexType)) { return new OIndexNotUnique(indexType, SBTREE_ALGORITHM, new OSBTreeIndexEngine>(durableInNonTxMode, - storage, getLastVersion()), valueContainerAlgorithm, metadata); + storage, version), valueContainerAlgorithm, metadata); } else if (OClass.INDEX_TYPE.FULLTEXT.toString().equals(indexType)) { return new OIndexFullText(indexType, SBTREE_ALGORITHM, new OSBTreeIndexEngine>(durableInNonTxMode, - storage, getLastVersion()), valueContainerAlgorithm, metadata); + storage, version), valueContainerAlgorithm, metadata); } else if (OClass.INDEX_TYPE.DICTIONARY.toString().equals(indexType)) { return new OIndexDictionary(indexType, SBTREE_ALGORITHM, new OSBTreeIndexEngine(durableInNonTxMode, storage, - getLastVersion()), valueContainerAlgorithm, metadata); + version), valueContainerAlgorithm, metadata); } throw new OConfigurationException("Unsupported type : " + indexType); diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexAbstract.java b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexAbstract.java index e725c57d6e7..319e613cfdd 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexAbstract.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexAbstract.java @@ -27,12 +27,9 @@ import com.orientechnologies.common.concur.lock.OModificationLock; import com.orientechnologies.common.concur.lock.ONewLockManager; -import com.orientechnologies.common.concur.resource.OSharedResourceAdaptiveExternal; import com.orientechnologies.common.listener.OProgressListener; import com.orientechnologies.common.log.OLogManager; -import com.orientechnologies.common.serialization.types.OLongSerializer; import com.orientechnologies.orient.core.annotation.ODocumentInstance; -import com.orientechnologies.orient.core.config.OGlobalConfiguration; import com.orientechnologies.orient.core.db.ODatabase; import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal; @@ -61,34 +58,33 @@ /** * Handles indexing when records change. - * + * * @author Luca Garulli - * */ public abstract class OIndexAbstract implements OIndexInternal { - protected static final String CONFIG_MAP_RID = "mapRid"; - protected static final String CONFIG_CLUSTERS = "clusters"; - protected final OModificationLock modificationLock = new OModificationLock(); - protected final OIndexEngine indexEngine; - private final String databaseName; - protected String type; - protected String valueContainerAlgorithm; - protected final ONewLockManager keyLockManager = new ONewLockManager(); + protected static final String CONFIG_MAP_RID = "mapRid"; + protected static final String CONFIG_CLUSTERS = "clusters"; + protected final OModificationLock modificationLock = new OModificationLock(); + protected final OIndexEngine indexEngine; + private final String databaseName; + protected String type; + protected String valueContainerAlgorithm; + protected final ONewLockManager keyLockManager = new ONewLockManager(); @ODocumentInstance - protected ODocument configuration; - protected ODocument metadata; - private String name; - private String algorithm; - private Set clustersToIndex = new HashSet(); + protected ODocument configuration; + protected ODocument metadata; + private String name; + private String algorithm; + private Set clustersToIndex = new HashSet(); - private volatile OIndexDefinition indexDefinition; - private volatile boolean rebuilding = false; + private volatile OIndexDefinition indexDefinition; + private volatile boolean rebuilding = false; - private Thread rebuildThread = null; + private Thread rebuildThread = null; - private final ThreadLocal txSnapshot = new IndexTxSnapshotThreadLocal(); - private final ReadWriteLock rwLock = new ReentrantReadWriteLock(); + private final ThreadLocal txSnapshot = new IndexTxSnapshotThreadLocal(); + private final ReadWriteLock rwLock = new ReentrantReadWriteLock(); protected static final class RemovedValue { public static final RemovedValue INSTANCE = new RemovedValue(); @@ -96,11 +92,11 @@ protected static final class RemovedValue { protected static final class IndexTxSnapshot { public Map indexSnapshot = new HashMap(); - public boolean clear = false; + public boolean clear = false; } public OIndexAbstract(final String type, String algorithm, final OIndexEngine indexEngine, String valueContainerAlgorithm, - ODocument metadata) { + ODocument metadata) { acquireExclusiveLock(); try { databaseName = ODatabaseRecordThreadLocal.INSTANCE.get().getName(); @@ -117,7 +113,7 @@ public OIndexAbstract(final String type, String algorithm, final OIndexEngine } public static IndexMetadata loadMetadataInternal(final ODocument config, final String type, final String algorithm, - final String valueContainerAlgorithm) { + final String valueContainerAlgorithm) { String indexName = config.field(OIndexInternal.CONFIG_NAME); final ODocument indexDefinitionDoc = config.field(OIndexInternal.INDEX_DEFINITION); @@ -157,7 +153,7 @@ public static IndexMetadata loadMetadataInternal(final ODocument config, final S throw new OIndexException("Can not convert from old index model to new one. " + "Index key type is absent."); final OType keyType = OType.valueOf(keyTypeStr.toUpperCase(Locale.ENGLISH)); - loadedIndexDefinition = new OPropertyIndexDefinition(className, propertyName, keyType, factory.getLastVersion()); + loadedIndexDefinition = new OPropertyIndexDefinition(className, propertyName, keyType); config.removeField(OIndexInternal.CONFIG_AUTOMATIC); config.removeField(OIndexInternal.CONFIG_KEYTYPE); @@ -197,16 +193,15 @@ public boolean hasRangeQuerySupport() { /** * Creates the index. - * - * @param clusterIndexName - * Cluster name where to place the TreeMap + * + * @param clusterIndexName Cluster name where to place the TreeMap * @param clustersToIndex * @param rebuild * @param progressListener */ public OIndexInternal create(final String name, final OIndexDefinition indexDefinition, final String clusterIndexName, - final Set clustersToIndex, boolean rebuild, final OProgressListener progressListener, - final OStreamSerializer valueSerializer) { + final Set clustersToIndex, boolean rebuild, final OProgressListener progressListener, + final OStreamSerializer valueSerializer) { acquireExclusiveLock(); try { this.name = name; @@ -636,8 +631,12 @@ public ODocument updateConfiguration() { try { configuration.field(OIndexInternal.CONFIG_TYPE, type); configuration.field(OIndexInternal.CONFIG_NAME, name); + assert indexEngine.getVersion() > 0; + configuration.field(OIndexInternal.INDEX_VERSION, indexEngine.getVersion()); if (indexDefinition != null) { + + final ODocument indexDefDocument = indexDefinition.toStream(); if (!indexDefDocument.hasOwners()) ODocumentInternal.addOwner(indexDefDocument, configuration); @@ -916,7 +915,7 @@ protected void checkForRebuild() { } protected long[] indexCluster(final String clusterName, final OProgressListener iProgressListener, long documentNum, - long documentIndexed, long documentTotal) { + long documentIndexed, long documentTotal) { try { for (final ORecord record : getDatabase().browseCluster(clusterName)) { if (Thread.interrupted()) @@ -953,7 +952,7 @@ protected long[] indexCluster(final String clusterName, final OProgressListener // END OF CLUSTER REACHED, IGNORE IT } - return new long[] { documentNum, documentIndexed }; + return new long[]{documentNum, documentIndexed}; } private OAbstractPaginatedStorage getStorage() { diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexDefinition.java b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexDefinition.java index 0bf16d291b1..2fe25f34501 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexDefinition.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexDefinition.java @@ -133,6 +133,4 @@ public interface OIndexDefinition extends OIndexCallback { boolean isNullValuesIgnored(); void setNullValuesIgnored(boolean value); - - int getVersion(); } diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexDefinitionFactory.java b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexDefinitionFactory.java index 92b92cab5c8..71e8b9a934f 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexDefinitionFactory.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexDefinitionFactory.java @@ -143,7 +143,7 @@ private static OIndexDefinition createSingleFieldIndexDefinition(OClass oClass, } - indexDefinition = new OPropertyMapIndexDefinition(oClass.getName(), fieldName, indexType, indexBy, factory.getLastVersion()); + indexDefinition = new OPropertyMapIndexDefinition(oClass.getName(), fieldName, indexType, indexBy); } else if (type.equals(OType.EMBEDDEDLIST) || type.equals(OType.EMBEDDEDSET) || type.equals(OType.LINKLIST) || type.equals(OType.LINKSET)) { if (type.equals(OType.LINKSET)) @@ -157,11 +157,11 @@ else if (type.equals(OType.LINKLIST)) { + " You should provide linked type for embedded collections that are going to be indexed."); } - indexDefinition = new OPropertyListIndexDefinition(oClass.getName(), fieldName, indexType, factory.getLastVersion()); + indexDefinition = new OPropertyListIndexDefinition(oClass.getName(), fieldName, indexType); } else if (type.equals(OType.LINKBAG)) { - indexDefinition = new OPropertyRidBagIndexDefinition(oClass.getName(), fieldName, factory.getLastVersion()); + indexDefinition = new OPropertyRidBagIndexDefinition(oClass.getName(), fieldName); } else - indexDefinition = new OPropertyIndexDefinition(oClass.getName(), fieldName, type, factory.getLastVersion()); + indexDefinition = new OPropertyIndexDefinition(oClass.getName(), fieldName, type); if (collate == null && propertyToIndex != null) collate = propertyToIndex.getCollate(); diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexFactory.java b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexFactory.java index 3f740ad3c68..713c6045e81 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexFactory.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexFactory.java @@ -40,11 +40,11 @@ public interface OIndexFactory { Set getAlgorithms(); /** - * - * - * - * - * + * + * + * + * + * * @param database * @param indexType * index type @@ -55,6 +55,6 @@ public interface OIndexFactory { * if index creation failed */ OIndexInternal createIndex(ODatabaseDocumentInternal database, String indexType, String algorithm, - String valueContainerAlgorithm, ODocument metadata) throws OConfigurationException; + String valueContainerAlgorithm, ODocument metadata, int version) throws OConfigurationException; } diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexInternal.java b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexInternal.java index 85cc9500643..f8f326410ab 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexInternal.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexInternal.java @@ -44,6 +44,7 @@ public interface OIndexInternal extends OIndex { public static final String CONFIG_NAME = "name"; public static final String INDEX_DEFINITION = "indexDefinition"; public static final String INDEX_DEFINITION_CLASS = "indexDefinitionClass"; + public static final String INDEX_VERSION = "indexVersion"; public static final String METADATA = "metadata"; /** @@ -181,22 +182,22 @@ public interface OIndexInternal extends OIndex { */ void releaseKeysForUpdate(Object... key); - /** - * Release exclusive lock on keys which prevents read/modification of this keys in following methods: - * - *
    - *
  1. {@link #put(Object, com.orientechnologies.orient.core.db.record.OIdentifiable)}
  2. - *
  3. {@link #checkEntry(com.orientechnologies.orient.core.db.record.OIdentifiable, Object)}
  4. - *
  5. {@link #remove(Object, com.orientechnologies.orient.core.db.record.OIdentifiable)}
  6. - *
  7. {@link #remove(Object)}
  8. - *
- * - * This is internal method and can not be used by end users. - * - * @param keys - * Keys to unlock. - */ - void releaseKeysForUpdate(Collection keys); + /** + * Release exclusive lock on keys which prevents read/modification of this keys in following methods: + * + *
    + *
  1. {@link #put(Object, com.orientechnologies.orient.core.db.record.OIdentifiable)}
  2. + *
  3. {@link #checkEntry(com.orientechnologies.orient.core.db.record.OIdentifiable, Object)}
  4. + *
  5. {@link #remove(Object, com.orientechnologies.orient.core.db.record.OIdentifiable)}
  6. + *
  7. {@link #remove(Object)}
  8. + *
+ * + * This is internal method and can not be used by end users. + * + * @param keys + * Keys to unlock. + */ + void releaseKeysForUpdate(Collection keys); public IndexMetadata loadMetadata(ODocument iConfig); diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerShared.java b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerShared.java index abcf7ad800e..9c28f32cf20 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerShared.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexManagerShared.java @@ -51,16 +51,15 @@ /** * Manages indexes at database level. A single instance is shared among multiple databases. Contentions are managed by r/w locks. - * + * * @author Luca Garulli (l.garulli--at--orientechnologies.com) * @author Artem Orobets added composite index managemement - * */ public class OIndexManagerShared extends OIndexManagerAbstract implements OIndexManager { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; protected volatile Thread recreateIndexesThread = null; - private volatile boolean rebuildCompleted = false; + private volatile boolean rebuildCompleted = false; public OIndexManagerShared(final ODatabaseDocument iDatabase) { super(iDatabase); @@ -78,48 +77,35 @@ public OIndex getIndexInternal(final String name) { /** * Create a new index with default algorithm. * - * @param iName - * - name of index - * @param iType - * - index type. Specified by plugged index factories. - * @param indexDefinition - * metadata that describes index structure - * @param clusterIdsToIndex - * ids of clusters that index should track for changes. - * @param progressListener - * listener to track task progress. - * @param metadata - * document with additional properties that can be used by index engine. + * @param iName - name of index + * @param iType - index type. Specified by plugged index factories. + * @param indexDefinition metadata that describes index structure + * @param clusterIdsToIndex ids of clusters that index should track for changes. + * @param progressListener listener to track task progress. + * @param metadata document with additional properties that can be used by index engine. * @return a newly created index instance */ public OIndex createIndex(final String iName, final String iType, final OIndexDefinition indexDefinition, - final int[] clusterIdsToIndex, OProgressListener progressListener, ODocument metadata) { + final int[] clusterIdsToIndex, OProgressListener progressListener, ODocument metadata) { return createIndex(iName, iType, indexDefinition, clusterIdsToIndex, progressListener, metadata, null); } /** * Create a new index. - * + *

* May require quite a long time if big amount of data should be indexed. * - * @param iName - * name of index - * @param iType - * index type. Specified by plugged index factories. - * @param indexDefinition - * metadata that describes index structure - * @param clusterIdsToIndex - * ids of clusters that index should track for changes. - * @param progressListener - * listener to track task progress. - * @param metadata - * document with additional properties that can be used by index engine. - * @param algorithm - * tip to an index factory what algorithm to use + * @param iName name of index + * @param iType index type. Specified by plugged index factories. + * @param indexDefinition metadata that describes index structure + * @param clusterIdsToIndex ids of clusters that index should track for changes. + * @param progressListener listener to track task progress. + * @param metadata document with additional properties that can be used by index engine. + * @param algorithm tip to an index factory what algorithm to use * @return a newly created index instance */ public OIndex createIndex(final String iName, final String iType, final OIndexDefinition indexDefinition, - final int[] clusterIdsToIndex, OProgressListener progressListener, ODocument metadata, String algorithm) { + final int[] clusterIdsToIndex, OProgressListener progressListener, ODocument metadata, String algorithm) { if (getDatabase().getTransaction().isActive()) throw new IllegalStateException("Cannot create a new index inside a transaction"); @@ -151,7 +137,7 @@ public OIndex createIndex(final String iName, final String iType, final OInde metadata.field("trackMode", "FULL"); } - index = OIndexes.createIndex(getDatabase(), iType, algorithm, valueContainerAlgorithm, metadata); + index = OIndexes.createIndex(getDatabase(), iType, algorithm, valueContainerAlgorithm, metadata, -1); // decide which cluster to use ("index" - for automatic and "manindex" for manual) final String clusterName = indexDefinition != null && indexDefinition.getClassName() != null ? defaultClusterName @@ -350,9 +336,11 @@ protected void fromStream() { while (indexConfigurationIterator.hasNext()) { final ODocument d = indexConfigurationIterator.next(); try { + final int indexVersion = d.field(OIndexInternal.INDEX_VERSION) == null ? 1 : (Integer) d.field(OIndexInternal.INDEX_VERSION); + index = OIndexes.createIndex(getDatabase(), (String) d.field(OIndexInternal.CONFIG_TYPE), - (String) d.field(OIndexInternal.ALGORITHM), d. field(OIndexInternal.VALUE_CONTAINER_ALGORITHM), - (ODocument) d.field(OIndexInternal.METADATA)); + (String) d.field(OIndexInternal.ALGORITHM), d.field(OIndexInternal.VALUE_CONTAINER_ALGORITHM), + (ODocument) d.field(OIndexInternal.METADATA), indexVersion); OIndexInternal.IndexMetadata newIndexMetadata = index.loadMetadata(d); final String normalizedName = newIndexMetadata.getName().toLowerCase(); @@ -365,7 +353,7 @@ protected void fromStream() { oldIndexes.remove(normalizedName); } else if (newIndexMetadata.getIndexDefinition() == null && d.field(OIndexAbstract.CONFIG_MAP_RID) - .equals(oldIndex.getConfiguration().field(OIndexAbstract.CONFIG_MAP_RID))) { + .equals(oldIndex.getConfiguration().field(OIndexAbstract.CONFIG_MAP_RID))) { // index is manual and index definition was just detected addIndexInternal(oldIndex.getInternal()); oldIndexes.remove(normalizedName); @@ -436,9 +424,9 @@ public void removeClassPropertyIndex(final OIndex idx) { private class RecreateIndexesTask implements Runnable { private final ODatabaseDocumentTx newDb; - private final ODocument doc; - private int ok; - private int errors; + private final ODocument doc; + private int ok; + private int errors; public RecreateIndexesTask(ODatabaseDocumentTx newDb, ODocument doc) { this.newDb = newDb; @@ -496,7 +484,7 @@ private void recreateIndex(ODocument idx) { } private void createAutomaticIndex(ODocument idx, OIndexInternal index, OIndexInternal.IndexMetadata indexMetadata, - OIndexDefinition indexDefinition) { + OIndexDefinition indexDefinition) { final String indexName = indexMetadata.getName(); final Set clusters = indexMetadata.getClustersToIndex(); final String type = indexMetadata.getType(); @@ -554,7 +542,7 @@ private OIndexInternal createIndex(ODocument idx) { throw new OException("Index type is null, will process other record. Index configuration: " + idx.toString()); } - return OIndexes.createIndex(newDb, indexType, algorithm, valueContainerAlgorithm, metadata); + return OIndexes.createIndex(newDb, indexType, algorithm, valueContainerAlgorithm, metadata, -1); } private Collection getConfiguration() { diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexes.java b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexes.java index fb587076d7f..8e5e5001b01 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OIndexes.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OIndexes.java @@ -146,7 +146,7 @@ public static OIndexFactory getFactory(String indexType, String algorithm) { * if index type does not exist */ public static OIndexInternal createIndex(ODatabaseDocumentInternal database, String indexType, String algorithm, - String valueContainerAlgorithm, ODocument metadata) throws OConfigurationException, OIndexException { + String valueContainerAlgorithm, ODocument metadata, int version) throws OConfigurationException, OIndexException { Iterator ite = getAllFactories(); boolean found = false; while (ite.hasNext()) { @@ -162,7 +162,7 @@ public static OIndexInternal createIndex(ODatabaseDocumentInternal database, while (ite.hasNext()) { final OIndexFactory factory = ite.next(); if (factory.getTypes().contains(indexType) && factory.getAlgorithms().contains(algorithm)) { - return factory.createIndex(database, indexType, algorithm, valueContainerAlgorithm, metadata); + return factory.createIndex(database, indexType, algorithm, valueContainerAlgorithm, metadata, version); } } diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OPropertyIndexDefinition.java b/core/src/main/java/com/orientechnologies/orient/core/index/OPropertyIndexDefinition.java index 12f6d2f7a25..91e0013d75f 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OPropertyIndexDefinition.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OPropertyIndexDefinition.java @@ -37,8 +37,8 @@ public class OPropertyIndexDefinition extends OAbstractIndexDefinition { protected String field; protected OType keyType; - public OPropertyIndexDefinition(final String iClassName, final String iField, final OType iType, int version) { - super(version); + public OPropertyIndexDefinition(final String iClassName, final String iField, final OType iType) { + super(); className = iClassName; field = iField; keyType = iType; diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OPropertyListIndexDefinition.java b/core/src/main/java/com/orientechnologies/orient/core/index/OPropertyListIndexDefinition.java index f9da8adddfb..bbc0281b142 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OPropertyListIndexDefinition.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OPropertyListIndexDefinition.java @@ -37,8 +37,8 @@ */ public class OPropertyListIndexDefinition extends OAbstractIndexDefinitionMultiValue implements OIndexDefinitionMultiValue { - public OPropertyListIndexDefinition(final String iClassName, final String iField, final OType iType, int version) { - super(iClassName, iField, iType, version); + public OPropertyListIndexDefinition(final String iClassName, final String iField, final OType iType) { + super(iClassName, iField, iType); } public OPropertyListIndexDefinition() { diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OPropertyMapIndexDefinition.java b/core/src/main/java/com/orientechnologies/orient/core/index/OPropertyMapIndexDefinition.java index b20fca75b19..620d855122d 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OPropertyMapIndexDefinition.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OPropertyMapIndexDefinition.java @@ -49,9 +49,8 @@ public static enum INDEX_BY { public OPropertyMapIndexDefinition() { } - public OPropertyMapIndexDefinition(final String iClassName, final String iField, final OType iType, final INDEX_BY indexBy, - int version) { - super(iClassName, iField, iType, version); + public OPropertyMapIndexDefinition(final String iClassName, final String iField, final OType iType, final INDEX_BY indexBy) { + super(iClassName, iField, iType); if (indexBy == null) throw new NullPointerException("You have to provide way by which map entries should be mapped"); diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OPropertyRidBagIndexDefinition.java b/core/src/main/java/com/orientechnologies/orient/core/index/OPropertyRidBagIndexDefinition.java index a06791c58d0..f476e773720 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OPropertyRidBagIndexDefinition.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OPropertyRidBagIndexDefinition.java @@ -40,8 +40,8 @@ public class OPropertyRidBagIndexDefinition extends OAbstractIndexDefinitionMult public OPropertyRidBagIndexDefinition() { } - public OPropertyRidBagIndexDefinition(String className, String field, int version) { - super(className, field, OType.LINK, version); + public OPropertyRidBagIndexDefinition(String className, String field) { + super(className, field, OType.LINK); } @Override diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/ORuntimeKeyIndexDefinition.java b/core/src/main/java/com/orientechnologies/orient/core/index/ORuntimeKeyIndexDefinition.java index a18634e4c45..da13101e10a 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/ORuntimeKeyIndexDefinition.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/ORuntimeKeyIndexDefinition.java @@ -43,7 +43,7 @@ public class ORuntimeKeyIndexDefinition extends OAbstractIndexDefinition { @SuppressWarnings("unchecked") public ORuntimeKeyIndexDefinition(final byte iId, int version) { - super(version); + super(); serializer = (OBinarySerializer) OBinarySerializerFactory.getInstance().getObjectSerializer(iId); if (serializer == null) diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/OSimpleKeyIndexDefinition.java b/core/src/main/java/com/orientechnologies/orient/core/index/OSimpleKeyIndexDefinition.java index 489305d7005..b809ca63164 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/OSimpleKeyIndexDefinition.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/OSimpleKeyIndexDefinition.java @@ -36,7 +36,7 @@ public class OSimpleKeyIndexDefinition extends OAbstractIndexDefinition { private OType[] keyTypes; public OSimpleKeyIndexDefinition(int version, final OType... keyTypes) { - super(version); + super(); this.keyTypes = keyTypes; } @@ -45,7 +45,7 @@ public OSimpleKeyIndexDefinition() { } public OSimpleKeyIndexDefinition(OType[] keyTypes2, List collatesList, int version) { - super(version); + super(); this.keyTypes = keyTypes2; if (keyTypes.length > 1) { diff --git a/core/src/main/java/com/orientechnologies/orient/core/index/hashindex/local/OHashIndexFactory.java b/core/src/main/java/com/orientechnologies/orient/core/index/hashindex/local/OHashIndexFactory.java index 4635e6ae157..e679b530cf1 100755 --- a/core/src/main/java/com/orientechnologies/orient/core/index/hashindex/local/OHashIndexFactory.java +++ b/core/src/main/java/com/orientechnologies/orient/core/index/hashindex/local/OHashIndexFactory.java @@ -77,7 +77,11 @@ public Set getAlgorithms() { } public OIndexInternal createIndex(ODatabaseDocumentInternal database, String indexType, String algorithm, - String valueContainerAlgorithm, ODocument metadata) throws OConfigurationException { + String valueContainerAlgorithm, ODocument metadata, int version) throws OConfigurationException { + + if (version < 0) + version = getLastVersion(); + if (valueContainerAlgorithm == null) valueContainerAlgorithm = ODefaultIndexFactory.NONE_VALUE_CONTAINER; @@ -98,12 +102,11 @@ public OIndexInternal createIndex(ODatabaseDocumentInternal database, String final String storageType = storage.getType(); if (storageType.equals("memory") || storageType.equals("plocal")) - indexEngine = new OHashTableIndexEngine(durableInNonTxMode, (OAbstractPaginatedStorage) database.getStorage(), - getLastVersion()); + indexEngine = new OHashTableIndexEngine(durableInNonTxMode, (OAbstractPaginatedStorage) database.getStorage(), version); else if (storageType.equals("distributed")) // DISTRIBUTED CASE: HANDLE IT AS FOR LOCAL - indexEngine = new OHashTableIndexEngine(durableInNonTxMode, (OAbstractPaginatedStorage) database.getStorage().getUnderlying(), - getLastVersion()); + indexEngine = new OHashTableIndexEngine(durableInNonTxMode, + (OAbstractPaginatedStorage) database.getStorage().getUnderlying(), version); else if (storageType.equals("remote")) indexEngine = new ORemoteIndexEngine(); else diff --git a/core/src/test/java/com/orientechnologies/orient/core/index/OCompositeIndexDefinitionTest.java b/core/src/test/java/com/orientechnologies/orient/core/index/OCompositeIndexDefinitionTest.java index c03e7893bd3..fa82f3de733 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/index/OCompositeIndexDefinitionTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/index/OCompositeIndexDefinitionTest.java @@ -34,8 +34,8 @@ public class OCompositeIndexDefinitionTest { public void beforeMethod() { compositeIndex = new OCompositeIndexDefinition("testClass", -1); - compositeIndex.addIndex(new OPropertyIndexDefinition("testClass", "fOne", OType.INTEGER, -1)); - compositeIndex.addIndex(new OPropertyIndexDefinition("testClass", "fTwo", OType.STRING, -1)); + compositeIndex.addIndex(new OPropertyIndexDefinition("testClass", "fOne", OType.INTEGER)); + compositeIndex.addIndex(new OPropertyIndexDefinition("testClass", "fTwo", OType.STRING)); } @Test @@ -58,9 +58,9 @@ public void testCreateValueSuccessful() { public void testCreateMapValueSuccessful() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass", -1); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); compositeIndexDefinition.addIndex(new OPropertyMapIndexDefinition("testCollectionClass", "fTwo", OType.STRING, - OPropertyMapIndexDefinition.INDEX_BY.KEY, -1)); + OPropertyMapIndexDefinition.INDEX_BY.KEY)); final Map stringMap = new HashMap(); stringMap.put("key1", "val1"); @@ -79,8 +79,8 @@ public void testCreateMapValueSuccessful() { public void testCreateCollectionValueSuccessfulOne() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass", -1); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER, -1)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER)); final Object result = compositeIndexDefinition.createValue(12, Arrays.asList(1, 2)); @@ -96,8 +96,8 @@ public void testCreateCollectionValueSuccessfulOne() { public void testCreateRidBagValueSuccessfulOne() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass", -1); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo", -1)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo")); ORidBag ridBag = new ORidBag(); ridBag.setAutoConvertToRecord(false); @@ -120,8 +120,8 @@ public void testCreateRidBagValueSuccessfulOne() { public void testCreateCollectionValueSuccessfulTwo() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass", -1); - compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); + compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); final Object result = compositeIndexDefinition.createValue(Arrays.asList(Arrays.asList(1, 2), 12)); @@ -137,8 +137,8 @@ public void testCreateCollectionValueSuccessfulTwo() { public void testCreateRidBagValueSuccessfulTwo() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass", -1); - compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo", -1)); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); + compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo")); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); ORidBag ridBag = new ORidBag(); ridBag.setAutoConvertToRecord(false); @@ -161,9 +161,9 @@ public void testCreateRidBagValueSuccessfulTwo() { public void testCreateCollectionValueSuccessfulThree() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass", -1); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.STRING, -1)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.STRING)); final Object result = compositeIndexDefinition.createValue(12, Arrays.asList(1, 2), "test"); @@ -179,9 +179,9 @@ public void testCreateCollectionValueSuccessfulThree() { public void testCreateRidBagValueSuccessfulThree() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass", -1); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo", -1)); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.STRING, -1)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo")); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.STRING)); ORidBag ridBag = new ORidBag(); ridBag.setAutoConvertToRecord(false); @@ -204,8 +204,8 @@ public void testCreateRidBagValueSuccessfulThree() { public void testCreateCollectionValueTwoCollections() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass", -1); - compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); + compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); compositeIndexDefinition.createValue(Arrays.asList(1, 2), Arrays.asList(12)); } @@ -229,7 +229,7 @@ public void testCreateValueWrongParamArrayParams() { @Test public void testCreateValueDefinitionsMoreThanParams() { - compositeIndex.addIndex(new OPropertyIndexDefinition("testClass", "fThree", OType.STRING, -1)); + compositeIndex.addIndex(new OPropertyIndexDefinition("testClass", "fThree", OType.STRING)); final Object result = compositeIndex.createValue("12", "test"); Assert.assertEquals(result, new OCompositeKey(Arrays.asList(12, "test"))); @@ -239,8 +239,8 @@ public void testCreateValueDefinitionsMoreThanParams() { public void testCreateValueIndexItemWithTwoParams() { final OCompositeIndexDefinition anotherCompositeIndex = new OCompositeIndexDefinition("testClass", -1); - anotherCompositeIndex.addIndex(new OPropertyIndexDefinition("testClass", "f11", OType.STRING, -1)); - anotherCompositeIndex.addIndex(new OPropertyIndexDefinition("testClass", "f22", OType.STRING, -1)); + anotherCompositeIndex.addIndex(new OPropertyIndexDefinition("testClass", "f11", OType.STRING)); + anotherCompositeIndex.addIndex(new OPropertyIndexDefinition("testClass", "f22", OType.STRING)); compositeIndex.addIndex(anotherCompositeIndex); @@ -272,9 +272,9 @@ public void testDocumentToIndexMapValueSuccessful() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass", -1); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); compositeIndexDefinition.addIndex(new OPropertyMapIndexDefinition("testCollectionClass", "fTwo", OType.STRING, - OPropertyMapIndexDefinition.INDEX_BY.KEY, -1)); + OPropertyMapIndexDefinition.INDEX_BY.KEY)); final Object result = compositeIndexDefinition.getDocumentValueToIndex(document); final Collection collectionResult = (Collection) result; @@ -293,8 +293,8 @@ public void testDocumentToIndexCollectionValueSuccessfulOne() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass", -1); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER, -1)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER)); final Object result = compositeIndexDefinition.getDocumentValueToIndex(document); @@ -321,8 +321,8 @@ public void testDocumentToIndexRidBagValueSuccessfulOne() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass", -1); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo", -1)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo")); final Object result = compositeIndexDefinition.getDocumentValueToIndex(document); @@ -344,8 +344,8 @@ public void testDocumentToIndexCollectionValueSuccessfulTwo() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass", -1); - compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); + compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); final Object result = compositeIndexDefinition.getDocumentValueToIndex(document); @@ -372,8 +372,8 @@ public void testDocumentToIndexRidBagValueSuccessfulTwo() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass", -1); - compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo", -1)); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); + compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo")); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); final Object result = compositeIndexDefinition.getDocumentValueToIndex(document); @@ -396,9 +396,9 @@ public void testDocumentToIndexCollectionValueSuccessfulThree() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass", -1); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.STRING, -1)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.STRING)); final Object result = compositeIndexDefinition.getDocumentValueToIndex(document); @@ -426,9 +426,9 @@ public void testDocumentToIndexRidBagValueSuccessfulThree() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass", -1); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo", -1)); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.STRING, -1)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo")); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.STRING)); final Object result = compositeIndexDefinition.getDocumentValueToIndex(document); @@ -450,8 +450,8 @@ public void testDocumentToIndexCollectionValueTwoCollections() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass", -1); - compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER, -1)); + compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.INTEGER)); compositeIndexDefinition.getDocumentValueToIndex(document); } @@ -488,8 +488,8 @@ public void testEmptyIndexReload() { final OCompositeIndexDefinition emptyCompositeIndex = new OCompositeIndexDefinition("testClass", -1); - emptyCompositeIndex.addIndex(new OPropertyIndexDefinition("testClass", "fOne", OType.INTEGER, -1)); - emptyCompositeIndex.addIndex(new OPropertyIndexDefinition("testClass", "fTwo", OType.STRING, -1)); + emptyCompositeIndex.addIndex(new OPropertyIndexDefinition("testClass", "fOne", OType.INTEGER)); + emptyCompositeIndex.addIndex(new OPropertyIndexDefinition("testClass", "fTwo", OType.STRING)); final ODocument docToStore = emptyCompositeIndex.toStream(); database.save(docToStore); @@ -519,13 +519,13 @@ public void testClassOnlyConstructor() { database.create(); final OCompositeIndexDefinition emptyCompositeIndex = new OCompositeIndexDefinition("testClass", Arrays.asList( - new OPropertyIndexDefinition("testClass", "fOne", OType.INTEGER, -1), new OPropertyIndexDefinition("testClass", "fTwo", - OType.STRING, -1)), -1); + new OPropertyIndexDefinition("testClass", "fOne", OType.INTEGER), new OPropertyIndexDefinition("testClass", "fTwo", + OType.STRING)), -1); final OCompositeIndexDefinition emptyCompositeIndexTwo = new OCompositeIndexDefinition("testClass", -1); - emptyCompositeIndexTwo.addIndex(new OPropertyIndexDefinition("testClass", "fOne", OType.INTEGER, -1)); - emptyCompositeIndexTwo.addIndex(new OPropertyIndexDefinition("testClass", "fTwo", OType.STRING, -1)); + emptyCompositeIndexTwo.addIndex(new OPropertyIndexDefinition("testClass", "fOne", OType.INTEGER)); + emptyCompositeIndexTwo.addIndex(new OPropertyIndexDefinition("testClass", "fTwo", OType.STRING)); Assert.assertEquals(emptyCompositeIndex, emptyCompositeIndexTwo); @@ -544,9 +544,9 @@ public void testClassOnlyConstructor() { public void testProcessChangeListEventsOne() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition(); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.STRING, -1)); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.INTEGER, -1)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.STRING)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.INTEGER)); final ODocument doc = new ODocument(); ORecordInternal.unsetDirty(doc); @@ -582,9 +582,9 @@ public void onAfterRecordChanged(final OMultiValueChangeEvent e public void testProcessChangeRidBagEventsOne() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition(); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo", -1)); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.INTEGER, -1)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo")); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.INTEGER)); final ORidBag ridBag = new ORidBag(); final List> firedEvents = new ArrayList>(); @@ -618,9 +618,9 @@ public void onAfterRecordChanged(final OMultiValueChangeEvent e public void testProcessChangeRidBagEventsTwo() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition(); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo", -1)); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.INTEGER, -1)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo")); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.INTEGER)); final ORidBag ridBag = new ORidBag(); final List> firedEvents = new ArrayList>(); @@ -696,9 +696,9 @@ public void onAfterRecordChanged(final OMultiValueChangeEvent ev public void testProcessChangeSetEventsTwo() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition(); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); - compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.STRING, -1)); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.INTEGER, -1)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); + compositeIndexDefinition.addIndex(new OPropertyListIndexDefinition("testCollectionClass", "fTwo", OType.STRING)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.INTEGER)); final ODocument doc = new ODocument(); ORecordInternal.unsetDirty(doc); @@ -775,10 +775,10 @@ public void onAfterRecordChanged(final OMultiValueChangeEvent ev public void testProcessChangeKeyMapEventsOne() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition(); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); compositeIndexDefinition.addIndex(new OPropertyMapIndexDefinition("testCollectionClass", "fTwo", OType.STRING, - OPropertyMapIndexDefinition.INDEX_BY.KEY, -1)); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.INTEGER, -1)); + OPropertyMapIndexDefinition.INDEX_BY.KEY)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.INTEGER)); final ODocument doc = new ODocument(); ORecordInternal.unsetDirty(doc); @@ -814,10 +814,10 @@ public void onAfterRecordChanged(final OMultiValueChangeEvent ev public void testProcessChangeKeyMapEventsTwo() { final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition(); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER, -1)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER)); compositeIndexDefinition.addIndex(new OPropertyMapIndexDefinition("testCollectionClass", "fTwo", OType.STRING, - OPropertyMapIndexDefinition.INDEX_BY.KEY, -1)); - compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.INTEGER, -1)); + OPropertyMapIndexDefinition.INDEX_BY.KEY)); + compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fThree", OType.INTEGER)); final ODocument doc = new ODocument(); ORecordInternal.unsetDirty(doc); diff --git a/core/src/test/java/com/orientechnologies/orient/core/index/OPropertyIndexDefinitionTest.java b/core/src/test/java/com/orientechnologies/orient/core/index/OPropertyIndexDefinitionTest.java index bd4b99b9274..4b72145e505 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/index/OPropertyIndexDefinitionTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/index/OPropertyIndexDefinitionTest.java @@ -18,7 +18,7 @@ public class OPropertyIndexDefinitionTest { @BeforeMethod public void beforeMethod() { - propertyIndex = new OPropertyIndexDefinition("testClass", "fOne", OType.INTEGER, -1); + propertyIndex = new OPropertyIndexDefinition("testClass", "fOne", OType.INTEGER); } @Test @@ -85,7 +85,7 @@ public void testEmptyIndexReload() { final ODatabaseDocumentTx database = new ODatabaseDocumentTx("memory:propertytest"); database.create(); - propertyIndex = new OPropertyIndexDefinition("tesClass", "fOne", OType.INTEGER, -1); + propertyIndex = new OPropertyIndexDefinition("tesClass", "fOne", OType.INTEGER); final ODocument docToStore = propertyIndex.toStream(); database.save(docToStore); diff --git a/core/src/test/java/com/orientechnologies/orient/core/index/OPropertyListIndexDefinitionTest.java b/core/src/test/java/com/orientechnologies/orient/core/index/OPropertyListIndexDefinitionTest.java index 7b5ad84684e..569fbce357f 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/index/OPropertyListIndexDefinitionTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/index/OPropertyListIndexDefinitionTest.java @@ -24,7 +24,7 @@ public class OPropertyListIndexDefinitionTest { @BeforeMethod public void beforeMethod() { - propertyIndex = new OPropertyListIndexDefinition("testClass", "fOne", OType.INTEGER, -1); + propertyIndex = new OPropertyListIndexDefinition("testClass", "fOne", OType.INTEGER); } public void testCreateValueSingleParameter() { diff --git a/core/src/test/java/com/orientechnologies/orient/core/index/OPropertyMapIndexDefinitionTest.java b/core/src/test/java/com/orientechnologies/orient/core/index/OPropertyMapIndexDefinitionTest.java index 30cee4c67af..5c360a1db06 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/index/OPropertyMapIndexDefinitionTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/index/OPropertyMapIndexDefinitionTest.java @@ -38,11 +38,11 @@ public void beforeClass() { @BeforeMethod public void beforeMethod() { propertyIndexByKey = new OPropertyMapIndexDefinition("testClass", "fOne", OType.STRING, - OPropertyMapIndexDefinition.INDEX_BY.KEY, -1); + OPropertyMapIndexDefinition.INDEX_BY.KEY); propertyIndexByIntegerKey = new OPropertyMapIndexDefinition("testClass", "fTwo", OType.INTEGER, - OPropertyMapIndexDefinition.INDEX_BY.KEY, -1); + OPropertyMapIndexDefinition.INDEX_BY.KEY); propertyIndexByValue = new OPropertyMapIndexDefinition("testClass", "fOne", OType.INTEGER, - OPropertyMapIndexDefinition.INDEX_BY.VALUE, -1); + OPropertyMapIndexDefinition.INDEX_BY.VALUE); } public void testCreateValueByKeySingleParameter() { @@ -196,7 +196,7 @@ public void testEmptyIndexByKeyReload() { database.create(); propertyIndexByKey = new OPropertyMapIndexDefinition("tesClass", "fOne", OType.STRING, - OPropertyMapIndexDefinition.INDEX_BY.KEY, -1); + OPropertyMapIndexDefinition.INDEX_BY.KEY); final ODocument docToStore = propertyIndexByKey.toStream(); database.save(docToStore); @@ -215,7 +215,7 @@ public void testEmptyIndexByValueReload() { database.create(); propertyIndexByValue = new OPropertyMapIndexDefinition("tesClass", "fOne", OType.INTEGER, - OPropertyMapIndexDefinition.INDEX_BY.VALUE, -1); + OPropertyMapIndexDefinition.INDEX_BY.VALUE); final ODocument docToStore = propertyIndexByValue.toStream(); database.save(docToStore); @@ -246,7 +246,7 @@ public void testCreateWrongSingleValueByValue() { @Test(expectedExceptions = NullPointerException.class) public void testIndexByIsRequired() { - new OPropertyMapIndexDefinition("testClass", "testField", OType.STRING, null, -1); + new OPropertyMapIndexDefinition("testClass", "testField", OType.STRING, null); } public void testCreateDDLByKey() { diff --git a/core/src/test/java/com/orientechnologies/orient/core/index/OPropertyRidBagAbstractIndexDefinitionTest.java b/core/src/test/java/com/orientechnologies/orient/core/index/OPropertyRidBagAbstractIndexDefinitionTest.java index 0008a16ac35..33431a981fe 100755 --- a/core/src/test/java/com/orientechnologies/orient/core/index/OPropertyRidBagAbstractIndexDefinitionTest.java +++ b/core/src/test/java/com/orientechnologies/orient/core/index/OPropertyRidBagAbstractIndexDefinitionTest.java @@ -21,7 +21,7 @@ public abstract class OPropertyRidBagAbstractIndexDefinitionTest { @BeforeMethod public void beforeMethod() { - propertyIndex = new OPropertyRidBagIndexDefinition("testClass", "fOne", -1); + propertyIndex = new OPropertyRidBagIndexDefinition("testClass", "fOne"); } public void testCreateValueSingleParameter() { diff --git a/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientBaseGraph.java b/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientBaseGraph.java index a465d227d74..1a832a09692 100755 --- a/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientBaseGraph.java +++ b/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientBaseGraph.java @@ -1544,7 +1544,7 @@ else if (p.getKey().toString().startsWith("metadata.")) { db.getMetadata() .getIndexManager() .createIndex(className + "." + key, indexType, - new OPropertyIndexDefinition(className, key, keyType, factory.getLastVersion()), cls.getPolymorphicClusterIds(), + new OPropertyIndexDefinition(className, key, keyType), cls.getPolymorphicClusterIds(), null, metadata); return null; diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/ClassIndexTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/ClassIndexTest.java index a6a9709c89c..5e8ad64d1a7 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/ClassIndexTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/ClassIndexTest.java @@ -1,7 +1,6 @@ package com.orientechnologies.orient.test.database.auto; import com.orientechnologies.common.listener.OProgressListener; -import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; import com.orientechnologies.orient.core.index.OCompositeIndexDefinition; import com.orientechnologies.orient.core.index.OIndex; import com.orientechnologies.orient.core.index.OIndexDefinition; @@ -13,7 +12,6 @@ import com.orientechnologies.orient.core.metadata.schema.OClass; import com.orientechnologies.orient.core.metadata.schema.OSchema; import com.orientechnologies.orient.core.metadata.schema.OType; -import com.orientechnologies.orient.core.sql.OCommandSQL; import com.orientechnologies.orient.enterprise.channel.binary.OResponseProcessingException; import org.testng.Assert; import org.testng.annotations.*; @@ -1016,83 +1014,83 @@ public void testGetClassIndexes() { final OCompositeIndexDefinition compositeIndexOne = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexOne.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fOne", OType.INTEGER, -1)); - compositeIndexOne.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fTwo", OType.STRING, -1)); + compositeIndexOne.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fOne", OType.INTEGER)); + compositeIndexOne.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fTwo", OType.STRING)); expectedIndexDefinitions.add(compositeIndexOne); final OCompositeIndexDefinition compositeIndexTwo = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexTwo.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fOne", OType.INTEGER, -1)); - compositeIndexTwo.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fTwo", OType.STRING, -1)); - compositeIndexTwo.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fThree", OType.BOOLEAN, -1)); + compositeIndexTwo.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fOne", OType.INTEGER)); + compositeIndexTwo.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fTwo", OType.STRING)); + compositeIndexTwo.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fThree", OType.BOOLEAN)); expectedIndexDefinitions.add(compositeIndexTwo); final OCompositeIndexDefinition compositeIndexThree = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexThree.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fEight", OType.INTEGER, -1)); + compositeIndexThree.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fEight", OType.INTEGER)); compositeIndexThree.addIndex(new OPropertyMapIndexDefinition("ClassIndexTestClass", "fEmbeddedMap", OType.STRING, - OPropertyMapIndexDefinition.INDEX_BY.KEY, -1)); + OPropertyMapIndexDefinition.INDEX_BY.KEY)); expectedIndexDefinitions.add(compositeIndexThree); final OCompositeIndexDefinition compositeIndexFour = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexFour.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fTen", OType.INTEGER, -1)); + compositeIndexFour.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fTen", OType.INTEGER)); compositeIndexFour.addIndex(new OPropertyMapIndexDefinition("ClassIndexTestClass", "fEmbeddedMap", OType.INTEGER, - OPropertyMapIndexDefinition.INDEX_BY.VALUE, -1)); + OPropertyMapIndexDefinition.INDEX_BY.VALUE)); expectedIndexDefinitions.add(compositeIndexFour); final OCompositeIndexDefinition compositeIndexFive = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexFive.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fEleven", OType.INTEGER, -1)); + compositeIndexFive.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fEleven", OType.INTEGER)); compositeIndexFive.addIndex(new OPropertyMapIndexDefinition("ClassIndexTestClass", "fLinkMap", OType.LINK, - OPropertyMapIndexDefinition.INDEX_BY.VALUE, -1)); + OPropertyMapIndexDefinition.INDEX_BY.VALUE)); expectedIndexDefinitions.add(compositeIndexFive); final OCompositeIndexDefinition compositeIndexSix = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexSix.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fTwelve", OType.INTEGER, -1)); - compositeIndexSix.addIndex(new OPropertyListIndexDefinition("ClassIndexTestClass", "fEmbeddedSet", OType.INTEGER, -1)); + compositeIndexSix.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fTwelve", OType.INTEGER)); + compositeIndexSix.addIndex(new OPropertyListIndexDefinition("ClassIndexTestClass", "fEmbeddedSet", OType.INTEGER)); expectedIndexDefinitions.add(compositeIndexSix); final OCompositeIndexDefinition compositeIndexSeven = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexSeven.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fThirteen", OType.INTEGER, -1)); - compositeIndexSeven.addIndex(new OPropertyListIndexDefinition("ClassIndexTestClass", "fEmbeddedList", OType.INTEGER, -1)); + compositeIndexSeven.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fThirteen", OType.INTEGER)); + compositeIndexSeven.addIndex(new OPropertyListIndexDefinition("ClassIndexTestClass", "fEmbeddedList", OType.INTEGER)); expectedIndexDefinitions.add(compositeIndexSeven); final OCompositeIndexDefinition compositeIndexEight = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexEight.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fFourteen", OType.INTEGER, -1)); - compositeIndexEight.addIndex(new OPropertyListIndexDefinition("ClassIndexTestClass", "fEmbeddedList", OType.LINK, -1)); + compositeIndexEight.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fFourteen", OType.INTEGER)); + compositeIndexEight.addIndex(new OPropertyListIndexDefinition("ClassIndexTestClass", "fEmbeddedList", OType.LINK)); expectedIndexDefinitions.add(compositeIndexEight); final OCompositeIndexDefinition compositeIndexNine = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexNine.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fFifteen", OType.INTEGER, -1)); + compositeIndexNine.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fFifteen", OType.INTEGER)); compositeIndexNine.addIndex(new OPropertyMapIndexDefinition("ClassIndexTestClass", "fEmbeddedMap", OType.STRING, - OPropertyMapIndexDefinition.INDEX_BY.KEY, -1)); + OPropertyMapIndexDefinition.INDEX_BY.KEY)); expectedIndexDefinitions.add(compositeIndexNine); final OCompositeIndexDefinition compositeIndexTen = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexTen.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fFourteen", OType.INTEGER, -1)); - compositeIndexTen.addIndex(new OPropertyListIndexDefinition("ClassIndexTestClass", "fLinkList", OType.LINK, -1)); + compositeIndexTen.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fFourteen", OType.INTEGER)); + compositeIndexTen.addIndex(new OPropertyListIndexDefinition("ClassIndexTestClass", "fLinkList", OType.LINK)); expectedIndexDefinitions.add(compositeIndexTen); final OCompositeIndexDefinition compositeIndexEleven = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexEleven.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fFourteen", OType.INTEGER, -1)); - compositeIndexEleven.addIndex(new OPropertyRidBagIndexDefinition("ClassIndexTestClass", "fRidBag", -1)); + compositeIndexEleven.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fFourteen", OType.INTEGER)); + compositeIndexEleven.addIndex(new OPropertyRidBagIndexDefinition("ClassIndexTestClass", "fRidBag")); expectedIndexDefinitions.add(compositeIndexEleven); - final OPropertyIndexDefinition propertyIndex = new OPropertyIndexDefinition("ClassIndexTestClass", "fOne", OType.INTEGER, -1); + final OPropertyIndexDefinition propertyIndex = new OPropertyIndexDefinition("ClassIndexTestClass", "fOne", OType.INTEGER); expectedIndexDefinitions.add(propertyIndex); final OPropertyMapIndexDefinition propertyMapIndexDefinition = new OPropertyMapIndexDefinition("ClassIndexTestClass", - "fEmbeddedMap", OType.STRING, OPropertyMapIndexDefinition.INDEX_BY.KEY, -1); + "fEmbeddedMap", OType.STRING, OPropertyMapIndexDefinition.INDEX_BY.KEY); expectedIndexDefinitions.add(propertyMapIndexDefinition); final OPropertyMapIndexDefinition propertyMapByValueIndexDefinition = new OPropertyMapIndexDefinition("ClassIndexTestClass", - "fEmbeddedMap", OType.INTEGER, OPropertyMapIndexDefinition.INDEX_BY.VALUE, -1); + "fEmbeddedMap", OType.INTEGER, OPropertyMapIndexDefinition.INDEX_BY.VALUE); expectedIndexDefinitions.add(propertyMapByValueIndexDefinition); final OPropertyMapIndexDefinition propertyLinkMapByKeyIndexDefinition = new OPropertyMapIndexDefinition("ClassIndexTestClass", - "fLinkMap", OType.STRING, OPropertyMapIndexDefinition.INDEX_BY.KEY, -1); + "fLinkMap", OType.STRING, OPropertyMapIndexDefinition.INDEX_BY.KEY); expectedIndexDefinitions.add(propertyLinkMapByKeyIndexDefinition); final OPropertyMapIndexDefinition propertyLinkMapByValueIndexDefinition = new OPropertyMapIndexDefinition( - "ClassIndexTestClass", "fLinkMap", OType.LINK, OPropertyMapIndexDefinition.INDEX_BY.VALUE, -1); + "ClassIndexTestClass", "fLinkMap", OType.LINK, OPropertyMapIndexDefinition.INDEX_BY.VALUE); expectedIndexDefinitions.add(propertyLinkMapByValueIndexDefinition); assertEquals(indexes.size(), 17); @@ -1117,87 +1115,87 @@ public void testGetIndexes() { final OCompositeIndexDefinition compositeIndexOne = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexOne.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fOne", OType.INTEGER, -1)); - compositeIndexOne.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fTwo", OType.STRING, -1)); + compositeIndexOne.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fOne", OType.INTEGER)); + compositeIndexOne.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fTwo", OType.STRING)); expectedIndexDefinitions.add(compositeIndexOne); final OCompositeIndexDefinition compositeIndexTwo = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexTwo.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fOne", OType.INTEGER, -1)); - compositeIndexTwo.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fTwo", OType.STRING, -1)); - compositeIndexTwo.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fThree", OType.BOOLEAN, -1)); + compositeIndexTwo.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fOne", OType.INTEGER)); + compositeIndexTwo.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fTwo", OType.STRING)); + compositeIndexTwo.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fThree", OType.BOOLEAN)); expectedIndexDefinitions.add(compositeIndexTwo); final OCompositeIndexDefinition compositeIndexThree = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexThree.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fEight", OType.INTEGER, -1)); + compositeIndexThree.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fEight", OType.INTEGER)); compositeIndexThree.addIndex(new OPropertyMapIndexDefinition("ClassIndexTestClass", "fEmbeddedMap", OType.STRING, - OPropertyMapIndexDefinition.INDEX_BY.KEY, -1)); + OPropertyMapIndexDefinition.INDEX_BY.KEY)); expectedIndexDefinitions.add(compositeIndexThree); final OCompositeIndexDefinition compositeIndexFour = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexFour.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fTen", OType.INTEGER, -1)); + compositeIndexFour.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fTen", OType.INTEGER)); compositeIndexFour.addIndex(new OPropertyMapIndexDefinition("ClassIndexTestClass", "fEmbeddedMap", OType.INTEGER, - OPropertyMapIndexDefinition.INDEX_BY.VALUE, -1)); + OPropertyMapIndexDefinition.INDEX_BY.VALUE)); expectedIndexDefinitions.add(compositeIndexFour); final OCompositeIndexDefinition compositeIndexFive = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexFive.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fEleven", OType.INTEGER, -1)); + compositeIndexFive.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fEleven", OType.INTEGER)); compositeIndexFive.addIndex(new OPropertyMapIndexDefinition("ClassIndexTestClass", "fLinkMap", OType.LINK, - OPropertyMapIndexDefinition.INDEX_BY.VALUE, -1)); + OPropertyMapIndexDefinition.INDEX_BY.VALUE)); expectedIndexDefinitions.add(compositeIndexFive); final OCompositeIndexDefinition compositeIndexSix = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexSix.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fTwelve", OType.INTEGER, -1)); - compositeIndexSix.addIndex(new OPropertyListIndexDefinition("ClassIndexTestClass", "fEmbeddedSet", OType.INTEGER, -1)); + compositeIndexSix.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fTwelve", OType.INTEGER)); + compositeIndexSix.addIndex(new OPropertyListIndexDefinition("ClassIndexTestClass", "fEmbeddedSet", OType.INTEGER)); expectedIndexDefinitions.add(compositeIndexSix); final OCompositeIndexDefinition compositeIndexSeven = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexSeven.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fThirteen", OType.INTEGER, -1)); - compositeIndexSeven.addIndex(new OPropertyListIndexDefinition("ClassIndexTestClass", "fEmbeddedList", OType.INTEGER, -1)); + compositeIndexSeven.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fThirteen", OType.INTEGER)); + compositeIndexSeven.addIndex(new OPropertyListIndexDefinition("ClassIndexTestClass", "fEmbeddedList", OType.INTEGER)); expectedIndexDefinitions.add(compositeIndexSeven); final OCompositeIndexDefinition compositeIndexEight = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexEight.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fFourteen", OType.INTEGER, -1)); - compositeIndexEight.addIndex(new OPropertyListIndexDefinition("ClassIndexTestClass", "fEmbeddedList", OType.LINK, -1)); + compositeIndexEight.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fFourteen", OType.INTEGER)); + compositeIndexEight.addIndex(new OPropertyListIndexDefinition("ClassIndexTestClass", "fEmbeddedList", OType.LINK)); expectedIndexDefinitions.add(compositeIndexEight); final OCompositeIndexDefinition compositeIndexNine = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexNine.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fFifteen", OType.INTEGER, -1)); + compositeIndexNine.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fFifteen", OType.INTEGER)); compositeIndexNine.addIndex(new OPropertyMapIndexDefinition("ClassIndexTestClass", "fEmbeddedMap", OType.STRING, - OPropertyMapIndexDefinition.INDEX_BY.KEY, -1)); + OPropertyMapIndexDefinition.INDEX_BY.KEY)); expectedIndexDefinitions.add(compositeIndexNine); final OCompositeIndexDefinition compositeIndexTen = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexTen.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fFourteen", OType.INTEGER, -1)); - compositeIndexTen.addIndex(new OPropertyListIndexDefinition("ClassIndexTestClass", "fLinkList", OType.LINK, -1)); + compositeIndexTen.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fFourteen", OType.INTEGER)); + compositeIndexTen.addIndex(new OPropertyListIndexDefinition("ClassIndexTestClass", "fLinkList", OType.LINK)); expectedIndexDefinitions.add(compositeIndexTen); final OCompositeIndexDefinition compositeIndexEleven = new OCompositeIndexDefinition("ClassIndexTestClass", -1); - compositeIndexEleven.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fFourteen", OType.INTEGER, -1)); - compositeIndexEleven.addIndex(new OPropertyRidBagIndexDefinition("ClassIndexTestClass", "fRidBag", -1)); + compositeIndexEleven.addIndex(new OPropertyIndexDefinition("ClassIndexTestClass", "fFourteen", OType.INTEGER)); + compositeIndexEleven.addIndex(new OPropertyRidBagIndexDefinition("ClassIndexTestClass", "fRidBag")); expectedIndexDefinitions.add(compositeIndexEleven); - final OPropertyIndexDefinition propertyIndex = new OPropertyIndexDefinition("ClassIndexTestClass", "fOne", OType.INTEGER, -1); + final OPropertyIndexDefinition propertyIndex = new OPropertyIndexDefinition("ClassIndexTestClass", "fOne", OType.INTEGER); expectedIndexDefinitions.add(propertyIndex); final OPropertyIndexDefinition parentPropertyIndex = new OPropertyIndexDefinition("ClassIndexTestSuperClass", "fNine", - OType.INTEGER, -1); + OType.INTEGER); expectedIndexDefinitions.add(parentPropertyIndex); final OPropertyMapIndexDefinition propertyMapIndexDefinition = new OPropertyMapIndexDefinition("ClassIndexTestClass", - "fEmbeddedMap", OType.STRING, OPropertyMapIndexDefinition.INDEX_BY.KEY, -1); + "fEmbeddedMap", OType.STRING, OPropertyMapIndexDefinition.INDEX_BY.KEY); expectedIndexDefinitions.add(propertyMapIndexDefinition); final OPropertyMapIndexDefinition propertyMapByValueIndexDefinition = new OPropertyMapIndexDefinition("ClassIndexTestClass", - "fEmbeddedMap", OType.INTEGER, OPropertyMapIndexDefinition.INDEX_BY.VALUE, -1); + "fEmbeddedMap", OType.INTEGER, OPropertyMapIndexDefinition.INDEX_BY.VALUE); expectedIndexDefinitions.add(propertyMapByValueIndexDefinition); final OPropertyMapIndexDefinition propertyLinkMapByKeyIndexDefinition = new OPropertyMapIndexDefinition("ClassIndexTestClass", - "fLinkMap", OType.STRING, OPropertyMapIndexDefinition.INDEX_BY.KEY, -1); + "fLinkMap", OType.STRING, OPropertyMapIndexDefinition.INDEX_BY.KEY); expectedIndexDefinitions.add(propertyLinkMapByKeyIndexDefinition); final OPropertyMapIndexDefinition propertyLinkMapByValueIndexDefinition = new OPropertyMapIndexDefinition( - "ClassIndexTestClass", "fLinkMap", OType.LINK, OPropertyMapIndexDefinition.INDEX_BY.VALUE, -1); + "ClassIndexTestClass", "fLinkMap", OType.LINK, OPropertyMapIndexDefinition.INDEX_BY.VALUE); expectedIndexDefinitions.add(propertyLinkMapByValueIndexDefinition); assertEquals(indexes.size(), 18); @@ -1219,7 +1217,7 @@ public void testGetIndexesWithoutParent() { final Set> indexes = inClass.getIndexes(); final OPropertyIndexDefinition propertyIndexDefinition = new OPropertyIndexDefinition("ClassIndexInTest", "fOne", - OType.INTEGER, -1); + OType.INTEGER); assertEquals(indexes.size(), 1); diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/IndexManagerTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/IndexManagerTest.java index 34a58b5e56f..c253f13aeb0 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/IndexManagerTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/IndexManagerTest.java @@ -1,8 +1,6 @@ package com.orientechnologies.orient.test.database.auto; import com.orientechnologies.common.listener.OProgressListener; -import com.orientechnologies.orient.core.db.document.ODatabaseDocument; -import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; import com.orientechnologies.orient.core.index.OCompositeIndexDefinition; import com.orientechnologies.orient.core.index.OIndex; import com.orientechnologies.orient.core.index.OIndexDefinition; @@ -106,7 +104,7 @@ public void testCreateOnePropertyIndexTest() { final OIndexManagerProxy indexManager = database.getMetadata().getIndexManager(); final OIndex result = indexManager.createIndex("propertyone", OClass.INDEX_TYPE.UNIQUE.toString(), - new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER, -1), new int[] { database.getClusterIdByName(CLASS_NAME) }, + new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER), new int[] { database.getClusterIdByName(CLASS_NAME) }, null, null); assertEquals(result.getName(), "propertyone"); @@ -124,8 +122,8 @@ public void createCompositeIndexTestWithoutListener() { "compositeone", OClass.INDEX_TYPE.NOTUNIQUE.toString(), new OCompositeIndexDefinition(CLASS_NAME, Arrays.asList( - new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER, -1), new OPropertyIndexDefinition(CLASS_NAME, "fTwo", - OType.STRING, -1) + new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER), new OPropertyIndexDefinition(CLASS_NAME, "fTwo", + OType.STRING) ), -1), new int[] { database.getClusterIdByName(CLASS_NAME) }, null, null); @@ -161,8 +159,8 @@ public void onCompletition(final Object iTask, final boolean iSucceed) { "compositetwo", OClass.INDEX_TYPE.NOTUNIQUE.toString(), new OCompositeIndexDefinition(CLASS_NAME, Arrays.asList( - new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER, -1), new OPropertyIndexDefinition(CLASS_NAME, "fTwo", - OType.STRING, -1), new OPropertyIndexDefinition(CLASS_NAME, "fThree", OType.BOOLEAN, -1) + new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER), new OPropertyIndexDefinition(CLASS_NAME, "fTwo", + OType.STRING), new OPropertyIndexDefinition(CLASS_NAME, "fThree", OType.BOOLEAN) ), -1), new int[] { database.getClusterIdByName(CLASS_NAME) }, progressListener, null); @@ -483,18 +481,18 @@ public void testGetClassIndexes() { final OCompositeIndexDefinition compositeIndexOne = new OCompositeIndexDefinition(CLASS_NAME, -1); - compositeIndexOne.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER, -1)); - compositeIndexOne.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fTwo", OType.STRING, -1)); + compositeIndexOne.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER)); + compositeIndexOne.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fTwo", OType.STRING)); expectedIndexDefinitions.add(compositeIndexOne); final OCompositeIndexDefinition compositeIndexTwo = new OCompositeIndexDefinition(CLASS_NAME, -1); - compositeIndexTwo.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER, -1)); - compositeIndexTwo.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fTwo", OType.STRING, -1)); - compositeIndexTwo.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fThree", OType.BOOLEAN, -1)); + compositeIndexTwo.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER)); + compositeIndexTwo.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fTwo", OType.STRING)); + compositeIndexTwo.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fThree", OType.BOOLEAN)); expectedIndexDefinitions.add(compositeIndexTwo); - final OPropertyIndexDefinition propertyIndex = new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER, -1); + final OPropertyIndexDefinition propertyIndex = new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER); expectedIndexDefinitions.add(propertyIndex); assertEquals(indexes.size(), 3); @@ -515,18 +513,18 @@ public void testGetClassIndexesBrokenClassNameCase() { final OCompositeIndexDefinition compositeIndexOne = new OCompositeIndexDefinition(CLASS_NAME, -1); - compositeIndexOne.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER, -1)); - compositeIndexOne.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fTwo", OType.STRING, -1)); + compositeIndexOne.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER)); + compositeIndexOne.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fTwo", OType.STRING)); expectedIndexDefinitions.add(compositeIndexOne); final OCompositeIndexDefinition compositeIndexTwo = new OCompositeIndexDefinition(CLASS_NAME, -1); - compositeIndexTwo.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER, -1)); - compositeIndexTwo.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fTwo", OType.STRING, -1)); - compositeIndexTwo.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fThree", OType.BOOLEAN, -1)); + compositeIndexTwo.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER)); + compositeIndexTwo.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fTwo", OType.STRING)); + compositeIndexTwo.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fThree", OType.BOOLEAN)); expectedIndexDefinitions.add(compositeIndexTwo); - final OPropertyIndexDefinition propertyIndex = new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER, -1); + final OPropertyIndexDefinition propertyIndex = new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER); expectedIndexDefinitions.add(propertyIndex); assertEquals(indexes.size(), 3); @@ -542,7 +540,7 @@ public void testDropIndex() throws Exception { final OIndexManager indexManager = database.getMetadata().getIndexManager(); indexManager.createIndex("anotherproperty", OClass.INDEX_TYPE.UNIQUE.toString(), new OPropertyIndexDefinition(CLASS_NAME, - "fOne", OType.INTEGER, -1), new int[] { database.getClusterIdByName(CLASS_NAME) }, null, null); + "fOne", OType.INTEGER), new int[] { database.getClusterIdByName(CLASS_NAME) }, null, null); assertNotNull(indexManager.getIndex("anotherproperty")); assertNotNull(indexManager.getClassIndex(CLASS_NAME, "anotherproperty")); @@ -587,7 +585,7 @@ public void testDropAllClassIndexes() { final OIndexManager indexManager = database.getMetadata().getIndexManager(); indexManager.createIndex("twoclassproperty", OClass.INDEX_TYPE.UNIQUE.toString(), new OPropertyIndexDefinition( - "indexManagerTestClassTwo", "fOne", OType.INTEGER, -1), + "indexManagerTestClassTwo", "fOne", OType.INTEGER), new int[] { database.getClusterIdByName("indexManagerTestClassTwo") }, null, null); assertFalse(indexManager.getClassIndexes("indexManagerTestClassTwo").isEmpty()); diff --git a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/IndexTest.java b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/IndexTest.java index fbe19d7b015..7753c82c102 100755 --- a/tests/src/test/java/com/orientechnologies/orient/test/database/auto/IndexTest.java +++ b/tests/src/test/java/com/orientechnologies/orient/test/database/auto/IndexTest.java @@ -23,11 +23,7 @@ import com.orientechnologies.orient.core.db.record.OIdentifiable; import com.orientechnologies.orient.core.id.ORID; import com.orientechnologies.orient.core.id.ORecordId; -import com.orientechnologies.orient.core.index.OCompositeKey; -import com.orientechnologies.orient.core.index.OIndex; -import com.orientechnologies.orient.core.index.OIndexException; -import com.orientechnologies.orient.core.index.OIndexManager; -import com.orientechnologies.orient.core.index.OSimpleKeyIndexDefinition; +import com.orientechnologies.orient.core.index.*; import com.orientechnologies.orient.core.iterator.ORecordIteratorCluster; import com.orientechnologies.orient.core.metadata.schema.OClass; import com.orientechnologies.orient.core.metadata.schema.OClass.INDEX_TYPE; @@ -64,7 +60,7 @@ import java.util.Map; import java.util.Set; -@Test(groups = { "index" }) +@Test(groups = {"index"}) public class IndexTest extends ObjectDBBaseTest { @Parameters(value = "url") public IndexTest(@Optional String url) { @@ -576,7 +572,7 @@ public void createNotUniqueIndexOnNick() { database.getMetadata().getSchema().save(); } - @Test(dependsOnMethods = { "createNotUniqueIndexOnNick", "populateIndexDocuments" }) + @Test(dependsOnMethods = {"createNotUniqueIndexOnNick", "populateIndexDocuments"}) public void testIndexInNotUniqueIndex() { final OProperty nickProperty = database.getMetadata().getSchema().getClass("Profile").getProperty("nick"); Assert.assertEquals(nickProperty.getIndexes().iterator().next().getType(), OClass.INDEX_TYPE.NOTUNIQUE.toString()); @@ -627,7 +623,7 @@ public void testIndexCount() { final OIndex nickIndex = database.getMetadata().getIndexManager().getIndex("Profile.nick"); final List result = database.query(new OSQLSynchQuery("select count(*) from index:Profile.nick")); Assert.assertEquals(result.size(), 1); - Assert.assertEquals(result.get(0). field("count").longValue(), nickIndex.getSize()); + Assert.assertEquals(result.get(0).field("count").longValue(), nickIndex.getSize()); } public void indexLinks() { @@ -1070,7 +1066,9 @@ public void testManualIndexInTx() { database.getMetadata().getSchema().createClass("ManualIndexTxClass"); OIndexManager idxManager = db.getMetadata().getIndexManager(); - idxManager.createIndex("manualTxIndexTest", "UNIQUE", new OSimpleKeyIndexDefinition(-1, OType.INTEGER), null, null, null); + OIndexFactory indexFactory = OIndexes.getFactory("UNIQUE", null); + + idxManager.createIndex("manualTxIndexTest", "UNIQUE", new OSimpleKeyIndexDefinition(indexFactory.getLastVersion(), OType.INTEGER), null, null, null); OIndex idx = (OIndex) idxManager.getIndex("manualTxIndexTest"); ODocument v0 = new ODocument("ManualIndexTxClass"); @@ -1110,7 +1108,9 @@ public void testManualIndexInTxRecursiveStore() { database.getMetadata().getSchema().createClass("ManualIndexTxRecursiveStoreClass"); OIndexManager idxManager = db.getMetadata().getIndexManager(); - idxManager.createIndex("manualTxIndexRecursiveStoreTest", "UNIQUE", new OSimpleKeyIndexDefinition(-1, OType.INTEGER), null, + OIndexFactory factory = OIndexes.getFactory("UNIQUE", null); + + idxManager.createIndex("manualTxIndexRecursiveStoreTest", "UNIQUE", new OSimpleKeyIndexDefinition(factory.getLastVersion(), OType.INTEGER), null, null, null); OIndex idx = (OIndex) idxManager.getIndex("manualTxIndexRecursiveStoreTest"); @@ -1155,7 +1155,9 @@ public void testManualIndexInTxRecursiveStore() { public void testIndexCountPlusCondition() { OIndexManager idxManager = database.getMetadata().getIndexManager(); - idxManager.createIndex("IndexCountPlusCondition", "NOTUNIQUE", new OSimpleKeyIndexDefinition(-1, OType.INTEGER), null, null, + OIndexFactory factory = OIndexes.getFactory("NOTUNIQUE", null); + idxManager.createIndex("IndexCountPlusCondition", "NOTUNIQUE", new OSimpleKeyIndexDefinition(factory.getLastVersion(), + OType.INTEGER), null, null, null); final OIndex idx = (OIndex) idxManager.getIndex("IndexCountPlusCondition"); @@ -1178,7 +1180,7 @@ public void testIndexCountPlusCondition() { for (Map.Entry entry : keyDocsCount.entrySet()) { List result = database.query(new OSQLSynchQuery( "select count(*) from index:IndexCountPlusCondition where key = ?"), entry.getKey()); - Assert.assertEquals(result.get(0). field("count"), entry.getValue()); + Assert.assertEquals(result.get(0).field("count"), entry.getValue()); } } @@ -1344,12 +1346,12 @@ public void testIndexPaginationTest() { for (ODocument document : result) { document.setLazyLoad(false); if (lastKey > -1) - Assert.assertTrue(lastKey <= (Integer) document. field("key").getKeys().get(0)); + Assert.assertTrue(lastKey <= (Integer) document.field("key").getKeys().get(0)); - lastKey = (Integer) document. field("key").getKeys().get(0); + lastKey = (Integer) document.field("key").getKeys().get(0); lastRid = document.field("rid"); - Assert.assertTrue(rids.remove(document. field("rid").getIdentity())); + Assert.assertTrue(rids.remove(document.field("rid").getIdentity())); } while (true) { @@ -1363,12 +1365,12 @@ public void testIndexPaginationTest() { for (ODocument document : result) { document.setLazyLoad(false); if (lastKey > -1) - Assert.assertTrue(lastKey <= (Integer) document. field("key").getKeys().get(0)); + Assert.assertTrue(lastKey <= (Integer) document.field("key").getKeys().get(0)); - lastKey = (Integer) document. field("key").getKeys().get(0); + lastKey = (Integer) document.field("key").getKeys().get(0); lastRid = document.field("rid", OType.LINK); - Assert.assertTrue(rids.remove(document. field("rid", OType.LINK))); + Assert.assertTrue(rids.remove(document.field("rid", OType.LINK))); } } @@ -1403,12 +1405,12 @@ public void testIndexPaginationTestDescOrder() { for (ODocument document : result) { document.setLazyLoad(false); if (lastKey > -1) - Assert.assertTrue(lastKey >= (Integer) document. field("key").getKeys().get(0)); + Assert.assertTrue(lastKey >= (Integer) document.field("key").getKeys().get(0)); - lastKey = (Integer) document. field("key").getKeys().get(0); + lastKey = (Integer) document.field("key").getKeys().get(0); lastRid = document.field("rid"); - Assert.assertTrue(rids.remove(document. field("rid"))); + Assert.assertTrue(rids.remove(document.field("rid"))); } while (true) { @@ -1423,12 +1425,12 @@ public void testIndexPaginationTestDescOrder() { for (ODocument document : result) { document.setLazyLoad(false); if (lastKey > -1) - Assert.assertTrue(lastKey >= (Integer) document. field("key").getKeys().get(0)); + Assert.assertTrue(lastKey >= (Integer) document.field("key").getKeys().get(0)); - lastKey = (Integer) document. field("key").getKeys().get(0); + lastKey = (Integer) document.field("key").getKeys().get(0); lastRid = document.field("rid", OType.LINK); - Assert.assertTrue(rids.remove(document. field("rid", OType.LINK))); + Assert.assertTrue(rids.remove(document.field("rid", OType.LINK))); } } @@ -1445,7 +1447,7 @@ public void testNullIndexKeysSupport() { ODocument metadata = new ODocument(); metadata.field("ignoreNullValues", false); - clazz.createIndex("NullIndexKeysSupportIndex", INDEX_TYPE.NOTUNIQUE.toString(), null, metadata, new String[] { "nullField" }); + clazz.createIndex("NullIndexKeysSupportIndex", INDEX_TYPE.NOTUNIQUE.toString(), null, metadata, new String[]{"nullField"}); for (int i = 0; i < 20; i++) { if (i % 5 == 0) { ODocument document = new ODocument("NullIndexKeysSupport"); @@ -1472,7 +1474,7 @@ public void testNullIndexKeysSupport() { Assert.assertNull(document.field("nullField")); final ODocument explain = databaseDocumentTx.command(new OCommandSQL("explain " + query)).execute(); - Assert.assertTrue(explain.> field("involvedIndexes").contains("NullIndexKeysSupportIndex")); + Assert.assertTrue(explain.>field("involvedIndexes").contains("NullIndexKeysSupportIndex")); } public void testNullHashIndexKeysSupport() { @@ -1486,7 +1488,7 @@ public void testNullHashIndexKeysSupport() { metadata.field("ignoreNullValues", false); clazz.createIndex("NullHashIndexKeysSupportIndex", INDEX_TYPE.NOTUNIQUE.toString(), null, metadata, - new String[] { "nullField" }); + new String[]{"nullField"}); for (int i = 0; i < 20; i++) { if (i % 5 == 0) { ODocument document = new ODocument("NullHashIndexKeysSupport"); @@ -1514,7 +1516,7 @@ public void testNullHashIndexKeysSupport() { Assert.assertNull(document.field("nullField")); final ODocument explain = databaseDocumentTx.command(new OCommandSQL("explain " + query)).execute(); - Assert.assertTrue(explain.> field("involvedIndexes").contains("NullHashIndexKeysSupportIndex")); + Assert.assertTrue(explain.>field("involvedIndexes").contains("NullHashIndexKeysSupportIndex")); } public void testNullIndexKeysSupportInTx() { @@ -1528,7 +1530,7 @@ public void testNullIndexKeysSupportInTx() { metadata.field("ignoreNullValues", false); clazz.createIndex("NullIndexKeysSupportInTxIndex", INDEX_TYPE.NOTUNIQUE.toString(), null, metadata, - new String[] { "nullField" }); + new String[]{"nullField"}); database.begin(); @@ -1561,7 +1563,7 @@ public void testNullIndexKeysSupportInTx() { Assert.assertNull(document.field("nullField")); final ODocument explain = databaseDocumentTx.command(new OCommandSQL("explain " + query)).execute(); - Assert.assertTrue(explain.> field("involvedIndexes").contains("NullIndexKeysSupportInTxIndex")); + Assert.assertTrue(explain.>field("involvedIndexes").contains("NullIndexKeysSupportInTxIndex")); } public void testNullIndexKeysSupportInMiddleTx() { @@ -1578,7 +1580,7 @@ public void testNullIndexKeysSupportInMiddleTx() { metadata.field("ignoreNullValues", false); clazz.createIndex("NullIndexKeysSupportInMiddleTxIndex", INDEX_TYPE.NOTUNIQUE.toString(), null, metadata, - new String[] { "nullField" }); + new String[]{"nullField"}); database.begin(); @@ -1609,7 +1611,7 @@ public void testNullIndexKeysSupportInMiddleTx() { Assert.assertNull(document.field("nullField")); final ODocument explain = databaseDocumentTx.command(new OCommandSQL("explain " + query)).execute(); - Assert.assertTrue(explain.> field("involvedIndexes").contains("NullIndexKeysSupportInMiddleTxIndex")); + Assert.assertTrue(explain.>field("involvedIndexes").contains("NullIndexKeysSupportInMiddleTxIndex")); database.commit(); } @@ -1639,7 +1641,7 @@ public void testCreateIndexAbstractClass() { Assert.assertEquals((Object) resultOne.get(0), (Object) docOne); ODocument explain = databaseDocumentTx.command(new OCommandSQL("explain " + queryOne)).execute(); - Assert.assertTrue(explain.> field("involvedIndexes").contains("TestCreateIndexAbstractClass.value")); + Assert.assertTrue(explain.>field("involvedIndexes").contains("TestCreateIndexAbstractClass.value")); final String queryTwo = "select from TestCreateIndexAbstractClass where value = 'val2'"; @@ -1648,7 +1650,7 @@ public void testCreateIndexAbstractClass() { Assert.assertEquals((Object) resultTwo.get(0), (Object) docTwo); explain = databaseDocumentTx.command(new OCommandSQL("explain " + queryTwo)).execute(); - Assert.assertTrue(explain.> field("involvedIndexes").contains("TestCreateIndexAbstractClass.value")); + Assert.assertTrue(explain.>field("involvedIndexes").contains("TestCreateIndexAbstractClass.value")); } public void testValuesContainerIsRemovedIfIndexIsRemoved() {