use of com.orientechnologies.orient.core.index.OPropertyIndexDefinition in project orientdb by orientechnologies.
the class IndexManagerTest method createCompositeIndexTestWithListener.
@Test
public void createCompositeIndexTestWithListener() {
final AtomicInteger atomicInteger = new AtomicInteger(0);
final OProgressListener progressListener = new OProgressListener() {
@Override
public void onBegin(final Object iTask, final long iTotal, Object metadata) {
atomicInteger.incrementAndGet();
}
@Override
public boolean onProgress(final Object iTask, final long iCounter, final float iPercent) {
return true;
}
@Override
public void onCompletition(final Object iTask, final boolean iSucceed) {
atomicInteger.incrementAndGet();
}
};
final OIndexManagerProxy indexManager = database.getMetadata().getIndexManager();
final OIndex result = indexManager.createIndex("compositetwo", 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), new OPropertyIndexDefinition(CLASS_NAME, "fThree", OType.BOOLEAN)), -1), new int[] { database.getClusterIdByName(CLASS_NAME) }, progressListener, null);
assertEquals(result.getName(), "compositetwo");
assertEquals(atomicInteger.get(), 2);
indexManager.reload();
assertEquals(database.getMetadata().getIndexManager().getClassIndex(CLASS_NAME, "compositetwo").getName(), result.getName());
}
use of com.orientechnologies.orient.core.index.OPropertyIndexDefinition 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());
}
use of com.orientechnologies.orient.core.index.OPropertyIndexDefinition in project orientdb by orientechnologies.
the class IndexManagerTest method testDropAllClassIndexes.
@Test
public void testDropAllClassIndexes() {
final OClass oClass = database.getMetadata().getSchema().createClass("indexManagerTestClassTwo");
oClass.createProperty("fOne", OType.INTEGER);
final OIndexManager indexManager = database.getMetadata().getIndexManager();
indexManager.createIndex("twoclassproperty", OClass.INDEX_TYPE.UNIQUE.toString(), new OPropertyIndexDefinition("indexManagerTestClassTwo", "fOne", OType.INTEGER), new int[] { database.getClusterIdByName("indexManagerTestClassTwo") }, null, null);
assertFalse(indexManager.getClassIndexes("indexManagerTestClassTwo").isEmpty());
indexManager.dropIndex("twoclassproperty");
assertTrue(indexManager.getClassIndexes("indexManagerTestClassTwo").isEmpty());
}
use of com.orientechnologies.orient.core.index.OPropertyIndexDefinition 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.OPropertyIndexDefinition in project orientdb by orientechnologies.
the class IndexManagerTest method testGetClassIndexesBrokenClassNameCase.
@Test(dependsOnMethods = { "createCompositeIndexTestWithListener", "createCompositeIndexTestWithoutListener", "testCreateOnePropertyIndexTest" })
public void testGetClassIndexesBrokenClassNameCase() {
final OIndexManager indexManager = database.getMetadata().getIndexManager();
final Set<OIndex<?>> indexes = indexManager.getClassIndexes("ClassforindeXMaNAgerTeST");
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()));
}
}
Aggregations