diff --git a/lucene/contrib/misc/src/java/org/apache/lucene/index/PKIndexSplitter.java b/lucene/contrib/misc/src/java/org/apache/lucene/index/PKIndexSplitter.java index 398d99ddb7f..0ecc5fb784e 100644 --- a/lucene/contrib/misc/src/java/org/apache/lucene/index/PKIndexSplitter.java +++ b/lucene/contrib/misc/src/java/org/apache/lucene/index/PKIndexSplitter.java @@ -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; diff --git a/lucene/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/src/java/org/apache/lucene/index/IndexWriter.java index ce421ca68dd..8817c7601bd 100644 --- a/lucene/src/java/org/apache/lucene/index/IndexWriter.java +++ b/lucene/src/java/org/apache/lucene/index/IndexWriter.java @@ -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 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 {