NodeState after = new SegmentNodeState(segment, head);
Journal parent = store.getJournal(state.get("parent").toString());
while (!parent.setHead(base, head)) {
RecordId newBase = parent.getHead();
NodeBuilder builder =
new SegmentNodeState(segment, newBase).builder();
after.compareAgainstBaseState(before, new MergeDiff(builder));
RecordId newHead =
writer.writeNode(builder.getNodeState()).getRecordId();
base = newBase;
head = newHead;
}
base = head;
BasicDBObjectBuilder builder = BasicDBObjectBuilder.start();
builder.add("_id", name);
builder.add("parent", state.get("parent"));
builder.add("base", base.toString());
builder.add("head", head.toString());
// TODO: concurrent updates?
journals.update(state, builder.get(), false, false, concern);
}
}