diff --git a/lucene/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/src/java/org/apache/lucene/index/IndexWriter.java index 61d9e9a7598..9af6c4a7de0 100644 --- a/lucene/src/java/org/apache/lucene/index/IndexWriter.java +++ b/lucene/src/java/org/apache/lucene/index/IndexWriter.java @@ -2151,7 +2151,8 @@ public class IndexWriter implements Closeable { } SegmentInfos sis = new SegmentInfos(codecs); // read infos from dir sis.read(dir, codecs); - Map dsNames = new HashMap(); + final Set dsFilesCopied = new HashSet(); + final Map dsNames = new HashMap(); for (SegmentInfo info : sis) { assert !infos.contains(info): "dup info dir=" + info.dir + " name=" + info.name; @@ -2160,7 +2161,7 @@ public class IndexWriter implements Closeable { String dsName = info.getDocStoreSegment(); if (infoStream != null) { - message("addIndexes: process segment origName=" + info.name + " newName=" + newSegName + " dsName=" + dsName); + message("addIndexes: process segment origName=" + info.name + " newName=" + newSegName + " dsName=" + dsName + " info=" + info); } // Determine if the doc store of this segment needs to be copied. It's @@ -2170,22 +2171,32 @@ public class IndexWriter implements Closeable { // NOTE: pre-3x segments include a null DSName if they don't share doc // store. So the following code ensures we don't accidentally insert // 'null' to the map. - String newDsName = newSegName; - boolean docStoreCopied = false; - if (dsNames.containsKey(dsName)) { - newDsName = dsNames.get(dsName); - docStoreCopied = true; - } else if (dsName != null) { - dsNames.put(dsName, newSegName); - docStoreCopied = false; + final String newDsName; + if (dsName != null) { + if (dsNames.containsKey(dsName)) { + newDsName = dsNames.get(dsName); + } else { + dsNames.put(dsName, newSegName); + newDsName = newSegName; + } + } else { + newDsName = newSegName; } // Copy the segment files - for (String file : info.files()) { - if (docStoreCopied && IndexFileNames.isDocStoreFile(file)) { - continue; - } - dir.copy(directory, file, newSegName + IndexFileNames.stripSegmentName(file)); + for (String file: info.files()) { + final String newFileName; + if (IndexFileNames.isDocStoreFile(file)) { + newFileName = newDsName + IndexFileNames.stripSegmentName(file); + if (dsFilesCopied.contains(newFileName)) { + continue; + } + dsFilesCopied.add(newFileName); + } else { + newFileName = newSegName + IndexFileNames.stripSegmentName(file); + } + assert !directory.fileExists(newFileName): "file \"" + newFileName + "\" already exists"; + dir.copy(directory, file, newFileName); } // Update SI appropriately diff --git a/lucene/src/java/org/apache/lucene/index/SegmentInfo.java b/lucene/src/java/org/apache/lucene/index/SegmentInfo.java index f1ec386ff80..afb5f1744c7 100644 --- a/lucene/src/java/org/apache/lucene/index/SegmentInfo.java +++ b/lucene/src/java/org/apache/lucene/index/SegmentInfo.java @@ -581,6 +581,9 @@ public final class SegmentInfo { if (this.dir != dir) { s.append('x'); } + if (hasVectors) { + s.append('v'); + } s.append(docCount); int delCount = getDelCount() + pendingDelCount; diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterMerging.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterMerging.java index 804db65d15c..6278b52c42c 100644 --- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterMerging.java +++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterMerging.java @@ -60,7 +60,7 @@ public class TestIndexWriterMerging extends LuceneTestCase newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer()). setMergePolicy(newLogMergePolicy(2)) ); - + writer.setInfoStream(VERBOSE ? System.out : null); writer.addIndexes(indexA, indexB); writer.optimize(); writer.close(); diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java index 6702612be97..5016f5245d4 100644 --- a/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java +++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java @@ -209,7 +209,7 @@ public class TestIndexWriterOnDiskFull extends LuceneTestCase { System.out.println("TEST: iter=" + iter); // Start with 100 bytes more than we are currently using: - long diskFree = diskUsage+100; + long diskFree = diskUsage+_TestUtil.nextInt(random, 50, 200); int method = iter; @@ -226,12 +226,16 @@ public class TestIndexWriterOnDiskFull extends LuceneTestCase { } while(!done) { + if (VERBOSE) { + System.out.println("TEST: cycle..."); + } // Make a new dir that will enforce disk usage: MockDirectoryWrapper dir = new MockDirectoryWrapper(random, new RAMDirectory(startDir)); writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setOpenMode(OpenMode.APPEND)); IOException err = null; - + writer.setInfoStream(VERBOSE ? System.out : null); + MergeScheduler ms = writer.getConfig().getMergeScheduler(); for(int x=0;x<2;x++) { if (ms instanceof ConcurrentMergeScheduler)