Search in sources :

Example 51 with ORecordId

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);
}
Also used : ORecordId(com.orientechnologies.orient.core.id.ORecordId) Test(org.testng.annotations.Test) OrientMonoThreadTest(com.orientechnologies.orient.test.database.base.OrientMonoThreadTest)

Example 52 with ORecordId

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;
}
Also used : ORecordId(com.orientechnologies.orient.core.id.ORecordId) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 53 with ORecordId

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();
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) ODatabaseDocument(com.orientechnologies.orient.core.db.document.ODatabaseDocument) ArrayList(java.util.ArrayList) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) ORecordId(com.orientechnologies.orient.core.id.ORecordId) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 54 with ORecordId

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));
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ORecordId(com.orientechnologies.orient.core.id.ORecordId) ORecord(com.orientechnologies.orient.core.record.ORecord) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 55 with ORecordId

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());
}
Also used : OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ORecordId(com.orientechnologies.orient.core.id.ORecordId)

Aggregations

ORecordId (com.orientechnologies.orient.core.id.ORecordId)431 Test (org.testng.annotations.Test)153 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)139 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)120 ORID (com.orientechnologies.orient.core.id.ORID)71 HashSet (java.util.HashSet)63 OIndexCursor (com.orientechnologies.orient.core.index.OIndexCursor)42 ORidBag (com.orientechnologies.orient.core.db.record.ridbag.ORidBag)37 ORecord (com.orientechnologies.orient.core.record.ORecord)37 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)34 OIndexTxAwareMultiValue (com.orientechnologies.orient.core.index.OIndexTxAwareMultiValue)30 OIndexTxAwareOneValue (com.orientechnologies.orient.core.index.OIndexTxAwareOneValue)30 HashMap (java.util.HashMap)29 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)28 IOException (java.io.IOException)25 Child (com.orientechnologies.orient.test.domain.business.Child)24 OException (com.orientechnologies.common.exception.OException)23 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)23 Map (java.util.Map)22 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)21