Examples of VHistory


Examples of de.fhg.igd.mongomvcc.VHistory

    putPerson("Max", 3);
    long c1 = _master.commit();
    putPerson("Peter", 26);
    long c2 = _master.commit();
   
    VHistory h = _db.getHistory();
    assertEquals(c1, h.getParent(c2));
    assertEquals(root, h.getParent(c1));
    assertEquals(0, h.getParent(root));
   
    assertArrayEquals(new long[] { root }, h.getChildren(0));
    assertArrayEquals(new long[] { c1 }, h.getChildren(root));
    assertArrayEquals(new long[] { c2 }, h.getChildren(c1));
    assertArrayEquals(new long[0], h.getChildren(c2));
   
    VBranch master2 = _db.createBranch("master2", c1);
    VCollection persons = master2.getCollection("persons");
    persons.insert(_factory.createDocument("name", "Elvis"));
    long c3 = master2.commit();
   
    h = _db.getHistory();
    assertEquals(c1, h.getParent(c2));
    assertEquals(c1, h.getParent(c3));
    assertEquals(root, h.getParent(c1));
    assertEquals(0, h.getParent(root));
   
    assertArrayEquals(new long[] { root }, h.getChildren(0));
    assertArrayEquals(new long[] { c1 }, h.getChildren(root));
    long[] c1c = h.getChildren(c1);
    assertEquals(2, c1c.length);
    assertTrue((c1c[0] == c2 && c1c[1] == c3) || (c1c[0] == c3 && c1c[1] == c2));
    assertArrayEquals(new long[0], h.getChildren(c2));
    assertArrayEquals(new long[0], h.getChildren(c3));
  }
View Full Code Here

Examples of de.fhg.igd.mongomvcc.VHistory

    }
   
    //walk through all branches and eliminate commits which are not dangling
    DBCollection collBranches = _db.getDB().getCollection(MongoDBConstants.COLLECTION_BRANCHES);
    DBCursor branches = collBranches.find(new BasicDBObject(), new BasicDBObject(MongoDBConstants.CID, 1));
    VHistory history = _db.getHistory();
    IdSet alreadyCheckedCommits = new IdHashSet();
    for (DBObject o : branches) {
      long cid = (Long)o.get(MongoDBConstants.CID);
      while (cid != 0) {
        if (alreadyCheckedCommits.contains(cid)) {
          break;
        }
        alreadyCheckedCommits.add(cid);
        danglingCommits.remove(cid);
        cid = history.getParent(cid);
      }
    }
   
    //all remaining commits must be dangling
    return danglingCommits.toArray();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.