LUCENE-3197: must also count the segment being produced by an in-flight merge as original (as of when optimize starts) to ensure all deletions against that segment are also merged away

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1137330 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2011-06-19 10:15:32 +00:00
parent 2e48814dff
commit 9c2a21ce29
3 changed files with 9 additions and 5 deletions

View File

@ -34,6 +34,7 @@ import org.apache.lucene.util.Version;
/** /**
* Split an index based on a {@link Filter}. * Split an index based on a {@link Filter}.
*/ */
public class PKIndexSplitter { public class PKIndexSplitter {
private final Filter docsInFirstIndex; private final Filter docsInFirstIndex;
private final Directory input; private final Directory input;

View File

@ -1674,11 +1674,13 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
for(final MergePolicy.OneMerge merge : pendingMerges) { for(final MergePolicy.OneMerge merge : pendingMerges) {
merge.optimize = true; merge.optimize = true;
merge.maxNumSegmentsOptimize = maxNumSegments; merge.maxNumSegmentsOptimize = maxNumSegments;
segmentsToOptimize.put(merge.info, Boolean.TRUE);
} }
for ( final MergePolicy.OneMerge merge: runningMerges ) { for ( final MergePolicy.OneMerge merge: runningMerges ) {
merge.optimize = true; merge.optimize = true;
merge.maxNumSegmentsOptimize = maxNumSegments; merge.maxNumSegmentsOptimize = maxNumSegments;
segmentsToOptimize.put(merge.info, Boolean.TRUE);
} }
} }
@ -1891,7 +1893,6 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
final MergePolicy.MergeSpecification spec; final MergePolicy.MergeSpecification spec;
if (optimize) { if (optimize) {
spec = mergePolicy.findMergesForOptimize(segmentInfos, maxNumSegmentsOptimize, Collections.unmodifiableMap(segmentsToOptimize)); spec = mergePolicy.findMergesForOptimize(segmentInfos, maxNumSegmentsOptimize, Collections.unmodifiableMap(segmentsToOptimize));
if (spec != null) { if (spec != null) {
final int numMerges = spec.merges.size(); final int numMerges = spec.merges.size();
for(int i=0;i<numMerges;i++) { for(int i=0;i<numMerges;i++) {
@ -3044,8 +3045,10 @@ public class IndexWriter implements Closeable, TwoPhaseCommit {
if (merge.optimize) { if (merge.optimize) {
// cascade the optimize: // cascade the optimize:
if (!segmentsToOptimize.containsKey(merge.info)) {
segmentsToOptimize.put(merge.info, Boolean.FALSE); segmentsToOptimize.put(merge.info, Boolean.FALSE);
} }
}
return true; return true;
} }