Simplify ChangeIndex by removing delete(ChangeData)
Since indexing is generally done after any modification operations, using a deleted ChangeData when indexing a deleted change is just asking for trouble; most ChangeData methods (reasonably) assume that the change exists. Instead, just use the form of the method that passes in the ID. Change the method that takes an integer ID to take a Change.Id object. In almost all cases we already have one of these handy, and this is more consistent with public interfaces elsewhere in Gerrit. A fortunate side effect is that async deletes should happen slightly faster, since we no longer need to open a DB connection and produce a ChangeData in the delete codepath. Change-Id: I353522b52188de11353ca26a7ba90a2ca462e404
This commit is contained in:
@@ -319,20 +319,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void delete(ChangeData cd) throws IOException {
|
||||
Term id = QueryBuilder.idTerm(cd);
|
||||
try {
|
||||
Futures.allAsList(
|
||||
openIndex.delete(id),
|
||||
closedIndex.delete(id)).get();
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void delete(int id) throws IOException {
|
||||
public void delete(Change.Id id) throws IOException {
|
||||
Term idTerm = QueryBuilder.idTerm(id);
|
||||
try {
|
||||
Futures.allAsList(
|
||||
|
Reference in New Issue
Block a user