use of com.orientechnologies.orient.core.id.ORecordId in project orientdb by orientechnologies.
the class LocalPaginateStorageSpeedTest method cycle.
@Override
@Test(enabled = false)
public void cycle() {
record.reset();
record.setClassName("Account");
record.field("id", data.getCyclesDone());
record.field("name", "Luca");
record.field("surname", "Garulli");
record.field("birthDate", date);
record.field("salary", 3000f + data.getCyclesDone());
content = record.toStream();
storage.createRecord(new ORecordId(), content, 0, (byte) 'd', 0, null);
}
use of com.orientechnologies.orient.core.id.ORecordId in project orientdb by orientechnologies.
the class ORuntimeResult method createProjectionDocument.
public static ODocument createProjectionDocument(final int iProgressive) {
final ODocument doc = new ODocument().setOrdered(true).setTrackingChanges(false);
// ASSIGN A TEMPORARY RID TO ALLOW PAGINATION IF ANY
((ORecordId) doc.getIdentity()).setClusterId(-2);
((ORecordId) doc.getIdentity()).setClusterPosition(iProgressive);
return doc;
}
use of com.orientechnologies.orient.core.id.ORecordId in project orientdb by orientechnologies.
the class ODocumentSchemalessBinarySerializationTest method testLinkCollections.
@Test
public void testLinkCollections() {
ODatabaseDocument db = new ODatabaseDocumentTx("memory:ODocumentSchemalessBinarySerializationTest").create();
try {
ODocument document = new ODocument();
Set<ORecordId> linkSet = new HashSet<ORecordId>();
linkSet.add(new ORecordId(10, 20));
linkSet.add(new ORecordId(10, 21));
linkSet.add(new ORecordId(10, 22));
linkSet.add(new ORecordId(11, 22));
document.field("linkSet", linkSet, OType.LINKSET);
List<ORecordId> linkList = new ArrayList<ORecordId>();
linkList.add(new ORecordId(10, 20));
linkList.add(new ORecordId(10, 21));
linkList.add(new ORecordId(10, 22));
linkList.add(new ORecordId(11, 22));
document.field("linkList", linkList, OType.LINKLIST);
byte[] res = serializer.toStream(document, false);
ODocument extr = (ODocument) serializer.fromStream(res, new ODocument(), new String[] {});
assertEquals(extr.fields(), document.fields());
assertEquals(((Set<?>) extr.field("linkSet")).size(), ((Set<?>) document.field("linkSet")).size());
assertTrue(((Set<?>) extr.field("linkSet")).containsAll((Set<?>) document.field("linkSet")));
assertEquals(extr.field("linkList"), document.field("linkList"));
} finally {
db.drop();
}
}
use of com.orientechnologies.orient.core.id.ORecordId in project orientdb by orientechnologies.
the class TestOTypeDetection method testOTypeFromValueInternal.
@Test
public void testOTypeFromValueInternal() {
Map<String, ORecordId> linkmap = new HashMap<String, ORecordId>();
linkmap.put("some", new ORecordId());
assertEquals(OType.LINKMAP, OType.getTypeByValue(linkmap));
Map<String, ORecord> linkmap2 = new HashMap<String, ORecord>();
linkmap2.put("some", new ODocument());
assertEquals(OType.LINKMAP, OType.getTypeByValue(linkmap2));
List<ORecordId> linkList = new ArrayList<ORecordId>();
linkList.add(new ORecordId());
assertEquals(OType.LINKLIST, OType.getTypeByValue(linkList));
List<ORecord> linkList2 = new ArrayList<ORecord>();
linkList2.add(new ODocument());
assertEquals(OType.LINKLIST, OType.getTypeByValue(linkList2));
Set<ORecordId> linkSet = new HashSet<ORecordId>();
linkSet.add(new ORecordId());
assertEquals(OType.LINKSET, OType.getTypeByValue(linkSet));
Set<ORecord> linkSet2 = new HashSet<ORecord>();
linkSet2.add(new ODocument());
assertEquals(OType.LINKSET, OType.getTypeByValue(linkSet2));
ODocument document = new ODocument();
ODocumentInternal.addOwner(document, new ODocument());
assertEquals(OType.EMBEDDED, OType.getTypeByValue(document));
}
use of com.orientechnologies.orient.core.id.ORecordId in project orientdb by orientechnologies.
the class OSBTreeBonsaiLocalTest method testAddKeyValuesAndRemoveFirstMiddleAndLastPages.
public void testAddKeyValuesAndRemoveFirstMiddleAndLastPages() throws Exception {
for (int i = 0; i < 326; i++) sbTree.put(i, new ORecordId(i % 32000, i));
for (int i = 0; i < 60; i++) sbTree.remove(i);
for (int i = 100; i < 220; i++) sbTree.remove(i);
for (int i = 260; i < 326; i++) sbTree.remove(i);
Assert.assertEquals((int) sbTree.firstKey(), 60);
Assert.assertEquals((int) sbTree.lastKey(), 259);
Collection<OIdentifiable> result = sbTree.getValuesMinor(250, true, -1);
Set<OIdentifiable> identifiables = new HashSet<OIdentifiable>(result);
for (int i = 250; i >= 220; i--) {
boolean removed = identifiables.remove(new ORecordId(i % 32000, i));
Assert.assertTrue(removed);
}
for (int i = 99; i >= 60; i--) {
boolean removed = identifiables.remove(new ORecordId(i % 32000, i));
Assert.assertTrue(removed);
}
Assert.assertTrue(identifiables.isEmpty());
result = sbTree.getValuesMajor(70, true, -1);
identifiables = new HashSet<OIdentifiable>(result);
for (int i = 70; i < 100; i++) {
boolean removed = identifiables.remove(new ORecordId(i % 32000, i));
Assert.assertTrue(removed);
}
for (int i = 220; i < 260; i++) {
boolean removed = identifiables.remove(new ORecordId(i % 32000, i));
Assert.assertTrue(removed);
}
Assert.assertTrue(identifiables.isEmpty());
result = sbTree.getValuesBetween(70, true, 250, true, -1);
identifiables = new HashSet<OIdentifiable>(result);
for (int i = 70; i < 100; i++) {
boolean removed = identifiables.remove(new ORecordId(i % 32000, i));
Assert.assertTrue(removed);
}
for (int i = 220; i <= 250; i++) {
boolean removed = identifiables.remove(new ORecordId(i % 32000, i));
Assert.assertTrue(removed);
}
Assert.assertTrue(identifiables.isEmpty());
}
Aggregations