ChangeBundle: Allow timestamp slop instead of rounding

ChangeReubilder will batch events together up to a maximum window size
of 3 seconds (MAX_WINDOW_MS). This means that entities from the end of
the window might have a timestamp in NoteDb up to 3 seconds earlier
than the original timestamp in ReviewDb. This can't be accounted for
by simply rounding the timestamp, as the amount we would have to
subtract actually depends on *other* entities in the database.

Instead, don't emit diffs if two timestamps are within the constant
defined in ChangeRebuilder.

This requires a different implementation of diffing ChangeMessages,
since there is no longer a concept of normalizing timestamps. Instead
we just ort the input list and try to pair them up. This may result
in difficult to read diffs if somehow the relative timestamps got
swapped, but we don't think this is a very common class of bugs.

Change-Id: Ie226123739b91a3c4d47b50115d1f033221ae28f
This commit is contained in:
Dave Borowitz
2016-03-09 20:21:40 -05:00
parent 5ae24f5d23
commit 1693e1b8ef
4 changed files with 245 additions and 138 deletions

View File

@@ -124,4 +124,15 @@ public final class ChangeMessage {
public void setPatchSetId(PatchSet.Id id) {
patchset = id;
}
@Override
public String toString() {
return "ChangeMessage{"
+ "key=" + key
+ ", author=" + author
+ ", writtenOn=" + writtenOn
+ ", patchset=" + patchset
+ ", message=[" + message
+ "]}";
}
}