LUCNEE-1642: respect destination IW's CFS when copying tail segments in addIndexesNoOptimize

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@783748 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2009-06-11 12:52:13 +00:00
parent fd63593d66
commit 9dc231fb74
2 changed files with 18 additions and 1 deletions

View File

@ -3583,7 +3583,7 @@ public class IndexWriter {
info = segmentInfos.info(i); info = segmentInfos.info(i);
if (info.dir != directory) { if (info.dir != directory) {
done = false; done = false;
final MergePolicy.OneMerge newMerge = new MergePolicy.OneMerge(segmentInfos.range(i, 1+i), info.getUseCompoundFile()); final MergePolicy.OneMerge newMerge = new MergePolicy.OneMerge(segmentInfos.range(i, 1+i), mergePolicy instanceof LogMergePolicy && getUseCompoundFile());
// Returns true if no running merge conflicts // Returns true if no running merge conflicts
// with this one (and, records this merge as // with this one (and, records this merge as

View File

@ -537,4 +537,21 @@ public class TestAddIndexesNoOptimize extends LuceneTestCase {
dir.close(); dir.close();
dir2.close(); dir2.close();
} }
// LUCENE-1642: make sure CFS of destination indexwriter
// is respected when copying tail segments
public void testTargetCFS() throws IOException {
Directory dir = new RAMDirectory();
IndexWriter writer = newWriter(dir, true);
writer.setUseCompoundFile(false);
addDocs(writer, 1);
writer.close();
Directory other = new RAMDirectory();
writer = newWriter(other, true);
writer.setUseCompoundFile(true);
writer.addIndexesNoOptimize(new Directory[] {dir});
assertTrue(writer.newestSegment().getUseCompoundFile());
writer.close();
}
} }