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