Search in sources :

Example 11 with OPropertyMapIndexDefinition

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

the class ClassIndexTest method testCreateOnePropertyByKeyEmbeddedMapIndex.

@Test
public void testCreateOnePropertyByKeyEmbeddedMapIndex() {
    final OIndex result = oClass.createIndex("ClassIndexTestPropertyByKeyEmbeddedMap", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "fEmbeddedMap by key" });
    assertEquals(result.getName(), "ClassIndexTestPropertyByKeyEmbeddedMap");
    assertEquals(oClass.getClassIndex("ClassIndexTestPropertyByKeyEmbeddedMap").getName(), result.getName());
    assertEquals(database.getMetadata().getIndexManager().getClassIndex("ClassIndexTestClass", "ClassIndexTestPropertyByKeyEmbeddedMap").getName(), result.getName());
    final OIndexDefinition indexDefinition = result.getDefinition();
    assertTrue(indexDefinition instanceof OPropertyMapIndexDefinition);
    assertEquals(indexDefinition.getFields().get(0), "fEmbeddedMap");
    assertEquals(indexDefinition.getTypes()[0], OType.STRING);
    assertEquals(((OPropertyMapIndexDefinition) indexDefinition).getIndexBy(), OPropertyMapIndexDefinition.INDEX_BY.KEY);
}
Also used : OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition) OPropertyMapIndexDefinition(com.orientechnologies.orient.core.index.OPropertyMapIndexDefinition) OIndex(com.orientechnologies.orient.core.index.OIndex) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 12 with OPropertyMapIndexDefinition

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

the class SQLCreateIndexTest method testOldStileCreateEmbeddedMapIndex.

@Test
public void testOldStileCreateEmbeddedMapIndex() throws Exception {
    database.command(new OCommandSQL("CREATE INDEX sqlCreateIndexTestClass.prop3 UNIQUE")).execute();
    database.getMetadata().getIndexManager().reload();
    final OIndex<?> index = database.getMetadata().getSchema().getClass("sqlCreateIndexTestClass").getClassIndex("sqlCreateIndexTestClass.prop3");
    Assert.assertNotNull(index);
    final OIndexDefinition indexDefinition = index.getDefinition();
    Assert.assertTrue(indexDefinition instanceof OPropertyMapIndexDefinition);
    Assert.assertEquals(indexDefinition.getFields(), Arrays.asList("prop3"));
    Assert.assertEquals(indexDefinition.getTypes(), new OType[] { OType.STRING });
    Assert.assertEquals(index.getType(), "UNIQUE");
    Assert.assertEquals(((OPropertyMapIndexDefinition) indexDefinition).getIndexBy(), OPropertyMapIndexDefinition.INDEX_BY.KEY);
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition) OPropertyMapIndexDefinition(com.orientechnologies.orient.core.index.OPropertyMapIndexDefinition) Test(org.testng.annotations.Test)

Example 13 with OPropertyMapIndexDefinition

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

the class SQLCreateIndexTest method testCreateEmbeddedMapIndex.

@Test
public void testCreateEmbeddedMapIndex() throws Exception {
    database.command(new OCommandSQL("CREATE INDEX sqlCreateIndexEmbeddedMapIndex ON sqlCreateIndexTestClass (prop3) UNIQUE")).execute();
    database.getMetadata().getIndexManager().reload();
    final OIndex<?> index = database.getMetadata().getSchema().getClass("sqlCreateIndexTestClass").getClassIndex("sqlCreateIndexEmbeddedMapIndex");
    Assert.assertNotNull(index);
    final OIndexDefinition indexDefinition = index.getDefinition();
    Assert.assertTrue(indexDefinition instanceof OPropertyMapIndexDefinition);
    Assert.assertEquals(indexDefinition.getFields(), Arrays.asList("prop3"));
    Assert.assertEquals(indexDefinition.getTypes(), new OType[] { OType.STRING });
    Assert.assertEquals(index.getType(), "UNIQUE");
    Assert.assertEquals(((OPropertyMapIndexDefinition) indexDefinition).getIndexBy(), OPropertyMapIndexDefinition.INDEX_BY.KEY);
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition) OPropertyMapIndexDefinition(com.orientechnologies.orient.core.index.OPropertyMapIndexDefinition) Test(org.testng.annotations.Test)

Aggregations

OIndexDefinition (com.orientechnologies.orient.core.index.OIndexDefinition)13 OPropertyMapIndexDefinition (com.orientechnologies.orient.core.index.OPropertyMapIndexDefinition)13 Test (org.testng.annotations.Test)12 OIndex (com.orientechnologies.orient.core.index.OIndex)8 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)6 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)4 OCompositeIndexDefinition (com.orientechnologies.orient.core.index.OCompositeIndexDefinition)3 OPropertyIndexDefinition (com.orientechnologies.orient.core.index.OPropertyIndexDefinition)2 OPropertyListIndexDefinition (com.orientechnologies.orient.core.index.OPropertyListIndexDefinition)2 OPropertyRidBagIndexDefinition (com.orientechnologies.orient.core.index.OPropertyRidBagIndexDefinition)2 HashSet (java.util.HashSet)2 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)1 OIndexCursor (com.orientechnologies.orient.core.index.OIndexCursor)1 OIndexCursorCollectionValue (com.orientechnologies.orient.core.index.OIndexCursorCollectionValue)1 OIndexCursorSingleValue (com.orientechnologies.orient.core.index.OIndexCursorSingleValue)1 OIndexDefinitionMultiValue (com.orientechnologies.orient.core.index.OIndexDefinitionMultiValue)1