Remove ChangeData factory method used only by old index schemas
Change-Id: I6d004dd0a5ae23d654d073cc7e876e00ebb031c0
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.elasticsearch;
|
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.APPROVAL_CODEC;
|
||||||
import static com.google.gerrit.server.index.change.ChangeField.CHANGE_CODEC;
|
import static com.google.gerrit.server.index.change.ChangeField.CHANGE_CODEC;
|
||||||
import static com.google.gerrit.server.index.change.ChangeField.PATCH_SET_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) {
|
if (c == null) {
|
||||||
int id = source.get(ChangeField.LEGACY_ID.getName()).getAsInt();
|
int id = source.get(ChangeField.LEGACY_ID.getName()).getAsInt();
|
||||||
String projectName = source.get(ChangeField.PROJECT.getName()).getAsString();
|
// IndexUtils#changeFields ensures either CHANGE or PROJECT is always present.
|
||||||
if (projectName == null) {
|
String projectName = checkNotNull(source.get(ChangeField.PROJECT.getName()).getAsString());
|
||||||
return changeDataFactory.createOnlyWhenNoteDbDisabled(db.get(), new Change.Id(id));
|
|
||||||
}
|
|
||||||
return changeDataFactory.create(
|
return changeDataFactory.create(
|
||||||
db.get(), new Project.NameKey(projectName), new Change.Id(id));
|
db.get(), new Project.NameKey(projectName), new Change.Id(id));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -429,15 +429,10 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
} else {
|
} else {
|
||||||
IndexableField f = Iterables.getFirst(doc.get(idFieldName), null);
|
IndexableField f = Iterables.getFirst(doc.get(idFieldName), null);
|
||||||
Change.Id id = new Change.Id(f.numericValue().intValue());
|
Change.Id id = new Change.Id(f.numericValue().intValue());
|
||||||
IndexableField project = Iterables.getFirst(doc.get(PROJECT.getName()), null);
|
// IndexUtils#changeFields ensures either CHANGE or PROJECT is always present.
|
||||||
if (project == null) {
|
IndexableField project = doc.get(PROJECT.getName()).iterator().next();
|
||||||
// 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);
|
cd = changeDataFactory.create(db.get(), new Project.NameKey(project.stringValue()), id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (fields.contains(PATCH_SET_FIELD)) {
|
if (fields.contains(PATCH_SET_FIELD)) {
|
||||||
decodePatchSets(doc, cd);
|
decodePatchSets(doc, cd);
|
||||||
|
|||||||
@@ -286,9 +286,6 @@ public class ChangeData {
|
|||||||
ChangeData create(ReviewDb db, ChangeNotes cn);
|
ChangeData create(ReviewDb db, ChangeNotes cn);
|
||||||
|
|
||||||
ChangeData create(ReviewDb db, ChangeControl c);
|
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();
|
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) {
|
public ChangeData setLazyLoad(boolean load) {
|
||||||
lazyLoad = load;
|
lazyLoad = load;
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
Reference in New Issue
Block a user