Rename LEGACY_ID2 field to LEGACY_ID
There is no longer a LEGACY_ID, so we no longer have the confusing situation where we have a legacy legacy-ID field. Change-Id: I0ff4942a3d3f3453c354cbdc1ab3eb4fb056f257
This commit is contained in:
@@ -17,7 +17,7 @@ package com.google.gerrit.lucene;
|
|||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||||
import static com.google.gerrit.server.git.QueueProvider.QueueType.INTERACTIVE;
|
import static com.google.gerrit.server.git.QueueProvider.QueueType.INTERACTIVE;
|
||||||
import static com.google.gerrit.server.index.ChangeField.LEGACY_ID2;
|
import static com.google.gerrit.server.index.ChangeField.LEGACY_ID;
|
||||||
import static com.google.gerrit.server.index.IndexRewriter.CLOSED_STATUSES;
|
import static com.google.gerrit.server.index.IndexRewriter.CLOSED_STATUSES;
|
||||||
import static com.google.gerrit.server.index.IndexRewriter.OPEN_STATUSES;
|
import static com.google.gerrit.server.index.IndexRewriter.OPEN_STATUSES;
|
||||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||||
@@ -134,7 +134,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
private static final String UPDATED_SORT_FIELD =
|
private static final String UPDATED_SORT_FIELD =
|
||||||
sortFieldName(ChangeField.UPDATED);
|
sortFieldName(ChangeField.UPDATED);
|
||||||
private static final String ID_SORT_FIELD =
|
private static final String ID_SORT_FIELD =
|
||||||
sortFieldName(ChangeField.LEGACY_ID2);
|
sortFieldName(ChangeField.LEGACY_ID);
|
||||||
|
|
||||||
private static final Map<String, String> CUSTOM_CHAR_MAPPING = ImmutableMap.of(
|
private static final Map<String, String> CUSTOM_CHAR_MAPPING = ImmutableMap.of(
|
||||||
"_", " ", ".", " ");
|
"_", " ", ".", " ");
|
||||||
@@ -388,7 +388,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
List<ChangeData> result =
|
List<ChangeData> result =
|
||||||
Lists.newArrayListWithCapacity(docs.scoreDocs.length);
|
Lists.newArrayListWithCapacity(docs.scoreDocs.length);
|
||||||
Set<String> fields = fields(opts);
|
Set<String> fields = fields(opts);
|
||||||
String idFieldName = LEGACY_ID2.getName();
|
String idFieldName = LEGACY_ID.getName();
|
||||||
for (int i = opts.start(); i < docs.scoreDocs.length; i++) {
|
for (int i = opts.start(); i < docs.scoreDocs.length; i++) {
|
||||||
ScoreDoc sd = docs.scoreDocs[i];
|
ScoreDoc sd = docs.scoreDocs[i];
|
||||||
Document doc = searchers[sd.shardIndex].doc(sd.doc, fields);
|
Document doc = searchers[sd.shardIndex].doc(sd.doc, fields);
|
||||||
@@ -429,13 +429,13 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> fields(QueryOptions opts) {
|
private Set<String> fields(QueryOptions opts) {
|
||||||
if (schemaHasRequestedField(ChangeField.LEGACY_ID2, opts.fields())
|
if (schemaHasRequestedField(ChangeField.LEGACY_ID, opts.fields())
|
||||||
|| schemaHasRequestedField(ChangeField.CHANGE, opts.fields())) {
|
|| schemaHasRequestedField(ChangeField.CHANGE, opts.fields())) {
|
||||||
return opts.fields();
|
return opts.fields();
|
||||||
}
|
}
|
||||||
// Request the numeric ID field even if the caller did not request it,
|
// Request the numeric ID field even if the caller did not request it,
|
||||||
// otherwise we can't actually construct a ChangeData.
|
// otherwise we can't actually construct a ChangeData.
|
||||||
return Sets.union(opts.fields(), ImmutableSet.of(LEGACY_ID2.getName()));
|
return Sets.union(opts.fields(), ImmutableSet.of(LEGACY_ID.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean schemaHasRequestedField(FieldDef<ChangeData, ?> field,
|
private boolean schemaHasRequestedField(FieldDef<ChangeData, ?> field,
|
||||||
@@ -556,7 +556,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
FieldDef<ChangeData, ?> f = values.getField();
|
FieldDef<ChangeData, ?> f = values.getField();
|
||||||
|
|
||||||
// Add separate DocValues fields for those fields needed for sorting.
|
// Add separate DocValues fields for those fields needed for sorting.
|
||||||
if (f == ChangeField.LEGACY_ID2) {
|
if (f == ChangeField.LEGACY_ID) {
|
||||||
int v = (Integer) getOnlyElement(values.getValues());
|
int v = (Integer) getOnlyElement(values.getValues());
|
||||||
doc.add(new NumericDocValuesField(sortFieldName(f), v));
|
doc.add(new NumericDocValuesField(sortFieldName(f), v));
|
||||||
} else if (f == ChangeField.UPDATED) {
|
} else if (f == ChangeField.UPDATED) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.lucene;
|
package com.google.gerrit.lucene;
|
||||||
|
|
||||||
import static com.google.gerrit.server.index.ChangeField.LEGACY_ID2;
|
import static com.google.gerrit.server.index.ChangeField.LEGACY_ID;
|
||||||
import static org.apache.lucene.search.BooleanClause.Occur.MUST;
|
import static org.apache.lucene.search.BooleanClause.Occur.MUST;
|
||||||
import static org.apache.lucene.search.BooleanClause.Occur.MUST_NOT;
|
import static org.apache.lucene.search.BooleanClause.Occur.MUST_NOT;
|
||||||
import static org.apache.lucene.search.BooleanClause.Occur.SHOULD;
|
import static org.apache.lucene.search.BooleanClause.Occur.SHOULD;
|
||||||
@@ -51,11 +51,11 @@ import java.util.List;
|
|||||||
public class QueryBuilder {
|
public class QueryBuilder {
|
||||||
|
|
||||||
public static Term idTerm(ChangeData cd) {
|
public static Term idTerm(ChangeData cd) {
|
||||||
return intTerm(LEGACY_ID2.getName(), cd.getId().get());
|
return intTerm(LEGACY_ID.getName(), cd.getId().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Term idTerm(Change.Id id) {
|
public static Term idTerm(Change.Id id) {
|
||||||
return intTerm(LEGACY_ID2.getName(), id.get());
|
return intTerm(LEGACY_ID.getName(), id.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final org.apache.lucene.util.QueryBuilder queryBuilder;
|
private final org.apache.lucene.util.QueryBuilder queryBuilder;
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
public class ChangeField {
|
public class ChangeField {
|
||||||
/** Legacy change ID. */
|
/** Legacy change ID. */
|
||||||
public static final FieldDef<ChangeData, Integer> LEGACY_ID2 =
|
public static final FieldDef<ChangeData, Integer> LEGACY_ID =
|
||||||
new FieldDef.Single<ChangeData, Integer>("legacy_id",
|
new FieldDef.Single<ChangeData, Integer>("legacy_id",
|
||||||
FieldType.INTEGER, true) {
|
FieldType.INTEGER, true) {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import java.util.Map;
|
|||||||
/** Secondary index schemas for changes. */
|
/** Secondary index schemas for changes. */
|
||||||
public class ChangeSchemas {
|
public class ChangeSchemas {
|
||||||
static final Schema<ChangeData> V25 = schema(
|
static final Schema<ChangeData> V25 = schema(
|
||||||
ChangeField.LEGACY_ID2,
|
ChangeField.LEGACY_ID,
|
||||||
ChangeField.ID,
|
ChangeField.ID,
|
||||||
ChangeField.STATUS,
|
ChangeField.STATUS,
|
||||||
ChangeField.PROJECT,
|
ChangeField.PROJECT,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.query.change;
|
package com.google.gerrit.server.query.change;
|
||||||
|
|
||||||
import static com.google.gerrit.server.index.ChangeField.LEGACY_ID2;
|
import static com.google.gerrit.server.index.ChangeField.LEGACY_ID;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.server.index.IndexPredicate;
|
import com.google.gerrit.server.index.IndexPredicate;
|
||||||
@@ -24,7 +24,7 @@ public class LegacyChangeIdPredicate extends IndexPredicate<ChangeData> {
|
|||||||
private final Change.Id id;
|
private final Change.Id id;
|
||||||
|
|
||||||
LegacyChangeIdPredicate(Change.Id id) {
|
LegacyChangeIdPredicate(Change.Id id) {
|
||||||
super(LEGACY_ID2, ChangeQueryBuilder.FIELD_CHANGE, id.toString());
|
super(LEGACY_ID, ChangeQueryBuilder.FIELD_CHANGE, id.toString());
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user