Search in sources :

Example 31 with OIndexManager

use of com.orientechnologies.orient.core.index.OIndexManager in project orientdb by orientechnologies.

the class IndexManagerTest method testAreIndexedPropertiesMoreThanNeeded.

@Test(dependsOnMethods = { "createCompositeIndexTestWithListener", "createCompositeIndexTestWithoutListener", "testCreateOnePropertyIndexTest" })
public void testAreIndexedPropertiesMoreThanNeeded() {
    final OIndexManager indexManager = database.getMetadata().getIndexManager();
    final boolean result = indexManager.areIndexed(CLASS_NAME, Arrays.asList("fTwo", "fOne", "fThee", "fFour"));
    assertFalse(result);
}
Also used : OIndexManager(com.orientechnologies.orient.core.index.OIndexManager) Test(org.testng.annotations.Test)

Example 32 with OIndexManager

use of com.orientechnologies.orient.core.index.OIndexManager in project orientdb by orientechnologies.

the class IndexManagerTest method testAreIndexedPropertiesNotFirstArrayParams.

@Test(dependsOnMethods = { "createCompositeIndexTestWithListener", "createCompositeIndexTestWithoutListener", "testCreateOnePropertyIndexTest" })
public void testAreIndexedPropertiesNotFirstArrayParams() {
    final OIndexManager indexManager = database.getMetadata().getIndexManager();
    final boolean result = indexManager.areIndexed(CLASS_NAME, "fTwo", "fTree");
    assertFalse(result);
}
Also used : OIndexManager(com.orientechnologies.orient.core.index.OIndexManager) Test(org.testng.annotations.Test)

Example 33 with OIndexManager

use of com.orientechnologies.orient.core.index.OIndexManager in project orientdb by orientechnologies.

the class IndexManagerTest method testGetClassInvolvedIndexesNotInvolvedPropertiesArrayParams.

@Test(dependsOnMethods = { "createCompositeIndexTestWithListener", "createCompositeIndexTestWithoutListener", "testCreateOnePropertyIndexTest" })
public void testGetClassInvolvedIndexesNotInvolvedPropertiesArrayParams() {
    final OIndexManager indexManager = database.getMetadata().getIndexManager();
    final Set<OIndex<?>> result = indexManager.getClassInvolvedIndexes(CLASS_NAME, "fTwo", "fFour");
    assertEquals(result.size(), 0);
}
Also used : OIndexManager(com.orientechnologies.orient.core.index.OIndexManager) OIndex(com.orientechnologies.orient.core.index.OIndex) Test(org.testng.annotations.Test)

Example 34 with OIndexManager

use of com.orientechnologies.orient.core.index.OIndexManager in project orientdb by orientechnologies.

the class IndexManagerTest method testGetClassIndexes.

@Test(dependsOnMethods = { "createCompositeIndexTestWithListener", "createCompositeIndexTestWithoutListener", "testCreateOnePropertyIndexTest" })
public void testGetClassIndexes() {
    final OIndexManager indexManager = database.getMetadata().getIndexManager();
    final Set<OIndex<?>> indexes = indexManager.getClassIndexes(CLASS_NAME);
    final Set<OIndexDefinition> expectedIndexDefinitions = new HashSet<OIndexDefinition>();
    final OCompositeIndexDefinition compositeIndexOne = new OCompositeIndexDefinition(CLASS_NAME);
    compositeIndexOne.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER));
    compositeIndexOne.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fTwo", OType.STRING));
    compositeIndexOne.setNullValuesIgnored(false);
    expectedIndexDefinitions.add(compositeIndexOne);
    final OCompositeIndexDefinition compositeIndexTwo = new OCompositeIndexDefinition(CLASS_NAME);
    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));
    compositeIndexTwo.setNullValuesIgnored(false);
    expectedIndexDefinitions.add(compositeIndexTwo);
    final OPropertyIndexDefinition propertyIndex = new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER);
    propertyIndex.setNullValuesIgnored(false);
    expectedIndexDefinitions.add(propertyIndex);
    assertEquals(indexes.size(), 3);
    for (final OIndex index : indexes) {
        assertTrue(expectedIndexDefinitions.contains(index.getDefinition()));
    }
}
Also used : OIndexManager(com.orientechnologies.orient.core.index.OIndexManager) OCompositeIndexDefinition(com.orientechnologies.orient.core.index.OCompositeIndexDefinition) OPropertyIndexDefinition(com.orientechnologies.orient.core.index.OPropertyIndexDefinition) OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition) OIndex(com.orientechnologies.orient.core.index.OIndex) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 35 with OIndexManager

