Store topic in notedb when notedb is rebuilt

In the database only the current topic is stored explictly. This is
why we must parse the change messages to rebuild the topic history.

Rebuilding the topic history based on parsing the change messages is a
heuristic, which may not work in all cases. To ensure that the current
topic is correctly set in notedb a final FixChangeEvent is added as
last event to the event list that is used to build up the notedb for
one change. The FinalUpdatesEvent will set the current topic in notedb
if it wasn't set before. To know whether the topic needs to be set we
keep track of the change state in notedb while the events are
processed. All fixes done by the FinalUpdatesEvent (at the moment only
an update of the topic, but more in future) will be done in a seperate
commit on the notes branch. This means these updates will not be
squashed with the updates from other events. This way there is a clear
seperation between normal updates and the fix update. Also the
FixChangeEvent will only lead to an update if there is anything to
fix. If not, it will not create a commit on the notes branch.

Change-Id: I489ddcbc1b71bbec786141f92f2f51d4644bf085
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2016-01-25 15:58:53 +01:00
parent 0c0a203fcb
commit 338dcf6a57
4 changed files with 78 additions and 12 deletions

View File

@@ -288,7 +288,8 @@ public class ChangeDraftUpdate extends AbstractChangeUpdate {
return true;
}
private boolean isEmpty() {
@Override
public boolean isEmpty() {
return deleteComments.isEmpty()
&& upsertComments.isEmpty();
}