Examples of IdSet


Examples of de.fhg.igd.mongomvcc.helper.IdSet

    }

    //read objects from the given commit and put them into the index
    for (Map.Entry<String, IdMap> e : c.getObjects().entrySet()) {
      IdMap m = getObjects(e.getKey());
      IdSet o = getOIDs(e.getKey());
      IdMapIterator it = e.getValue().iterator();
      while (it.hasNext()) {
        it.advance();
        if (it.value() < 0) {
          //deleted object
          long prev = m.get(it.key());
          if (prev != 0) {
            m.remove(it.key());
            o.remove(prev);
          }
        } else {
          long prev = m.put(it.key(), it.value());
          if (prev != 0) {
            //overwrite object with new value
            o.remove(prev);
          }
          o.add(it.value());
        }
      }
    }
  }
View Full Code Here

Examples of de.fhg.igd.mongomvcc.helper.IdSet

   * the OIDs of all deleted objects.
   * @param collection the collection's name
   * @return the OIDs
   */
  private IdSet getDeletedOids(String collection) {
    IdSet oids = _deletedOids.get(collection);
    if (oids == null) {
      oids = new IdHashSet();
      _deletedOids.put(collection, oids);
    }
    return oids;
View Full Code Here

Examples of de.fhg.igd.mongomvcc.helper.IdSet

   * For a given collection, this method returns the OIDs of all objects
   * @param collection the collection's name
   * @return the OIDs
   */
  private IdSet getOIDs(String collection) {
    IdSet oids = _oids.get(collection);
    if (oids == null) {
      oids = new IdHashSet();
      _oids.put(collection, oids);
    }
    return oids;
View Full Code Here

Examples of de.fhg.igd.mongomvcc.helper.IdSet

   * @param uid the new object's UID
   * @param oid the OID
   */
  public void insert(String collection, long uid, long oid) {
    IdMap objs = getObjects(collection);
    IdSet oids = getOIDs(collection);
    long prev = objs.put(uid, oid);
    if (prev != 0) {
      //an existing object is replaced by a new instance. Remove the
      //old OID, since the old object is now invalid (within this index)
      oids.remove(prev);
     
      if (oid == -1) {
        getDeletedOids(collection).add(prev);
      }
    }
    if (oid != -1) {
      oids.add(oid);
    }
    getDirtyObjects(collection).put(uid, oid);
  }
View Full Code Here

Examples of de.fhg.igd.mongomvcc.helper.IdSet

    //load all commits which are older than the expiry time. mark them as dangling
    DBCollection collCommits = _db.getDB().getCollection(MongoDBConstants.COLLECTION_COMMITS);
    DBCursor commits = collCommits.find(new BasicDBObject(MongoDBConstants.TIMESTAMP,
        new BasicDBObject("$not", new BasicDBObject("$gte", maxTime))), //also include commits without a timestamp
        new BasicDBObject(MongoDBConstants.ID, 1));
    IdSet danglingCommits = new IdHashSet();
    for (DBObject o : commits) {
      long cid = (Long)o.get(MongoDBConstants.ID);
      danglingCommits.add(cid);
    }
   
    //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);
      }
    }
   
View Full Code Here

Examples of de.fhg.igd.mongomvcc.helper.IdSet

    //fetch the OIDs of all documents older than the expiry time
    DBCollection collDocs = _db.getDB().getCollection(collection);
    DBCursor docs = collDocs.find(new BasicDBObject(MongoDBConstants.TIMESTAMP,
        new BasicDBObject("$not", new BasicDBObject("$gte", maxTime))), //also include docs without a timestamp
        new BasicDBObject(MongoDBConstants.ID, 1));
    IdSet oids = new IdHashSet(docs.count());
    for (DBObject o : docs) {
      oids.add((Long)o.get(MongoDBConstants.ID));
    }
   
    //iterate through all commits and eliminate referenced documents
    DBCollection collCommits = _db.getDB().getCollection(MongoDBConstants.COLLECTION_COMMITS);
    for (DBObject o : collCommits.find()) {
      Commit c = Tree.deserializeCommit(o);
      Map<String, IdMap> allObjs = c.getObjects();
      IdMap objs = allObjs.get(collection);
      if (objs != null) {
        //eliminate OIDs referenced by this commit
        IdMapIterator mi = objs.iterator();
        while (mi.hasNext()) {
          mi.advance();
          oids.remove(mi.value());
        }
      }
    }
   
    //the remaining OIDs must be the unreferenced ones
    return oids.toArray();
  }
View Full Code Here

Examples of org.apache.james.imapserver.commands.IdSet

    public void testIdSet() throws Exception
    {
        String testRequest = "8 25 1:4 33:* 2,3,4 1,4:6,8:* ";
        ImapRequestLineReader request = getRequest( testRequest );

        IdSet idSet;
        idSet = parser.set( request );
        checkSet( idSet, new long[]{8}, new long[]{0, 2, 7, 9, 20, Long.MAX_VALUE } );

        idSet = parser.set( request );
        checkSet( idSet, new long[]{ 25 }, new long[]{ 0, 5, 20, 30, Long.MAX_VALUE } );
View Full Code Here

Examples of org.apache.james.imapserver.commands.IdSet

    public void testIdSet() throws Exception
    {
        String testRequest = "8 25 1:4 33:* 2,3,4 1,4:6,8:* ";
        ImapRequestLineReader request = getRequest( testRequest );

        IdSet idSet;
        idSet = parser.set( request );
        checkSet( idSet, new long[]{8}, new long[]{0, 2, 7, 9, 20, Long.MAX_VALUE } );

        idSet = parser.set( request );
        checkSet( idSet, new long[]{ 25 }, new long[]{ 0, 5, 20, 30, Long.MAX_VALUE } );
View Full Code Here

Examples of org.apache.james.imapserver.commands.IdSet

    public void testIdSet() throws Exception
    {
        String testRequest = "8 25 1:4 33:* 2,3,4 1,4:6,8:* ";
        ImapRequestLineReader request = getRequest( testRequest );

        IdSet idSet;
        idSet = parser.set( request );
        checkSet( idSet, new long[]{8}, new long[]{0, 2, 7, 9, 20, Long.MAX_VALUE } );

        idSet = parser.set( request );
        checkSet( idSet, new long[]{ 25 }, new long[]{ 0, 5, 20, 30, Long.MAX_VALUE } );
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.