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}.
*/
public class PKIndexSplitter {
private final Filter docsInFirstIndex;
private final Directory input;

View File

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

View File

@ -285,7 +285,7 @@ public abstract class LogMergePolicy extends MergePolicy {
private MergeSpecification findMergesForOptimizeMaxNumSegments(SegmentInfos infos, int maxNumSegments, int last) throws IOException {
MergeSpecification spec = new MergeSpecification();
final List<SegmentInfo> segments = infos.asList();
// First, enroll all "full" merges (size
// mergeFactor) to potentially be run concurrently:
while (last - maxNumSegments + 1 >= mergeFactor) {
@ -353,7 +353,7 @@ public abstract class LogMergePolicy extends MergePolicy {
assert maxNumSegments > 0;
if (verbose()) {
message("findMergesForOptimize: maxNumSegs=" + maxNumSegments + " segsToOptimize= "+ segmentsToOptimize);
message("findMergesForOptimize: maxNumSegs=" + maxNumSegments + " segsToOptimize="+ segmentsToOptimize);
}
// If the segments are already optimized (e.g. there's only 1 segment), or
@ -401,7 +401,7 @@ public abstract class LogMergePolicy extends MergePolicy {
break;
}
}
if (anyTooLarge) {
return findMergesForOptimizeSizeLimit(infos, maxNumSegments, last);
} else {