Search in sources :

Example 21 with OCompositeIndexDefinition

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

the class ClassIndexTest method testCreateCompositeEmbeddedMapIndex.

@Test
public void testCreateCompositeEmbeddedMapIndex() {
    final OIndex result = oClass.createIndex("ClassIndexTestCompositeEmbeddedMap", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "fFifteen", "fEmbeddedMap" });
    assertEquals(result.getName(), "ClassIndexTestCompositeEmbeddedMap");
    assertEquals(oClass.getClassIndex("ClassIndexTestCompositeEmbeddedMap").getName(), result.getName());
    assertEquals(database.getMetadata().getIndexManager().getClassIndex("ClassIndexTestClass", "ClassIndexTestCompositeEmbeddedMap").getName(), result.getName());
    final OIndexDefinition indexDefinition = result.getDefinition();
    assertTrue(indexDefinition instanceof OCompositeIndexDefinition);
    assertEquals(indexDefinition.getFields().toArray(), new String[] { "fFifteen", "fEmbeddedMap" });
    assertEquals(indexDefinition.getTypes(), new OType[] { OType.INTEGER, OType.STRING });
    assertEquals(indexDefinition.getParamCount(), 2);
}
Also used : OCompositeIndexDefinition(com.orientechnologies.orient.core.index.OCompositeIndexDefinition) OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition) OIndex(com.orientechnologies.orient.core.index.OIndex) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 22 with OCompositeIndexDefinition

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

the class ClassIndexTest method testCreateCompositeEmbeddedMapByKeyIndex.

@Test
public void testCreateCompositeEmbeddedMapByKeyIndex() {
    final OIndex result = oClass.createIndex("ClassIndexTestCompositeEmbeddedMapByKey", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "fEight", "fEmbeddedMap" });
    assertEquals(result.getName(), "ClassIndexTestCompositeEmbeddedMapByKey");
    assertEquals(oClass.getClassIndex("ClassIndexTestCompositeEmbeddedMapByKey").getName(), result.getName());
    assertEquals(database.getMetadata().getIndexManager().getClassIndex("ClassIndexTestClass", "ClassIndexTestCompositeEmbeddedMapByKey").getName(), result.getName());
    final OIndexDefinition indexDefinition = result.getDefinition();
    assertTrue(indexDefinition instanceof OCompositeIndexDefinition);
    assertEquals(indexDefinition.getFields().toArray(), new String[] { "fEight", "fEmbeddedMap" });
    assertEquals(indexDefinition.getTypes(), new OType[] { OType.INTEGER, OType.STRING });
    assertEquals(indexDefinition.getParamCount(), 2);
}
Also used : OCompositeIndexDefinition(com.orientechnologies.orient.core.index.OCompositeIndexDefinition) OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition) OIndex(com.orientechnologies.orient.core.index.OIndex) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 23 with OCompositeIndexDefinition

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

the class ClassIndexTest method testCreateCompositeLinkSetIndex.

@Test(dependsOnMethods = "testGetIndexes")
public void testCreateCompositeLinkSetIndex() {
    final OIndex result = oClass.createIndex("ClassIndexTestCompositeLinkSet", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "fTwelve", "fLinkSet" });
    assertEquals(result.getName(), "ClassIndexTestCompositeLinkSet");
    assertEquals(oClass.getClassIndex("ClassIndexTestCompositeLinkSet").getName(), result.getName());
    assertEquals(database.getMetadata().getIndexManager().getClassIndex("ClassIndexTestClass", "ClassIndexTestCompositeLinkSet").getName(), result.getName());
    final OIndexDefinition indexDefinition = result.getDefinition();
    assertTrue(indexDefinition instanceof OCompositeIndexDefinition);
    assertEquals(indexDefinition.getFields().toArray(), new String[] { "fTwelve", "fLinkSet" });
    assertEquals(indexDefinition.getTypes(), new OType[] { OType.INTEGER, OType.LINK });
    assertEquals(indexDefinition.getParamCount(), 2);
}
Also used : OCompositeIndexDefinition(com.orientechnologies.orient.core.index.OCompositeIndexDefinition) OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition) OIndex(com.orientechnologies.orient.core.index.OIndex) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 24 with OCompositeIndexDefinition

use of com.orientechnologies.orient.core.index.OCompositeIndexDefinition 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 25 with OCompositeIndexDefinition

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

the class IndexManagerTest method createCompositeIndexTestWithoutListener.

@Test
public void createCompositeIndexTestWithoutListener() {
    final OIndexManagerProxy indexManager = database.getMetadata().getIndexManager();
    final OIndex result = indexManager.createIndex("compositeone", OClass.INDEX_TYPE.NOTUNIQUE.toString(), new OCompositeIndexDefinition(CLASS_NAME, Arrays.asList(new OPropertyIndexDefinition(CLASS_NAME, "fOne", OType.INTEGER), new OPropertyIndexDefinition(CLASS_NAME, "fTwo", OType.STRING)), -1), new int[] { database.getClusterIdByName(CLASS_NAME) }, null, null);
    assertEquals(result.getName(), "compositeone");
    indexManager.reload();
    assertEquals(database.getMetadata().getIndexManager().getClassIndex(CLASS_NAME, "compositeone").getName(), result.getName());
}
Also used : OCompositeIndexDefinition(com.orientechnologies.orient.core.index.OCompositeIndexDefinition) OPropertyIndexDefinition(com.orientechnologies.orient.core.index.OPropertyIndexDefinition) OIndex(com.orientechnologies.orient.core.index.OIndex) OIndexManagerProxy(com.orientechnologies.orient.core.index.OIndexManagerProxy) Test(org.testng.annotations.Test)

Aggregations

OCompositeIndexDefinition (com.orientechnologies.orient.core.index.OCompositeIndexDefinition)29 OIndexDefinition (com.orientechnologies.orient.core.index.OIndexDefinition)26 OIndex (com.orientechnologies.orient.core.index.OIndex)16 Test (org.testng.annotations.Test)16 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)11 OIndexCursor (com.orientechnologies.orient.core.index.OIndexCursor)7 OPropertyIndexDefinition (com.orientechnologies.orient.core.index.OPropertyIndexDefinition)7 OIndexDefinitionMultiValue (com.orientechnologies.orient.core.index.OIndexDefinitionMultiValue)6 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)6 HashSet (java.util.HashSet)4 OIndexManager (com.orientechnologies.orient.core.index.OIndexManager)3 OPropertyMapIndexDefinition (com.orientechnologies.orient.core.index.OPropertyMapIndexDefinition)3 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)2 OCommandExecutionException (com.orientechnologies.orient.core.exception.OCommandExecutionException)2 OIndexCursorCollectionValue (com.orientechnologies.orient.core.index.OIndexCursorCollectionValue)2 OIndexCursorSingleValue (com.orientechnologies.orient.core.index.OIndexCursorSingleValue)2 OIndexManagerProxy (com.orientechnologies.orient.core.index.OIndexManagerProxy)2 OPropertyListIndexDefinition (com.orientechnologies.orient.core.index.OPropertyListIndexDefinition)2 OPropertyRidBagIndexDefinition (com.orientechnologies.orient.core.index.OPropertyRidBagIndexDefinition)2 OProgressListener (com.orientechnologies.common.listener.OProgressListener)1