use of de.fhg.igd.mongomvcc.helper.IdMap in project mongomvcc by igd-geo.
the class Index method insert.
/**
* Inserts a new object into the index and marks it as dirty
* @param collection the name of the collection the object has been added to
* @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);
}
use of de.fhg.igd.mongomvcc.helper.IdMap in project mongomvcc by igd-geo.
the class Tree method resolveCollectionObjects.
private static IdMap resolveCollectionObjects(DBObject o) {
Set<String> keys = o.keySet();
IdMap r = new IdHashMap(keys.size());
for (String k : keys) {
r.put(Long.parseLong(k), (Long) o.get(k));
}
return r;
}
use of de.fhg.igd.mongomvcc.helper.IdMap in project mongomvcc by igd-geo.
the class Tree method addCommit.
/**
* Adds a commit to the tree
* @param commit the commit to add
*/
public void addCommit(Commit commit) {
DBObject o = new BasicDBObject();
o.put(MongoDBConstants.ID, commit.getCID());
o.put(MongoDBConstants.TIMESTAMP, commit.getTimestamp());
o.put(PARENT_CID, commit.getParentCID());
o.put(ROOT_CID, commit.getRootCID());
DBObject objs = new BasicDBObject();
for (Map.Entry<String, IdMap> e : commit.getObjects().entrySet()) {
DBObject co = new BasicDBObject();
IdMapIterator it = e.getValue().iterator();
while (it.hasNext()) {
it.advance();
co.put(String.valueOf(it.key()), it.value());
}
objs.put(e.getKey(), co);
}
o.put(OBJECTS, objs);
_commits.insert(o);
}
use of de.fhg.igd.mongomvcc.helper.IdMap in project mongomvcc by igd-geo.
the class Index method getObjects.
/**
* For a given collection, this method lazily retrieves
* the map that maps UIDs to OIDs
* @param collection the collection's name
* @return the map
*/
private IdMap getObjects(String collection) {
IdMap objs = _objects.get(collection);
if (objs == null) {
objs = new IdHashMap();
_objects.put(collection, objs);
}
return objs;
}
use of de.fhg.igd.mongomvcc.helper.IdMap in project mongomvcc by igd-geo.
the class Index method getDirtyObjects.
/**
* For a given collection, this method lazily retrieves
* the map that maps UIDs of dirty objects to OIDs.
* @param collection the collection's name
* @return the map
*/
private IdMap getDirtyObjects(String collection) {
IdMap objs = _dirtyObjects.get(collection);
if (objs == null) {
objs = new IdHashMap();
_dirtyObjects.put(collection, objs);
}
return objs;
}
Aggregations