Search in sources :

Example 86 with OSchema

use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.

the class IndexManagerTest method testGetClassInvolvedIndexesWithNullValues.

@Test
public void testGetClassInvolvedIndexesWithNullValues() {
    String className = "GetClassInvolvedIndexesWithNullValues";
    final OIndexManager indexManager = database.getMetadata().getIndexManager();
    final OSchema schema = database.getMetadata().getSchema();
    final OClass oClass = schema.createClass(className);
    oClass.createProperty("one", OType.STRING);
    oClass.createProperty("two", OType.STRING);
    oClass.createProperty("three", OType.STRING);
    indexManager.createIndex(className + "_indexOne_notunique", OClass.INDEX_TYPE.NOTUNIQUE.toString(), new OPropertyIndexDefinition(className, "one", OType.STRING), oClass.getClusterIds(), null, null);
    indexManager.createIndex(className + "_indexOneTwo_notunique", OClass.INDEX_TYPE.NOTUNIQUE.toString(), new OCompositeIndexDefinition(className, Arrays.asList(new OPropertyIndexDefinition(className, "one", OType.STRING), new OPropertyIndexDefinition(className, "two", OType.STRING)), -1), oClass.getClusterIds(), null, null);
    indexManager.createIndex(className + "_indexOneTwoThree_notunique", OClass.INDEX_TYPE.NOTUNIQUE.toString(), new OCompositeIndexDefinition(className, Arrays.asList(new OPropertyIndexDefinition(className, "one", OType.STRING), new OPropertyIndexDefinition(className, "two", OType.STRING), new OPropertyIndexDefinition(className, "three", OType.STRING)), -1), oClass.getClusterIds(), null, null);
    Set<OIndex<?>> result = indexManager.getClassInvolvedIndexes(className, Arrays.asList("one"));
    assertEquals(result.size(), 3);
    result = indexManager.getClassInvolvedIndexes(className, Arrays.asList("one", "two"));
    assertEquals(result.size(), 2);
    result = indexManager.getClassInvolvedIndexes(className, Arrays.asList("one", "two", "three"));
    assertEquals(result.size(), 1);
    result = indexManager.getClassInvolvedIndexes(className, Arrays.asList("two"));
    assertEquals(result.size(), 0);
    result = indexManager.getClassInvolvedIndexes(className, Arrays.asList("two", "one", "three"));
    assertEquals(result.size(), 1);
}
Also used : OIndexManager(com.orientechnologies.orient.core.index.OIndexManager) OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OPropertyIndexDefinition(com.orientechnologies.orient.core.index.OPropertyIndexDefinition) OCompositeIndexDefinition(com.orientechnologies.orient.core.index.OCompositeIndexDefinition) OIndex(com.orientechnologies.orient.core.index.OIndex) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) Test(org.testng.annotations.Test)

Example 87 with OSchema

use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.

the class IndexManagerTest method beforeClass.

@BeforeClass
public void beforeClass() throws Exception {
    super.beforeClass();
    final OSchema schema = database.getMetadata().getSchema();
    final OClass oClass = schema.createClass(CLASS_NAME);
    oClass.createProperty("fOne", OType.INTEGER);
    oClass.createProperty("fTwo", OType.STRING);
    oClass.createProperty("fThree", OType.BOOLEAN);
    oClass.createProperty("fFour", OType.INTEGER);
    oClass.createProperty("fSix", OType.STRING);
    oClass.createProperty("fSeven", OType.STRING);
}
Also used : OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) BeforeClass(org.testng.annotations.BeforeClass)

Example 88 with OSchema

use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.

the class SQLDropClassIndexTest method beforeClass.

@BeforeClass
public void beforeClass() {
    database = new ODatabaseDocumentTx(url);
    if (database.isClosed())
        database.open("admin", "admin");
    final OSchema schema = database.getMetadata().getSchema();
    final OClass oClass = schema.createClass("SQLDropClassTestClass");
    oClass.createProperty("prop1", EXPECTED_PROP1_TYPE);
    oClass.createProperty("prop2", EXPECTED_PROP2_TYPE);
    schema.save();
    database.close();
}
Also used : OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)

Example 89 with OSchema

use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.

the class SQLDropIndexTest method beforeClass.

