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);
}
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);
}
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);
}
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()));
}
}
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());
}
Aggregations