use of com.orientechnologies.orient.core.index.OIndexDefinition in project orientdb by orientechnologies.
the class SQLCreateIndexTest method testCreateOldStileEmbeddedListIndex.
public void testCreateOldStileEmbeddedListIndex() throws Exception {
database.command(new OCommandSQL("CREATE INDEX sqlCreateIndexTestClass.prop5 NOTUNIQUE")).execute();
database.getMetadata().getIndexManager().reload();
final OIndex<?> index = database.getMetadata().getSchema().getClass("sqlCreateIndexTestClass").getClassIndex("sqlCreateIndexTestClass.prop5");
Assert.assertNotNull(index);
final OIndexDefinition indexDefinition = index.getDefinition();
Assert.assertTrue(indexDefinition instanceof OPropertyListIndexDefinition);
Assert.assertEquals(indexDefinition.getFields(), Arrays.asList("prop5"));
Assert.assertEquals(indexDefinition.getTypes(), new OType[] { OType.INTEGER });
Assert.assertEquals(index.getType(), "NOTUNIQUE");
}
use of com.orientechnologies.orient.core.index.OIndexDefinition in project orientdb by orientechnologies.
the class SQLCreateIndexTest method testCreateEmbeddedMapByValueIndex.
@Test
public void testCreateEmbeddedMapByValueIndex() throws Exception {
database.command(new OCommandSQL("CREATE INDEX sqlCreateIndexEmbeddedMapByValueIndex ON sqlCreateIndexTestClass (prop3 by value) UNIQUE")).execute();
database.getMetadata().getIndexManager().reload();
final OIndex<?> index = database.getMetadata().getSchema().getClass("sqlCreateIndexTestClass").getClassIndex("sqlCreateIndexEmbeddedMapByValueIndex");
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.INTEGER });
Assert.assertEquals(index.getType(), "UNIQUE");
Assert.assertEquals(((OPropertyMapIndexDefinition) indexDefinition).getIndexBy(), OPropertyMapIndexDefinition.INDEX_BY.VALUE);
}
use of com.orientechnologies.orient.core.index.OIndexDefinition in project orientdb by orientechnologies.
the class SQLCreateIndexTest method testCompositeIndexWithMetadata.
public void testCompositeIndexWithMetadata() {
database.command(new OCommandSQL("CREATE INDEX sqlCreateIndexCompositeIndexWithMetadata ON sqlCreateIndexTestClass (prop1, prop2) UNIQUE" + " metadata {v1:23, v2:\"val2\"}")).execute();
database.getMetadata().getIndexManager().reload();
final OIndex<?> index = database.getMetadata().getSchema().getClass("sqlCreateIndexTestClass").getClassIndex("sqlCreateIndexCompositeIndexWithMetadata");
Assert.assertNotNull(index);
final OIndexDefinition indexDefinition = index.getDefinition();
Assert.assertTrue(indexDefinition instanceof OCompositeIndexDefinition);
Assert.assertEquals(indexDefinition.getFields(), Arrays.asList("prop1", "prop2"));
Assert.assertEquals(indexDefinition.getTypes(), new OType[] { EXPECTED_PROP1_TYPE, EXPECTED_PROP2_TYPE });
Assert.assertEquals(index.getType(), "UNIQUE");
ODocument metadata = index.getMetadata();
Assert.assertEquals(metadata.field("v1"), 23);
Assert.assertEquals(metadata.field("v2"), "val2");
}
use of com.orientechnologies.orient.core.index.OIndexDefinition in project orientdb by orientechnologies.
the class SQLCreateIndexTest method testCreateEmbeddedMapByKeyIndex.
@Test
public void testCreateEmbeddedMapByKeyIndex() throws Exception {
database.command(new OCommandSQL("CREATE INDEX sqlCreateIndexEmbeddedMapByKeyIndex ON sqlCreateIndexTestClass (prop3 by key) UNIQUE")).execute();
database.getMetadata().getIndexManager().reload();
final OIndex<?> index = database.getMetadata().getSchema().getClass("sqlCreateIndexTestClass").getClassIndex("sqlCreateIndexEmbeddedMapByKeyIndex");
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);
}
use of com.orientechnologies.orient.core.index.OIndexDefinition in project orientdb by orientechnologies.
the class SQLCreateIndexTest method testCreateOldStileRidBagIndex.
public void testCreateOldStileRidBagIndex() throws Exception {
database.command(new OCommandSQL("CREATE INDEX sqlCreateIndexTestClass.prop9 NOTUNIQUE")).execute();
database.getMetadata().getIndexManager().reload();
final OIndex<?> index = database.getMetadata().getSchema().getClass("sqlCreateIndexTestClass").getClassIndex("sqlCreateIndexTestClass.prop9");
Assert.assertNotNull(index);
final OIndexDefinition indexDefinition = index.getDefinition();
Assert.assertTrue(indexDefinition instanceof OPropertyRidBagIndexDefinition);
Assert.assertEquals(indexDefinition.getFields(), Arrays.asList("prop9"));
Assert.assertEquals(indexDefinition.getTypes(), new OType[] { OType.LINK });
Assert.assertEquals(index.getType(), "NOTUNIQUE");
}
Aggregations