Don't run SQL rewrites when secondary index is enabled
If the secondary index is enabled on a server the index handles all queries. There is no reason to run the SQL rewrites or to leave predicates in the predicate tree without being wrapped by the IndexedChangeQuery predicate. Change-Id: I18defed2a5a6003b9ae6ba227e29864b5c912e7b
This commit is contained in:
@@ -16,8 +16,8 @@ package com.google.gerrit.lucene;
|
||||
|
||||
import static com.google.gerrit.lucene.IndexVersionCheck.SCHEMA_VERSIONS;
|
||||
import static com.google.gerrit.lucene.IndexVersionCheck.gerritIndexConfig;
|
||||
import static com.google.gerrit.server.query.change.IndexRewriteImpl.CLOSED_STATUSES;
|
||||
import static com.google.gerrit.server.query.change.IndexRewriteImpl.OPEN_STATUSES;
|
||||
import static com.google.gerrit.server.index.IndexRewriteImpl.CLOSED_STATUSES;
|
||||
import static com.google.gerrit.server.index.IndexRewriteImpl.OPEN_STATUSES;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -34,11 +34,11 @@ import com.google.gerrit.server.index.ChangeIndex;
|
||||
import com.google.gerrit.server.index.FieldDef;
|
||||
import com.google.gerrit.server.index.FieldDef.FillArgs;
|
||||
import com.google.gerrit.server.index.FieldType;
|
||||
import com.google.gerrit.server.index.IndexRewriteImpl;
|
||||
import com.google.gerrit.server.query.Predicate;
|
||||
import com.google.gerrit.server.query.QueryParseException;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.ChangeDataSource;
|
||||
import com.google.gerrit.server.query.change.IndexRewriteImpl;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.ResultSet;
|
||||
|
||||
@@ -258,6 +258,11 @@ public class LuceneChangeIndex implements ChangeIndex, LifecycleListener {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return query.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet<ChangeData> read() throws OrmException {
|
||||
IndexSearcher[] searchers = new IndexSearcher[indexes.size()];
|
||||
|
@@ -121,8 +121,8 @@ public class QueryBuilder {
|
||||
private static Query sortKeyQuery(SortKeyPredicate p) {
|
||||
return NumericRangeQuery.newLongRange(
|
||||
p.getField().getName(),
|
||||
p.getMinValue(),
|
||||
p.getMaxValue(),
|
||||
p.getMinValue() != Long.MIN_VALUE ? p.getMinValue() : null,
|
||||
p.getMaxValue() != Long.MAX_VALUE ? p.getMaxValue() : null,
|
||||
true, true);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user