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();
}
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();
}
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();
}
}
use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class SQLInsertTest method insertAvoidingSubQuery.
@Test
public void insertAvoidingSubQuery() {
final OSchema schema = database.getMetadata().getSchema();
if (schema.getClass("test") == null)
schema.createClass("test");
ODocument doc = (ODocument) database.command(new OCommandSQL("INSERT INTO test(text) VALUES ('(Hello World)')")).execute();
Assert.assertTrue(doc != null);
Assert.assertEquals(doc.field("text"), "(Hello World)");
}
use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class SQLSelectHashIndexReuseTest method testReuseOfIndexOnSeveralClassesFields.
@Test
public void testReuseOfIndexOnSeveralClassesFields() {
final OSchema schema = database.getMetadata().getSchema();
final OClass superClass = schema.createClass("sqlSelectHashIndexReuseTestSuperClass");
superClass.createProperty("prop0", OType.INTEGER);
final OClass oClass = schema.createClass("sqlSelectHashIndexReuseTestChildClass", superClass);
oClass.createProperty("prop1", OType.INTEGER);
oClass.createIndex("sqlSelectHashIndexReuseTestOnPropertiesFromClassAndSuperclass", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "prop0", "prop1");
schema.save();
long oldIndexUsage = profiler.getCounter("db.demo.query.indexUsed");
long oldcompositeIndexUsed = profiler.getCounter("db.demo.query.compositeIndexUsed");
long oldcompositeIndexUsed2 = profiler.getCounter("db.demo.query.compositeIndexUsed.2");
final ODocument docOne = new ODocument("sqlSelectHashIndexReuseTestChildClass");
docOne.field("prop0", 0);
docOne.field("prop1", 1);
docOne.save();
final ODocument docTwo = new ODocument("sqlSelectHashIndexReuseTestChildClass");
docTwo.field("prop0", 2);
docTwo.field("prop1", 3);
docTwo.save();
final List<ODocument> result = database.command(new OSQLSynchQuery<ODocument>("select * from sqlSelectHashIndexReuseTestChildClass where prop0 = 0 and prop1 = 1")).execute();
Assert.assertEquals(result.size(), 1);
assertProfileCount(profiler.getCounter("db.demo.query.indexUsed"), oldIndexUsage, 1);
assertProfileCount(profiler.getCounter("db.demo.query.compositeIndexUsed"), oldcompositeIndexUsed, 1);
assertProfileCount(profiler.getCounter("db.demo.query.compositeIndexUsed.2"), oldcompositeIndexUsed2, 1);
}
Aggregations