use of com.orientechnologies.orient.core.index.OCompositeKey in project orientdb by orientechnologies.
the class ClassIndexManagerTest method testCollectionCompositeCreation.
public void testCollectionCompositeCreation() {
final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass");
doc.field("prop1", "test1");
doc.field("prop2", Arrays.asList(1, 2));
doc.save();
final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection");
Assert.assertEquals(index.getSize(), 2);
Assert.assertEquals(index.get(new OCompositeKey("test1", 1)), doc.getIdentity());
Assert.assertEquals(index.get(new OCompositeKey("test1", 2)), doc.getIdentity());
doc.delete();
Assert.assertEquals(index.getSize(), 0);
}
use of com.orientechnologies.orient.core.index.OCompositeKey in project orientdb by orientechnologies.
the class ClassIndexManagerTest method testCollectionCompositeUpdateCollectionWasAssigned.
public void testCollectionCompositeUpdateCollectionWasAssigned() {
final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass");
doc.field("prop1", "test1");
doc.field("prop2", Arrays.asList(1, 2));
doc.save();
final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection");
Assert.assertEquals(index.getSize(), 2);
doc.field("prop2", Arrays.asList(1, 3));
doc.save();
Assert.assertEquals(index.get(new OCompositeKey("test1", 1)), doc.getIdentity());
Assert.assertEquals(index.get(new OCompositeKey("test1", 3)), doc.getIdentity());
Assert.assertEquals(index.getSize(), 2);
doc.delete();
Assert.assertEquals(index.getSize(), 0);
}
use of com.orientechnologies.orient.core.index.OCompositeKey in project orientdb by orientechnologies.
the class ClassIndexManagerTest method testCollectionCompositeUpdateSimpleField.
public void testCollectionCompositeUpdateSimpleField() {
final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass");
doc.field("prop1", "test1");
doc.field("prop2", Arrays.asList(1, 2));
doc.save();
final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection");
Assert.assertEquals(index.getSize(), 2);
doc.field("prop1", "test2");
doc.save();
Assert.assertEquals(index.get(new OCompositeKey("test2", 1)), doc.getIdentity());
Assert.assertEquals(index.get(new OCompositeKey("test2", 2)), doc.getIdentity());
Assert.assertEquals(index.getSize(), 2);
doc.delete();
Assert.assertEquals(index.getSize(), 0);
}
use of com.orientechnologies.orient.core.index.OCompositeKey in project orientdb by orientechnologies.
the class ClassIndexManagerTest method testCollectionCompositeUpdateCollectionWasChanged.
public void testCollectionCompositeUpdateCollectionWasChanged() {
final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass");
doc.field("prop1", "test1");
doc.field("prop2", Arrays.asList(1, 2));
doc.save();
final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection");
Assert.assertEquals(index.getSize(), 2);
List<Integer> docList = doc.field("prop2");
docList.add(3);
docList.add(4);
docList.add(5);
docList.remove(0);
doc.save();
Assert.assertEquals(index.get(new OCompositeKey("test1", 2)), doc.getIdentity());
Assert.assertEquals(index.get(new OCompositeKey("test1", 3)), doc.getIdentity());
Assert.assertEquals(index.get(new OCompositeKey("test1", 4)), doc.getIdentity());
Assert.assertEquals(index.get(new OCompositeKey("test1", 5)), doc.getIdentity());
Assert.assertEquals(index.getSize(), 4);
doc.delete();
Assert.assertEquals(index.getSize(), 0);
}
use of com.orientechnologies.orient.core.index.OCompositeKey in project orientdb by orientechnologies.
the class SBTreeCompositeKeyTest method testIterateValuesMinorNonInclusivePartial.
public void testIterateValuesMinorNonInclusivePartial() {
OSBTree.OSBTreeCursor<OCompositeKey, OIdentifiable> cursor = localSBTree.iterateEntriesMinor(compositeKey(3.0), false, true);
Set<ORID> orids = extractRids(cursor);
assertEquals(orids.size(), 18);
for (int i = 1; i < 3; i++) for (int j = 1; j <= 9; j++) {
assertTrue(orids.contains(new ORecordId(i, j)));
}
cursor = localSBTree.iterateEntriesMinor(compositeKey(3.0), false, false);
orids = extractRids(cursor);
assertEquals(orids.size(), 18);
for (int i = 1; i < 3; i++) for (int j = 1; j <= 9; j++) {
assertTrue(orids.contains(new ORecordId(i, j)));
}
}
Aggregations