Search in sources :

Example 1 with ODirtyManager

use of com.orientechnologies.orient.core.record.impl.ODirtyManager in project orientdb by orientechnologies.

the class ODirtyManagerRidbagTest method testRidBagTree.

@Test
public void testRidBagTree() {
    Object value = OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.getValue();
    OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(-1);
    try {
        ODocument doc = new ODocument();
        doc.field("test", "ddd");
        ORidBag bag = new ORidBag();
        ODocument doc1 = new ODocument();
        bag.add(doc1);
        doc.field("bag", bag);
        ODocumentInternal.convertAllMultiValuesToTrackedVersions(doc);
        ODirtyManager manager = ORecordInternal.getDirtyManager(doc1);
        assertEquals(2, manager.getNewRecords().size());
    } finally {
        OGlobalConfiguration.RID_BAG_EMBEDDED_TO_SBTREEBONSAI_THRESHOLD.setValue(value);
    }
}
Also used : ORidBag(com.orientechnologies.orient.core.db.record.ridbag.ORidBag) ODirtyManager(com.orientechnologies.orient.core.record.impl.ODirtyManager) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 2 with ODirtyManager

use of com.orientechnologies.orient.core.record.impl.ODirtyManager in project orientdb by orientechnologies.

the class ODirtyManagerTest method testSetToNullLink.

@Test
public void testSetToNullLink() {
    ODocument doc = new ODocument();
    doc.field("test", "ddd");
    ODocument doc2 = new ODocument();
    doc.field("test1", doc2);
    doc.field("test1", (Object) null);
    ODirtyManager manager = ORecordInternal.getDirtyManager(doc);
    assertEquals(2, manager.getNewRecords().size());
    assertEquals(0, manager.getPointed(doc).size());
}
Also used : ODirtyManager(com.orientechnologies.orient.core.record.impl.ODirtyManager) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 3 with ODirtyManager

use of com.orientechnologies.orient.core.record.impl.ODirtyManager in project orientdb by orientechnologies.

the class ODirtyManagerTest method testNestedMapDocRidBag.

@Test
public void testNestedMapDocRidBag() {
    ODocument doc = new ODocument();
    Map<String, ODocument> embeddedMap = new HashMap<String, ODocument>();
    ODocument embeddedMapDoc = new ODocument();
    ORidBag embeddedMapDocRidBag = new ORidBag();
    ODocument link = new ODocument();
    embeddedMapDocRidBag.add(link);
    embeddedMapDoc.field("ridBag", embeddedMapDocRidBag);
    embeddedMap.put("k1", embeddedMapDoc);
    doc.field("embeddedMap", embeddedMap, OType.EMBEDDEDMAP);
    ODocumentInternal.convertAllMultiValuesToTrackedVersions(doc);
    ODirtyManager manager = ORecordInternal.getDirtyManager(doc);
    assertEquals(2, manager.getNewRecords().size());
    assertEquals(1, manager.getPointed(doc).size());
    // TODO: double check this, it's an overhead
    assertEquals(1, manager.getPointed(embeddedMapDoc).size());
    assertTrue(manager.getPointed(doc).contains(link));
}
Also used : ORidBag(com.orientechnologies.orient.core.db.record.ridbag.ORidBag) ODirtyManager(com.orientechnologies.orient.core.record.impl.ODirtyManager) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 4 with ODirtyManager

use of com.orientechnologies.orient.core.record.impl.ODirtyManager in project orientdb by orientechnologies.

the class ODirtyManagerTest method testLinkSetNoConvert.

@Test
public void testLinkSetNoConvert() {
    ODocument doc = new ODocument();
    doc.field("test", "ddd");
    Set<OIdentifiable> set = new ORecordLazySet(doc);
    ODocument link = new ODocument();
    set.add(link);
    doc.field("set", set, OType.LINKSET);
    ODirtyManager manager = ORecordInternal.getDirtyManager(doc);
    assertEquals(2, manager.getNewRecords().size());
    assertEquals(1, manager.getPointed(doc).size());
    assertTrue(manager.getPointed(doc).contains(link));
}
Also used : ORecordLazySet(com.orientechnologies.orient.core.db.record.ORecordLazySet) ODirtyManager(com.orientechnologies.orient.core.record.impl.ODirtyManager) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Example 5 with ODirtyManager

use of com.orientechnologies.orient.core.record.impl.ODirtyManager in project orientdb by orientechnologies.

the class ODirtyManagerTest method testEmbeddedMap.

@Test
public void testEmbeddedMap() {
    ODocument doc = new ODocument();
    doc.field("test", "ddd");
    Map<String, Object> map = new HashMap<String, Object>();
    ODocument doc1 = new ODocument();
    map.put("bla", "bla");
    map.put("some", doc1);
    doc.field("list", map, OType.EMBEDDEDMAP);
    ODocumentInternal.convertAllMultiValuesToTrackedVersions(doc);
    ODirtyManager manager = ORecordInternal.getDirtyManager(doc);
    assertEquals(1, manager.getNewRecords().size());
}
Also used : ODirtyManager(com.orientechnologies.orient.core.record.impl.ODirtyManager) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.testng.annotations.Test)

Aggregations

ODirtyManager (com.orientechnologies.orient.core.record.impl.ODirtyManager)33 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)32 Test (org.testng.annotations.Test)28 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)5 ORidBag (com.orientechnologies.orient.core.db.record.ridbag.ORidBag)3 ORecord (com.orientechnologies.orient.core.record.ORecord)3 ORecordLazySet (com.orientechnologies.orient.core.db.record.ORecordLazySet)2 OrientEdge (com.tinkerpop.blueprints.impls.orient.OrientEdge)2 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)2 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)2 Test (org.junit.Test)2 OException (com.orientechnologies.common.exception.OException)1 ODatabaseException (com.orientechnologies.orient.core.exception.ODatabaseException)1 ORecordNotFoundException (com.orientechnologies.orient.core.exception.ORecordNotFoundException)1 ORecordId (com.orientechnologies.orient.core.id.ORecordId)1