@BeforeClass
public void beforeClass() {
    database = new ODatabaseDocumentTx(url);
    if (database.isClosed())
        database.open("admin", "admin");
    final OSchema schema = database.getMetadata().getSchema();
    final OClass oClass = schema.createClass("SQLDropIndexTestClass");
    oClass.createProperty("prop1", EXPECTED_PROP1_TYPE);
    oClass.createProperty("prop2", EXPECTED_PROP2_TYPE);
    schema.save();
}
Also used : OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)

Example 90 with OSchema

use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.

the class SQLSelectByLinkedPropertyIndexReuseTest method createSchemaForTest.

private void createSchemaForTest() {
    final OSchema schema = database.getMetadata().getSchema();
    if (!schema.existsClass("lpirtStudent")) {
        final OClass curatorClass = schema.createClass("lpirtCurator");
        curatorClass.createProperty("name", OType.STRING).createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
        curatorClass.createProperty("salary", OType.INTEGER).createIndex(OClass.INDEX_TYPE.UNIQUE, new ODocument().field("ignoreNullValues", true));
        curatorClass.createIndex("curotorCompositeIndex", OClass.INDEX_TYPE.UNIQUE.name(), null, new ODocument().field("ignoreNullValues", true), new String[] { "salary", "name" });
        final OClass groupClass = schema.createClass("lpirtGroup");
        groupClass.createProperty("name", OType.STRING).createIndex(OClass.INDEX_TYPE.UNIQUE, new ODocument().field("ignoreNullValues", true));
        groupClass.createProperty("curator", OType.LINK, curatorClass).createIndex(OClass.INDEX_TYPE.UNIQUE, new ODocument().field("ignoreNullValues", true));
        final OClass diplomaClass = schema.createClass("lpirtDiploma");
        diplomaClass.createProperty("GPA", OType.DOUBLE).createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
        diplomaClass.createProperty("thesis", OType.STRING).createIndex(OClass.INDEX_TYPE.FULLTEXT);
        diplomaClass.createProperty("name", OType.STRING).createIndex(OClass.INDEX_TYPE.UNIQUE, new ODocument().field("ignoreNullValues", true));
        diplomaClass.createIndex("diplomaThesisUnique", OClass.INDEX_TYPE.UNIQUE.name(), null, new ODocument().field("ignoreNullValues", true), new String[] { "thesis" });
        final OClass transcriptClass = schema.createClass("lpirtTranscript");
        transcriptClass.createProperty("id", OType.STRING).createIndex(OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, new ODocument().field("ignoreNullValues", true));
        final OClass skillClass = schema.createClass("lpirtSkill");
        skillClass.createProperty("name", OType.STRING).createIndex(OClass.INDEX_TYPE.UNIQUE, new ODocument().field("ignoreNullValues", true));
        final OClass studentClass = schema.createClass("lpirtStudent");
        studentClass.createProperty("name", OType.STRING).createIndex(OClass.INDEX_TYPE.UNIQUE, new ODocument().field("ignoreNullValues", true));
        studentClass.createProperty("group", OType.LINK, groupClass).createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
        studentClass.createProperty("diploma", OType.LINK, diplomaClass);
        studentClass.createProperty("transcript", OType.LINK, transcriptClass).createIndex(OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, new ODocument().field("ignoreNullValues", true));
        studentClass.createProperty("skill", OType.LINK, skillClass);
        final ODocument metadata = new ODocument().field("ignoreNullValues", false);
        studentClass.createIndex("studentDiplomaAndNameIndex", OClass.INDEX_TYPE.UNIQUE.toString(), null, metadata.copy(), new String[] { "diploma", "name" });
        studentClass.createIndex("studentSkillAndGroupIndex", OClass.INDEX_TYPE.NOTUNIQUE_HASH_INDEX.toString(), null, metadata.copy(), new String[] { "skill", "group" });
        schema.save();
    }
}
Also used : OSchema(com.orientechnologies.orient.core.metadata.schema.OSchema) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Aggregations

OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)203 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)165 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)122 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)54 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)46 Test (org.testng.annotations.Test)35 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)31 OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)23 Test (org.junit.Test)19 Before (org.junit.Before)16 ORID (com.orientechnologies.orient.core.id.ORID)15 OIndex (com.orientechnologies.orient.core.index.OIndex)15 Collection (java.util.Collection)15 Set (java.util.Set)15 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)9 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)9 BeforeClass (org.testng.annotations.BeforeClass)9 OStorage (com.orientechnologies.orient.core.storage.OStorage)6 ArrayList (java.util.ArrayList)5 OCommandExecutionException (com.orientechnologies.orient.core.exception.OCommandExecutionException)4