Remove ChangeData factory method used only by old index schemas

Change-Id: I6d004dd0a5ae23d654d073cc7e876e00ebb031c0
This commit is contained in:
Dave Borowitz 2017-08-09 09:11:32 -04:00
parent 1b15877db6
commit 03b46de12a
3 changed files with 6 additions and 61 deletions

View File

@ -14,6 +14,7 @@
package com.google.gerrit.elasticsearch;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.gerrit.server.index.change.ChangeField.APPROVAL_CODEC;
import static com.google.gerrit.server.index.change.ChangeField.CHANGE_CODEC;
import static com.google.gerrit.server.index.change.ChangeField.PATCH_SET_CODEC;
@ -272,10 +273,8 @@ class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
if (c == null) {
int id = source.get(ChangeField.LEGACY_ID.getName()).getAsInt();
String projectName = source.get(ChangeField.PROJECT.getName()).getAsString();
if (projectName == null) {
return changeDataFactory.createOnlyWhenNoteDbDisabled(db.get(), new Change.Id(id));
}
// IndexUtils#changeFields ensures either CHANGE or PROJECT is always present.
String projectName = checkNotNull(source.get(ChangeField.PROJECT.getName()).getAsString());
return changeDataFactory.create(
db.get(), new Project.NameKey(projectName), new Change.Id(id));
}

View File

@ -429,14 +429,9 @@ public class LuceneChangeIndex implements ChangeIndex {
} else {
IndexableField f = Iterables.getFirst(doc.get(idFieldName), null);
Change.Id id = new Change.Id(f.numericValue().intValue());
IndexableField project = Iterables.getFirst(doc.get(PROJECT.getName()), null);
if (project == null) {
// Old schema without project field: we can safely assume NoteDb is
// disabled.
cd = changeDataFactory.createOnlyWhenNoteDbDisabled(db.get(), id);
} else {
cd = changeDataFactory.create(db.get(), new Project.NameKey(project.stringValue()), id);
}
// IndexUtils#changeFields ensures either CHANGE or PROJECT is always present.
IndexableField project = doc.get(PROJECT.getName()).iterator().next();
cd = changeDataFactory.create(db.get(), new Project.NameKey(project.stringValue()), id);
}
if (fields.contains(PATCH_SET_FIELD)) {

View File

@ -286,9 +286,6 @@ public class ChangeData {
ChangeData create(ReviewDb db, ChangeNotes cn);
ChangeData create(ReviewDb db, ChangeControl c);
// TODO(dborowitz): Remove when deleting index schemas <27.
ChangeData createOnlyWhenNoteDbDisabled(ReviewDb db, Change.Id id);
}
/**
@ -550,52 +547,6 @@ public class ChangeData {
project = notes.getProjectName();
}
@AssistedInject
private ChangeData(
GitRepositoryManager repoManager,
ChangeControl.GenericFactory changeControlFactory,
IdentifiedUser.GenericFactory userFactory,
AccountCache accountCache,
Accounts accounts,
Emails emails,
ProjectCache projectCache,
MergeUtil.Factory mergeUtilFactory,
ChangeNotes.Factory notesFactory,
ApprovalsUtil approvalsUtil,
ChangeMessagesUtil cmUtil,
CommentsUtil commentsUtil,
PatchSetUtil psUtil,
PatchListCache patchListCache,
NotesMigration notesMigration,
MergeabilityCache mergeabilityCache,
@Nullable StarredChangesUtil starredChangesUtil,
@Assisted ReviewDb db,
@Assisted Change.Id id) {
checkState(
!notesMigration.readChanges(),
"do not call createOnlyWhenNoteDbDisabled when NoteDb is enabled");
this.db = db;
this.repoManager = repoManager;
this.changeControlFactory = changeControlFactory;
this.userFactory = userFactory;
this.accountCache = accountCache;
this.accounts = accounts;
this.emails = emails;
this.projectCache = projectCache;
this.mergeUtilFactory = mergeUtilFactory;
this.notesFactory = notesFactory;
this.approvalsUtil = approvalsUtil;
this.cmUtil = cmUtil;
this.commentsUtil = commentsUtil;
this.psUtil = psUtil;
this.patchListCache = patchListCache;
this.notesMigration = notesMigration;
this.mergeabilityCache = mergeabilityCache;
this.starredChangesUtil = starredChangesUtil;
this.legacyId = id;
this.project = null;
}
public ChangeData setLazyLoad(boolean load) {
lazyLoad = load;
return this;