Remove FieldDef.FillArgs

Supporting this in FieldDef required a lot of unnecessary boilerplate
that was (prior to earlier cleanups in this series) only used by the
change index, no other indexes. This also breaks a dependency edge
between the index package and the rest of gerrit-server, making it more
feasible to factor out a new build rule in the future.

Change-Id: I0785c7e2c93df7951818c3ebaa23e1e988686064
This commit is contained in:
Dave Borowitz
2017-08-09 09:43:25 -04:00
parent 6fe38f4323
commit 65dc8b6dd8
17 changed files with 29 additions and 79 deletions

View File

@@ -27,7 +27,6 @@ import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.gerrit.server.config.SitePaths;
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.Index;
import com.google.gerrit.server.index.IndexUtils;
@@ -285,9 +284,9 @@ public abstract class AbstractLuceneIndex<K, V> implements Index<K, V> {
searcherManager.release(searcher);
}
Document toDocument(V obj, FillArgs fillArgs) {
Document toDocument(V obj) {
Document result = new Document();
for (Values<V> vs : schema.buildFields(obj, fillArgs)) {
for (Values<V> vs : schema.buildFields(obj)) {
if (vs.getValues() != null) {
add(result, vs);
}

View File

@@ -109,8 +109,7 @@ public class LuceneAccountIndex extends AbstractLuceneIndex<Account.Id, AccountS
@Override
public void replace(AccountState as) throws IOException {
try {
// No parts of FillArgs are currently required, just use null.
replace(idTerm(as), toDocument(as, null)).get();
replace(idTerm(as), toDocument(as)).get();
} catch (ExecutionException | InterruptedException e) {
throw new IOException(e);
}

View File

@@ -44,7 +44,6 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.StarredChangesUtil;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.SitePaths;
import com.google.gerrit.server.index.FieldDef.FillArgs;
import com.google.gerrit.server.index.IndexExecutor;
import com.google.gerrit.server.index.IndexUtils;
import com.google.gerrit.server.index.QueryOptions;
@@ -142,7 +141,6 @@ public class LuceneChangeIndex implements ChangeIndex {
return QueryBuilder.intTerm(LEGACY_ID.getName(), id.get());
}
private final FillArgs fillArgs;
private final ListeningExecutorService executor;
private final Provider<ReviewDb> db;
private final ChangeData.Factory changeDataFactory;
@@ -158,10 +156,8 @@ public class LuceneChangeIndex implements ChangeIndex {
@IndexExecutor(INTERACTIVE) ListeningExecutorService executor,
Provider<ReviewDb> db,
ChangeData.Factory changeDataFactory,
FillArgs fillArgs,
@Assisted Schema<ChangeData> schema)
throws IOException {
this.fillArgs = fillArgs;
this.executor = executor;
this.db = db;
this.changeDataFactory = changeDataFactory;
@@ -215,7 +211,7 @@ public class LuceneChangeIndex implements ChangeIndex {
Term id = LuceneChangeIndex.idTerm(cd);
// toDocument is essentially static and doesn't depend on the specific
// sub-index, so just pick one.
Document doc = openIndex.toDocument(cd, fillArgs);
Document doc = openIndex.toDocument(cd);
try {
if (cd.change().getStatus().isOpen()) {
Futures.allAsList(closedIndex.delete(id), openIndex.replace(id, doc)).get();

View File

@@ -108,8 +108,7 @@ public class LuceneGroupIndex extends AbstractLuceneIndex<AccountGroup.UUID, Acc
@Override
public void replace(AccountGroup group) throws IOException {
try {
// No parts of FillArgs are currently required, just use null.
replace(idTerm(group), toDocument(group, null)).get();
replace(idTerm(group), toDocument(group)).get();
} catch (ExecutionException | InterruptedException e) {
throw new IOException(e);
}