diff --git a/gerrit-lucene/src/main/java/com/google/gerrit/lucene/AutoCommitWriter.java b/gerrit-lucene/src/main/java/com/google/gerrit/lucene/AutoCommitWriter.java index fd14cd9c06..e0c13ae03a 100644 --- a/gerrit-lucene/src/main/java/com/google/gerrit/lucene/AutoCommitWriter.java +++ b/gerrit-lucene/src/main/java/com/google/gerrit/lucene/AutoCommitWriter.java @@ -82,7 +82,7 @@ class AutoCommitWriter extends IndexWriter { } @Override - public void deleteDocuments(Term term) throws IOException { + public void deleteDocuments(Term... term) throws IOException { super.deleteDocuments(term); autoFlush(); } @@ -97,18 +97,6 @@ class AutoCommitWriter extends IndexWriter { return ret; } - @Override - public void deleteDocuments(Term... terms) throws IOException { - super.deleteDocuments(terms); - autoFlush(); - } - - @Override - public void deleteDocuments(Query query) throws IOException { - super.deleteDocuments(query); - autoFlush(); - } - @Override public void deleteDocuments(Query... queries) throws IOException { super.deleteDocuments(queries); diff --git a/gerrit-lucene/src/main/java/com/google/gerrit/lucene/LuceneChangeIndex.java b/gerrit-lucene/src/main/java/com/google/gerrit/lucene/LuceneChangeIndex.java index 365f7e97d3..2faece4ab2 100644 --- a/gerrit-lucene/src/main/java/com/google/gerrit/lucene/LuceneChangeIndex.java +++ b/gerrit-lucene/src/main/java/com/google/gerrit/lucene/LuceneChangeIndex.java @@ -136,6 +136,8 @@ public class LuceneChangeIndex implements ChangeIndex { Version lucene46 = Version.LUCENE_46; @SuppressWarnings("deprecation") Version lucene47 = Version.LUCENE_47; + @SuppressWarnings("deprecation") + Version lucene48 = Version.LUCENE_48; for (Map.Entry> e : ChangeSchemas.ALL.entrySet()) { if (e.getKey() <= 3) { @@ -146,8 +148,10 @@ public class LuceneChangeIndex implements ChangeIndex { versions.put(e.getValue(), lucene46); } else if (e.getKey() <= 10) { versions.put(e.getValue(), lucene47); + } else if (e.getKey() <= 11) { + versions.put(e.getValue(), lucene48); } else { - versions.put(e.getValue(), Version.LUCENE_48); + versions.put(e.getValue(), Version.LUCENE_4_10_0); } } LUCENE_VERSIONS = versions.build(); @@ -175,7 +179,7 @@ public class LuceneChangeIndex implements ChangeIndex { private GerritIndexWriterConfig(Version version, Config cfg, String name) { CustomMappingAnalyzer analyzer = - new CustomMappingAnalyzer(new StandardAnalyzer(version, + new CustomMappingAnalyzer(new StandardAnalyzer( CharArraySet.EMPTY_SET), CUSTOM_CHAR_MAPPING); luceneConfig = new IndexWriterConfig(version, analyzer); luceneConfig.setOpenMode(OpenMode.CREATE_OR_APPEND); @@ -241,8 +245,8 @@ public class LuceneChangeIndex implements ChangeIndex { LUCENE_VERSIONS.get(schema), "unknown Lucene version for index schema: %s", schema); CustomMappingAnalyzer analyzer = - new CustomMappingAnalyzer(new StandardAnalyzer(luceneVersion, - CharArraySet.EMPTY_SET), CUSTOM_CHAR_MAPPING); + new CustomMappingAnalyzer(new StandardAnalyzer(CharArraySet.EMPTY_SET), + CUSTOM_CHAR_MAPPING); queryBuilder = new QueryBuilder(schema, analyzer); GerritIndexWriterConfig openConfig = diff --git a/gerrit-lucene/src/main/java/com/google/gerrit/lucene/QueryBuilder.java b/gerrit-lucene/src/main/java/com/google/gerrit/lucene/QueryBuilder.java index dfe3f2d215..fecd77abda 100644 --- a/gerrit-lucene/src/main/java/com/google/gerrit/lucene/QueryBuilder.java +++ b/gerrit-lucene/src/main/java/com/google/gerrit/lucene/QueryBuilder.java @@ -43,7 +43,7 @@ import org.apache.lucene.search.PrefixQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.RegexpQuery; import org.apache.lucene.search.TermQuery; -import org.apache.lucene.util.BytesRef; +import org.apache.lucene.util.BytesRefBuilder; import org.apache.lucene.util.NumericUtils; import java.util.Date; @@ -154,9 +154,9 @@ public class QueryBuilder { } private static Term intTerm(String name, int value) { - BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_INT); - NumericUtils.intToPrefixCodedBytes(value, 0, bytes); - return new Term(name, bytes); + BytesRefBuilder builder = new BytesRefBuilder(); + NumericUtils.intToPrefixCodedBytes(value, 0, builder); + return new Term(name, builder.get()); } private Query intQuery(IndexPredicate p) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/index/ChangeSchemas.java b/gerrit-server/src/main/java/com/google/gerrit/server/index/ChangeSchemas.java index 8bb8f0bb31..a1ba14b8ca 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/index/ChangeSchemas.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/index/ChangeSchemas.java @@ -243,7 +243,8 @@ public class ChangeSchemas { ChangeField.DELETED, ChangeField.DELTA); - + // For upgrade to Lucene 4.10.0 index format only. + static final Schema V12 = release(V11.getFields().values()); private static Schema release(Collection> fields) { return new Schema<>(true, fields); diff --git a/lib/lucene/BUCK b/lib/lucene/BUCK index 9ccc5aa59b..dd148b1e29 100644 --- a/lib/lucene/BUCK +++ b/lib/lucene/BUCK @@ -1,11 +1,11 @@ include_defs('//lib/maven.defs') -VERSION = '4.8.1' +VERSION = '4.10.0' maven_jar( name = 'core', id = 'org.apache.lucene:lucene-core:' + VERSION, - sha1 = 'a549eef6316a2c38d4cda932be809107deeaf8a7', + sha1 = 'a4ceea9a80e81fe84e81fe4fccce9e9930dc703a', license = 'Apache2.0', exclude = [ 'META-INF/LICENSE.txt', @@ -16,7 +16,7 @@ maven_jar( maven_jar( name = 'analyzers-common', id = 'org.apache.lucene:lucene-analyzers-common:' + VERSION, - sha1 = '6e3731524351c83cd21022a23bee5e87f0575555', + sha1 = '912962d436d9851dc90091e48251c802d3b65941', license = 'Apache2.0', exclude = [ 'META-INF/LICENSE.txt', @@ -27,6 +27,6 @@ maven_jar( maven_jar( name = 'query-parser', id = 'org.apache.lucene:lucene-queryparser:' + VERSION, - sha1 = 'f3e105d74137906fdeb2c7bc4dd68c08564778f9', + sha1 = '7a00eb4b97a6cb7a5a29957b62c7f002dd71b7ff', license = 'Apache2.0', )