Store reviewer field in the index

Prior to this change, draft changes in search results may have
resulted in touching the database, since ChangeControl#isDraftVisible
checks if the user is a reviewer, and there are not enough stored
fields to compute the reviewer set from the index. (We store approvals
on the current patch set, not all approvals; even the latter would be
insufficient with NoteDb.)

Add a new reviewer field that stores enough information to reconstruct
the whole ReviewerSet, and also to search by reviewer state. Shove
this all in one repeated field with a little comma-separated format,
similar to what we already do for labels. The current
ReviewerPredicate implementation matches the old behavior of returning
results independent of state, although it's now expressed as a
predicate tree.

Change-Id: Ie54b9e2decf847185ec741bc50bae7eb680787a0
This commit is contained in:
Dave Borowitz
2016-06-02 17:50:00 -04:00
parent 3b8ff49c6e
commit 4315f01324
12 changed files with 282 additions and 28 deletions

View File

@@ -988,6 +988,7 @@ public class ChangeIT extends AbstractDaemonTest {
@Test
public void defaultSearchDoesNotTouchDatabase() throws Exception {
setApiUser(admin);
PushOneCommit.Result r1 = createChange();
gApi.changes()
.id(r1.getChangeId())
@@ -999,8 +1000,9 @@ public class ChangeIT extends AbstractDaemonTest {
.submit();
createChange();
createDraftChange();
setApiUserAnonymous(); // Identified user may async get stars from DB.
setApiUser(user);
AcceptanceTestRequestScope.Context ctx = disableDb();
try {
assertThat(gApi.changes().query()