Search in sources :

Example 16 with OIndexDefinition

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");
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition) OPropertyListIndexDefinition(com.orientechnologies.orient.core.index.OPropertyListIndexDefinition)

Example 17 with OIndexDefinition

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);
}
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 18 with OIndexDefinition

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");
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OCompositeIndexDefinition(com.orientechnologies.orient.core.index.OCompositeIndexDefinition) OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 19 with OIndexDefinition

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);
}
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 20 with OIndexDefinition

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");
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OPropertyRidBagIndexDefinition(com.orientechnologies.orient.core.index.OPropertyRidBagIndexDefinition) OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition)

Aggregations

OIndexDefinition (com.orientechnologies.orient.core.index.OIndexDefinition)67 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)29 OCompositeIndexDefinition (com.orientechnologies.orient.core.index.OCompositeIndexDefinition)26 OIndex (com.orientechnologies.orient.core.index.OIndex)26 Test (org.testng.annotations.Test)25 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)18 OPropertyMapIndexDefinition (com.orientechnologies.orient.core.index.OPropertyMapIndexDefinition)13 OIndexCursor (com.orientechnologies.orient.core.index.OIndexCursor)8 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)7 OIndexDefinitionMultiValue (com.orientechnologies.orient.core.index.OIndexDefinitionMultiValue)6 OIndexUnique (com.orientechnologies.orient.core.index.OIndexUnique)6 OPropertyIndexDefinition (com.orientechnologies.orient.core.index.OPropertyIndexDefinition)6 OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)5 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)4 OPropertyListIndexDefinition (com.orientechnologies.orient.core.index.OPropertyListIndexDefinition)4 OPropertyRidBagIndexDefinition (com.orientechnologies.orient.core.index.OPropertyRidBagIndexDefinition)4 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)4 HashSet (java.util.HashSet)4 ConsoleCommand (com.orientechnologies.common.console.annotation.ConsoleCommand)3 OSystemException (com.orientechnologies.common.exception.OSystemException)3