long version = intermediateVersion;
for (String mutation : tailMutations) {
ProtocolWaveletOperation op = serializer.deserializeDelta(mutation).getOperation();
if (op.hasMutateDocument()) {
MutateDocument mutateDocument = op.getMutateDocument();
String documentId = mutateDocument.getDocumentId();
DocDiff docDiff = documentDiffMap.get(documentId);
if (docDiff == null) {
docDiff = new DocDiff(lastReadVersions.get(documentId, 0L));
documentDiffMap.put(documentId, docDiff);
}
docDiff.addOperation(mutateDocument.getDocumentId(), version,
OperationFactory.createDocumentOperation(mutateDocument.getDocumentOperation()));
}
version++;
}