Split change index into two for open/closed changes
When preprocessing predicates to send to the index, determine the set of change statuses that can possibly match that change, and use this to send the query to the minimal set of indexes needed to satisfy it. Do not attempt to rewrite the query further by e.g. splitting the result and pruning subtrees that cannot be satisfied by a particular index; assume once we hit the index, the extra cost of branches that cannot contribute to the result is negligible. When updating a change, delete the change from the index where it doesn't belong. This adds an indexing step at many more places that modify changes. Change-Id: I928d34c883d3f8558e9324db5fa558f7b3b97612
This commit is contained in:
@@ -36,7 +36,8 @@ import java.util.Map;
|
||||
|
||||
public class IndexVersionCheck implements LifecycleListener {
|
||||
public static final Map<String, Integer> SCHEMA_VERSIONS = ImmutableMap.of(
|
||||
"changes", ChangeField.SCHEMA_VERSION);
|
||||
"changes_open", ChangeField.SCHEMA_VERSION,
|
||||
"changes_closed", ChangeField.SCHEMA_VERSION);
|
||||
|
||||
public static File gerritIndexConfig(SitePaths sitePaths) {
|
||||
return new File(sitePaths.index_dir, "gerrit_index.config");
|
||||
|
||||
@@ -21,9 +21,7 @@ import static org.apache.lucene.search.BooleanClause.Occur.MUST_NOT;
|
||||
import static org.apache.lucene.search.BooleanClause.Occur.SHOULD;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.extensions.events.LifecycleListener;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.config.SitePaths;
|
||||
import com.google.gerrit.server.index.ChangeField;
|
||||
import com.google.gerrit.server.index.ChangeIndex;
|
||||
import com.google.gerrit.server.index.FieldDef;
|
||||
@@ -39,8 +37,6 @@ import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.ChangeDataSource;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.ResultSet;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.apache.lucene.analysis.standard.StandardAnalyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
@@ -132,6 +128,12 @@ public class LuceneChangeIndex implements ChangeIndex {
|
||||
commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(ChangeData cd) throws IOException {
|
||||
writer.deleteDocuments(intTerm(FIELD_CHANGE, cd.getId().get()));
|
||||
commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangeDataSource getSource(Predicate<ChangeData> p)
|
||||
throws QueryParseException {
|
||||
|
||||
Reference in New Issue
Block a user