use of com.orientechnologies.orient.core.index.OIndexManager in project orientdb by orientechnologies.

the class IndexManagerTest method testGetClassIndexesBrokenClassNameCase.

@Test(dependsOnMethods = { "createCompositeIndexTestWithListener", "createCompositeIndexTestWithoutListener", "testCreateOnePropertyIndexTest" })
public void testGetClassIndexesBrokenClassNameCase() {
    final OIndexManager indexManager = database.getMetadata().getIndexManager();
    final Set<OIndex<?>> indexes = indexManager.getClassIndexes("ClassforindeXMaNAgerTeST");
    final Set<OIndexDefinition> expectedIndexDefinitions = new HashSet<OIndexDefinition>();
    final OCompositeIndexDefinition compositeIndexOne = new OCompositeIndexDefinition(CLASS_NAME);
    compositeIndexOne.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER));
    compositeIndexOne.addIndex(new OPropertyIndexDefinition(CLASS_NAME, "fTwo", OType.STRING));
    compositeIndexOne.setNullValuesIgnored(false);
    expectedIndexDefinitions.add(compositeIndexOne);
    final OCompositeIndexDefinition compositeIndexTwo = new OCompositeIndexDefinition(CLASS_NAME);
    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));
    compositeIndexTwo.setNullValuesIgnored(false);
    expectedIndexDefinitions.add(compositeIndexTwo);
    final OPropertyIndexDefinition propertyIndex = new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER);
    propertyIndex.setNullValuesIgnored(false);
    expectedIndexDefinitions.add(propertyIndex);
    assertEquals(indexes.size(), 3);
    for (final OIndex index : indexes) {
        assertTrue(expectedIndexDefinitions.contains(index.getDefinition()));
    }
}
Also used : OIndexManager(com.orientechnologies.orient.core.index.OIndexManager) OCompositeIndexDefinition(com.orientechnologies.orient.core.index.OCompositeIndexDefinition) OPropertyIndexDefinition(com.orientechnologies.orient.core.index.OPropertyIndexDefinition) OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition) OIndex(com.orientechnologies.orient.core.index.OIndex) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

OIndexManager (com.orientechnologies.orient.core.index.OIndexManager)46 Test (org.testng.annotations.Test)40 OIndex (com.orientechnologies.orient.core.index.OIndex)18 OPropertyIndexDefinition (com.orientechnologies.orient.core.index.OPropertyIndexDefinition)5 OCompositeIndexDefinition (com.orientechnologies.orient.core.index.OCompositeIndexDefinition)3 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)3 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)2 OIndexDefinition (com.orientechnologies.orient.core.index.OIndexDefinition)2 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)2 HashSet (java.util.HashSet)2 OException (com.orientechnologies.common.exception.OException)1 OCommandCacheSoftRefs (com.orientechnologies.orient.core.cache.OCommandCacheSoftRefs)1 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)1 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)1 ORecordOperation (com.orientechnologies.orient.core.db.record.ORecordOperation)1 OSecurityException (com.orientechnologies.orient.core.exception.OSecurityException)1 OTransactionException (com.orientechnologies.orient.core.exception.OTransactionException)1 ORID (com.orientechnologies.orient.core.id.ORID)1 ORecordId (com.orientechnologies.orient.core.id.ORecordId)1 OIndexKeyCursor (com.orientechnologies.orient.core.index.OIndexKeyCursor)1