Store mergeable field from cache in index

Eventually this will no longer be part of the serialized change proto,
and even with the cache it is still expensive to check mergeability
for each change in a list of search results, as the submit type must
still be checked in order to look up the mergeability.

The new MERGEABLE field now loads from the cache, although ChangeJson
and several other callers still depend on the field in Change. This
will facilitate index schema upgrades, in that a full reindex will
also populate the persistent cache.

While we're at it, upgrade Lucene to 4.10.1, which contains some
important stability bugfixes[1].

[1] http://lucene.apache.org/core/4_10_1/changes/Changes.html#v4.10.1

Change-Id: I166b85f91bd596a3f0295616c2e72853b692dd54
This commit is contained in:
Dave Borowitz
2014-10-17 14:51:03 -07:00
parent 094ee4daa1
commit 2ab1af186e
14 changed files with 228 additions and 89 deletions

View File

@@ -119,8 +119,10 @@ public class LuceneChangeIndex implements ChangeIndex {
private static final String CHANGE_FIELD = ChangeField.CHANGE.getName();
private static final String DELETED_FIELD = ChangeField.DELETED.getName();
private static final String ID_FIELD = ChangeField.LEGACY_ID.getName();
private static final String MERGEABLE_FIELD = ChangeField.MERGEABLE.getName();
private static final ImmutableSet<String> FIELDS = ImmutableSet.of(
ADDED_FIELD, APPROVAL_FIELD, CHANGE_FIELD, DELETED_FIELD, ID_FIELD);
ADDED_FIELD, APPROVAL_FIELD, CHANGE_FIELD, DELETED_FIELD, ID_FIELD,
MERGEABLE_FIELD);
private static final Map<String, String> CUSTOM_CHAR_MAPPING = ImmutableMap.of(
"_", " ", ".", " ");
@@ -138,6 +140,8 @@ public class LuceneChangeIndex implements ChangeIndex {
Version lucene47 = Version.LUCENE_47;
@SuppressWarnings("deprecation")
Version lucene48 = Version.LUCENE_48;
@SuppressWarnings("deprecation")
Version lucene410 = Version.LUCENE_4_10_0;
for (Map.Entry<Integer, Schema<ChangeData>> e
: ChangeSchemas.ALL.entrySet()) {
if (e.getKey() <= 3) {
@@ -150,8 +154,10 @@ public class LuceneChangeIndex implements ChangeIndex {
versions.put(e.getValue(), lucene47);
} else if (e.getKey() <= 11) {
versions.put(e.getValue(), lucene48);
} else if (e.getKey() <= 13) {
versions.put(e.getValue(), lucene410);
} else {
versions.put(e.getValue(), Version.LUCENE_4_10_0);
versions.put(e.getValue(), Version.LUCENE_4_10_1);
}
}
LUCENE_VERSIONS = versions.build();
@@ -480,6 +486,14 @@ public class LuceneChangeIndex implements ChangeIndex {
deleted.numericValue().intValue());
}
// Mergeable.
String mergeable = doc.get(MERGEABLE_FIELD);
if ("1".equals(mergeable)) {
cd.setMergeable(true);
} else if ("0".equals(mergeable)) {
cd.setMergeable(false);
}
return cd;
}