You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2015/07/06 16:50:11 UTC
svn commit: r1689420 - in /lucene/dev/trunk: ./ lucene/
lucene/backward-codecs/
lucene/backward-codecs/src/test/org/apache/lucene/index/ lucene/core/
lucene/core/src/java/org/apache/lucene/index/
Author: uschindler
Date: Mon Jul 6 14:50:11 2015
New Revision: 1689420
URL: http://svn.apache.org/r1689420
Log:
Merged revision(s) 1689411 from lucene/dev/branches/branch_5x:
LUCENE-6658: Fix IndexUpgrader to also upgrade indexes without any segments
Added:
lucene/dev/trunk/lucene/backward-codecs/src/test/org/apache/lucene/index/empty.5.0.0.zip (with props)
Modified:
lucene/dev/trunk/ (props changed)
lucene/dev/trunk/lucene/ (props changed)
lucene/dev/trunk/lucene/CHANGES.txt (contents, props changed)
lucene/dev/trunk/lucene/backward-codecs/ (props changed)
lucene/dev/trunk/lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
lucene/dev/trunk/lucene/core/ (props changed)
lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/IndexUpgrader.java
Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=1689420&r1=1689419&r2=1689420&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Mon Jul 6 14:50:11 2015
@@ -236,6 +236,9 @@ Bug fixes
* LUCENE-6586: Fix typo in GermanStemmer, causing possible wrong value
for substCount. (Christoph Kaser via Mike McCandless)
+* LUCENE-6658: Fix IndexUpgrader to also upgrade indexes without any
+ segments. (Trejkaz, Uwe Schindler)
+
Changes in Runtime Behavior
* LUCENE-6501: The subreader structure in ParallelCompositeReader
Modified: lucene/dev/trunk/lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?rev=1689420&r1=1689419&r2=1689420&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (original)
+++ lucene/dev/trunk/lucene/backward-codecs/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java Mon Jul 6 14:50:11 2015
@@ -1118,6 +1118,7 @@ public class TestBackwardsCompatibility
for (SegmentCommitInfo si : infos) {
assertEquals(Version.LATEST, si.info.getVersion());
}
+ assertEquals(Version.LATEST, infos.getCommitLuceneVersion());
return infos.size();
}
@@ -1257,6 +1258,20 @@ public class TestBackwardsCompatibility
}
}
+ public static final String emptyIndex = "empty.5.0.0.zip";
+
+ public void testUpgradeEmptyOldIndex() throws Exception {
+ Path oldIndexDir = createTempDir("emptyIndex");
+ TestUtil.unzip(getDataInputStream(emptyIndex), oldIndexDir);
+ Directory dir = newFSDirectory(oldIndexDir);
+
+ newIndexUpgrader(dir).upgrade();
+
+ checkAllSegmentsUpgraded(dir);
+
+ dir.close();
+ }
+
public static final String moreTermsIndex = "moreterms.5.0.0.zip";
public void testMoreTerms() throws Exception {
Added: lucene/dev/trunk/lucene/backward-codecs/src/test/org/apache/lucene/index/empty.5.0.0.zip
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/backward-codecs/src/test/org/apache/lucene/index/empty.5.0.0.zip?rev=1689420&view=auto
==============================================================================
Binary file - no diff available.
Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/IndexUpgrader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/IndexUpgrader.java?rev=1689420&r1=1689419&r2=1689420&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/IndexUpgrader.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/index/IndexUpgrader.java Mon Jul 6 14:50:11 2015
@@ -52,6 +52,8 @@ import java.util.Collection;
* documents.
*/
public final class IndexUpgrader {
+
+ private static final String LOG_PREFIX = "IndexUpgrader";
@SuppressForbidden(reason = "System.out required: command line tool")
private static void printUsage() {
@@ -162,18 +164,22 @@ public final class IndexUpgrader {
iwc.setMergePolicy(new UpgradeIndexMergePolicy(iwc.getMergePolicy()));
iwc.setIndexDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
- final IndexWriter w = new IndexWriter(dir, iwc);
- try {
+ try (final IndexWriter w = new IndexWriter(dir, iwc)) {
InfoStream infoStream = iwc.getInfoStream();
- if (infoStream.isEnabled("IndexUpgrader")) {
- infoStream.message("IndexUpgrader", "Upgrading all pre-" + Version.LATEST + " segments of index directory '" + dir + "' to version " + Version.LATEST + "...");
+ if (infoStream.isEnabled(LOG_PREFIX)) {
+ infoStream.message(LOG_PREFIX, "Upgrading all pre-" + Version.LATEST + " segments of index directory '" + dir + "' to version " + Version.LATEST + "...");
}
w.forceMerge(1);
- if (infoStream.isEnabled("IndexUpgrader")) {
- infoStream.message("IndexUpgrader", "All segments upgraded to version " + Version.LATEST);
+ if (infoStream.isEnabled(LOG_PREFIX)) {
+ infoStream.message(LOG_PREFIX, "All segments upgraded to version " + Version.LATEST);
+ infoStream.message(LOG_PREFIX, "Enforcing commit to rewrite all index metadata...");
+ }
+ w.setCommitData(w.getCommitData()); // fake change to enforce a commit (e.g. if index has no segments)
+ assert w.hasUncommittedChanges();
+ w.commit();
+ if (infoStream.isEnabled(LOG_PREFIX)) {
+ infoStream.message(LOG_PREFIX, "Committed upgraded metadata to index.");
}
- } finally {
- w.close();
}
}