Iterator it = updatedSnapshots.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
ObjectId key = (ObjectId) entry.getKey();
DataRow newSnapshot = (DataRow) entry.getValue();
DataRow oldSnapshot = (DataRow) snapshots.put(key, newSnapshot);
// generate diff for the updated event, if this not a new
// snapshot
// The following cases should be handled here:
// 1. There is no previously cached snapshot for a given id.
// 2. There was a previously cached snapshot for a given id,
// but it expired from cache and was removed. Currently
// handled as (1); what are the consequences of that?
// 3. There is a previously cached snapshot and it has the
// *same version* as the "replacesVersion" property of the
// new snapshot.
// 4. There is a previously cached snapshot and it has a
// *different version* from "replacesVersion" property of
// the new snapshot. It means that we don't know how to merge
// the two (we don't even know which one is newer due to
// multithreading). Just throw out this snapshot....
if (oldSnapshot != null) {
// case 4 above... have to throw out the snapshot since
// no good options exist to tell how to merge the two.
if (oldSnapshot.getVersion() != newSnapshot.getReplacesVersion()) {
logger
.debug("snapshot version changed, don't know what to do... Old: "
+ oldSnapshot
+ ", New: "
+ newSnapshot);
forgetSnapshot(key);
continue;
}
Map diff = oldSnapshot.createDiff(newSnapshot);
if (diff != null) {
if (diffs == null) {
diffs = new HashMap();
}