Search in sources :

Example 1 with OIndexDefinition

use of com.orientechnologies.orient.core.index.OIndexDefinition in project wicket-orientdb by OrienteerBAP.

the class OIndexModel method handleObject.

@Override
protected void handleObject(OIndex<?> object) {
    indexName = object.getName();
    OIndexDefinition indexDefinition = object.getDefinition();
    if (indexDefinition != null) {
        String className = indexDefinition.getClassName();
        if (className != null)
            classModel = new OClassModel(className);
    }
}
Also used : OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition)

Example 2 with OIndexDefinition

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

the class OChainedIndexProxyFindBestIndexTest method mockUniqueCompositeHashIndexWithNullSupport.

private OIndexUnique mockUniqueCompositeHashIndexWithNullSupport() {
    final OIndexUnique uniqueIndex = mock(OIndexUnique.class);
    when(uniqueIndex.getInternal()).thenReturn(uniqueIndex);
    final OIndexDefinition definition = mock(OIndexDefinition.class);
    when(definition.getParamCount()).thenReturn(2);
    when(uniqueIndex.getDefinition()).thenReturn(definition);
    when(uniqueIndex.getType()).thenReturn(OClass.INDEX_TYPE.UNIQUE_HASH_INDEX.toString());
    when(uniqueIndex.getMetadata()).thenReturn(new ODocument().field("ignoreNullValues", false));
    return uniqueIndex;
}
Also used : OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition) OIndexUnique(com.orientechnologies.orient.core.index.OIndexUnique) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 3 with OIndexDefinition

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

the class OChainedIndexProxyFindBestIndexTest method mockUniqueIndex.

private OIndexUnique mockUniqueIndex() {
    final OIndexUnique uniqueIndex = mock(OIndexUnique.class);
    when(uniqueIndex.getInternal()).thenReturn(uniqueIndex);
    final OIndexDefinition definition = mock(OIndexDefinition.class);
    when(definition.getParamCount()).thenReturn(1);
    when(uniqueIndex.getDefinition()).thenReturn(definition);
    when(uniqueIndex.getType()).thenReturn(OClass.INDEX_TYPE.UNIQUE.toString());
    return uniqueIndex;
}
Also used : OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition) OIndexUnique(com.orientechnologies.orient.core.index.OIndexUnique)

Example 4 with OIndexDefinition

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

the class SQLIndexWithoutSchemaTest method testCreateIndex.

@Test
public void testCreateIndex() {
    database.command(new OCommandSQL("CREATE INDEX indexWithoutSchema ON " + TEST_CLASS + " (prop2) NOTUNIQUE INTEGER")).execute();
    database.getMetadata().getIndexManager().reload();
    final OIndex<?> index = database.getMetadata().getSchema().getClass(TEST_CLASS).getClassIndex("indexWithoutSchema");
    Assert.assertNotNull(index);
    Assert.assertEquals(index.getType(), OClass.INDEX_TYPE.NOTUNIQUE.name());
    final OIndexDefinition definition = index.getDefinition();
    Assert.assertEquals(definition.getFields().size(), 1);
    Assert.assertEquals(definition.getFields().get(0).toLowerCase(Locale.ENGLISH), "prop2");
    Assert.assertEquals(definition.getTypes()[0], OType.INTEGER);
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition)

Example 5 with OIndexDefinition

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

the class SQLIndexWithoutSchemaTest method testCreateCompositeIndex.

@Test
public void testCreateCompositeIndex() {
    database.command(new OCommandSQL("CREATE INDEX compositeIndexWithoutSchema ON " + TEST_CLASS + " (cp2, cp3) NOTUNIQUE INTEGER, INTEGER METADATA { ignoreNullValues: true }")).execute();
    database.getMetadata().getIndexManager().reload();
    final OIndex<?> index = database.getMetadata().getSchema().getClass(TEST_CLASS).getClassIndex("compositeIndexWithoutSchema");
    Assert.assertNotNull(index);
    Assert.assertEquals(index.getType(), OClass.INDEX_TYPE.NOTUNIQUE.name());
    final OIndexDefinition definition = index.getDefinition();
    Assert.assertEquals(definition.getFields().size(), 2);
    Assert.assertEquals(definition.getFields().get(0).toLowerCase(Locale.ENGLISH), "cp2");
    Assert.assertEquals(definition.getFields().get(1).toLowerCase(Locale.ENGLISH), "cp3");
    Assert.assertEquals(definition.getTypes()[0], OType.INTEGER);
    Assert.assertEquals(definition.getTypes()[1], OType.INTEGER);
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OIndexDefinition(com.orientechnologies.orient.core.index.OIndexDefinition)

Aggregations

OIndexDefinition (com.orientechnologies.orient.core.index.OIndexDefinition)68 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