use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class CompositeIndexWithNullTest method testRangeQueryNullInTheMiddleInMiddleTx.
public void testRangeQueryNullInTheMiddleInMiddleTx() {
if (database.getURL().startsWith("remote:"))
return;
final OSchema schema = database.getMetadata().getSchema();
OClass clazz = schema.createClass("compositeIndexNullRangeQueryNullInTheMiddleInMiddleTxClass");
clazz.createProperty("prop1", OType.INTEGER);
clazz.createProperty("prop2", OType.INTEGER);
clazz.createProperty("prop3", OType.INTEGER);
final ODocument metadata = new ODocument();
metadata.field("ignoreNullValues", false);
clazz.createIndex("compositeIndexNullRangeQueryNullInTheMiddleInMiddleTxIndex", OClass.INDEX_TYPE.NOTUNIQUE.toString(), null, metadata, new String[] { "prop1", "prop2", "prop3" });
for (int i = 0; i < 20; i++) {
ODocument document = new ODocument("compositeIndexNullRangeQueryNullInTheMiddleInMiddleTxClass");
document.field("prop1", i / 10);
if (i % 2 == 0)
document.field("prop2", i);
document.field("prop3", i);
document.save();
}
final String query = "select from compositeIndexNullRangeQueryNullInTheMiddleInMiddleTxClass where prop1 > 0";
List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(result.size(), 10);
for (int k = 0; k < 10; k++) {
ODocument document = result.get(k);
Assert.assertEquals(document.field("prop1"), 1);
}
ODocument explain = database.command(new OCommandSQL("explain " + query)).execute();
Assert.assertTrue(explain.<Set<String>>field("involvedIndexes").contains("compositeIndexNullRangeQueryNullInTheMiddleInMiddleTxIndex"));
}
use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class CompositeIndexWithNullTest method testPointQueryNullInTheMiddle.
public void testPointQueryNullInTheMiddle() {
final OSchema schema = database.getMetadata().getSchema();
OClass clazz = schema.createClass("compositeIndexNullPointQueryNullInTheMiddleClass");
clazz.createProperty("prop1", OType.INTEGER);
clazz.createProperty("prop2", OType.INTEGER);
clazz.createProperty("prop3", OType.INTEGER);
final ODocument metadata = new ODocument();
metadata.field("ignoreNullValues", false);
clazz.createIndex("compositeIndexNullPointQueryNullInTheMiddleIndex", OClass.INDEX_TYPE.NOTUNIQUE.toString(), null, metadata, null, new String[] { "prop1", "prop2", "prop3" });
for (int i = 0; i < 20; i++) {
ODocument document = new ODocument("compositeIndexNullPointQueryNullInTheMiddleClass");
document.field("prop1", i / 10);
if (i % 2 == 0)
document.field("prop2", i);
document.field("prop3", i);
document.save();
}
String query = "select from compositeIndexNullPointQueryNullInTheMiddleClass where prop1 = 1";
List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(result.size(), 10);
for (int k = 0; k < 10; k++) {
ODocument document = result.get(k);
Assert.assertEquals(document.field("prop1"), 1);
}
ODocument explain = database.command(new OCommandSQL("explain " + query)).execute();
Assert.assertTrue(explain.<Set<String>>field("involvedIndexes").contains("compositeIndexNullPointQueryNullInTheMiddleIndex"));
query = "select from compositeIndexNullPointQueryNullInTheMiddleClass where prop1 = 1 and prop2 is null";
result = database.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(result.size(), 5);
for (ODocument document : result) {
Assert.assertEquals(document.field("prop1"), 1);
Assert.assertNull(document.field("prop2"));
}
explain = database.command(new OCommandSQL("explain " + query)).execute();
Assert.assertTrue(explain.<Set<String>>field("involvedIndexes").contains("compositeIndexNullPointQueryNullInTheMiddleIndex"));
query = "select from compositeIndexNullPointQueryNullInTheMiddleClass where prop1 = 1 and prop2 is null and prop3 = 13";
result = database.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(result.size(), 1);
explain = database.command(new OCommandSQL("explain " + query)).execute();
Assert.assertTrue(explain.<Set<String>>field("involvedIndexes").contains("compositeIndexNullPointQueryNullInTheMiddleIndex"));
}
use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class CompositeIndexWithNullTest method testRangeQueryNullInTheMiddle.
public void testRangeQueryNullInTheMiddle() {
final OSchema schema = database.getMetadata().getSchema();
OClass clazz = schema.createClass("compositeIndexNullRangeQueryNullInTheMiddleClass");
clazz.createProperty("prop1", OType.INTEGER);
clazz.createProperty("prop2", OType.INTEGER);
clazz.createProperty("prop3", OType.INTEGER);
final ODocument metadata = new ODocument();
metadata.field("ignoreNullValues", false);
clazz.createIndex("compositeIndexNullRangeQueryNullInTheMiddleIndex", OClass.INDEX_TYPE.NOTUNIQUE.toString(), null, metadata, new String[] { "prop1", "prop2", "prop3" });
for (int i = 0; i < 20; i++) {
ODocument document = new ODocument("compositeIndexNullRangeQueryNullInTheMiddleClass");
document.field("prop1", i / 10);
if (i % 2 == 0)
document.field("prop2", i);
document.field("prop3", i);
document.save();
}
final String query = "select from compositeIndexNullRangeQueryNullInTheMiddleClass where prop1 > 0";
List<ODocument> result = database.query(new OSQLSynchQuery<ODocument>(query));
Assert.assertEquals(result.size(), 10);
for (int k = 0; k < 10; k++) {
ODocument document = result.get(k);
Assert.assertEquals(document.field("prop1"), 1);
}
ODocument explain = database.command(new OCommandSQL("explain " + query)).execute();
Assert.assertTrue(explain.<Set<String>>field("involvedIndexes").contains("compositeIndexNullRangeQueryNullInTheMiddleIndex"));
}
use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class DateIndexTest method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
super.beforeClass();
final OSchema schema = database.getMetadata().getSchema();
OClass dateIndexTest = schema.createClass("DateIndexTest");
dateIndexTest.createProperty("dateField", OType.DATE);
dateIndexTest.createProperty("dateTimeField", OType.DATETIME);
dateIndexTest.createProperty("dateList", OType.EMBEDDEDLIST, OType.DATE);
dateIndexTest.createProperty("dateTimeList", OType.EMBEDDEDLIST, OType.DATETIME);
dateIndexTest.createProperty("value", OType.STRING);
dateIndexTest.createIndex("DateIndexTestDateIndex", OClass.INDEX_TYPE.UNIQUE, "dateField");
dateIndexTest.createIndex("DateIndexTestValueDateIndex", OClass.INDEX_TYPE.UNIQUE, "value", "dateField");
dateIndexTest.createIndex("DateIndexTestDateTimeIndex", OClass.INDEX_TYPE.UNIQUE, "dateTimeField");
dateIndexTest.createIndex("DateIndexTestValueDateTimeIndex", OClass.INDEX_TYPE.UNIQUE, "value", "dateTimeField");
dateIndexTest.createIndex("DateIndexTestValueDateListIndex", OClass.INDEX_TYPE.UNIQUE, "value", "dateList");
dateIndexTest.createIndex("DateIndexTestValueDateTimeListIndex", OClass.INDEX_TYPE.UNIQUE, "value", "dateTimeList");
dateIndexTest.createIndex("DateIndexTestDateHashIndex", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "dateField");
dateIndexTest.createIndex("DateIndexTestValueDateHashIndex", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "value", "dateField");
dateIndexTest.createIndex("DateIndexTestDateTimeHashIndex", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "dateTimeField");
dateIndexTest.createIndex("DateIndexTestValueDateTimeHashIndex", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "value", "dateTimeField");
dateIndexTest.createIndex("DateIndexTestValueDateListHashIndex", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "value", "dateList");
dateIndexTest.createIndex("DateIndexTestValueDateTimeListHashIndex", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "value", "dateTimeList");
schema.save();
}
use of com.orientechnologies.orient.core.metadata.schema.OSchema in project orientdb by orientechnologies.
the class ClassIndexTest method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
super.beforeClass();
final OSchema schema = database.getMetadata().getSchema();
oClass = schema.createClass("ClassIndexTestClass");
oSuperClass = schema.createClass("ClassIndexTestSuperClass");
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);
oClass.createProperty("fEight", OType.INTEGER);
oClass.createProperty("fTen", OType.INTEGER);
oClass.createProperty("fEleven", OType.INTEGER);
oClass.createProperty("fTwelve", OType.INTEGER);
oClass.createProperty("fThirteen", OType.INTEGER);
oClass.createProperty("fFourteen", OType.INTEGER);
oClass.createProperty("fFifteen", OType.INTEGER);
oClass.createProperty("fEmbeddedMap", OType.EMBEDDEDMAP, OType.INTEGER);
oClass.createProperty("fEmbeddedMapWithoutLinkedType", OType.EMBEDDEDMAP);
oClass.createProperty("fLinkMap", OType.LINKMAP);
oClass.createProperty("fLinkList", OType.LINKLIST);
oClass.createProperty("fEmbeddedList", OType.EMBEDDEDLIST, OType.INTEGER);
oClass.createProperty("fEmbeddedSet", OType.EMBEDDEDSET, OType.INTEGER);
oClass.createProperty("fLinkSet", OType.LINKSET);
oClass.createProperty("fRidBag", OType.LINKBAG);
oSuperClass.createProperty("fNine", OType.INTEGER);
oClass.setSuperClass(oSuperClass);
schema.save();
database.close();
}
Aggregations