diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java index 7abf681fe88..4517294f4c3 100644 --- a/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java +++ b/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java @@ -1898,7 +1898,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable { final int size = mergeExceptions.size(); for(int i=0;i 0; + assert maxNumSegments == UNBOUNDED_MAX_MERGE_SEGMENTS || maxNumSegments > 0; assert trigger != null; if (stopMerges) { return false; @@ -2771,7 +2771,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable { // Best-effort up front check: testReserveDocs(numDocs); - final IOContext context = new IOContext(new MergeInfo(Math.toIntExact(numDocs), -1, false, -1)); + final IOContext context = new IOContext(new MergeInfo(Math.toIntExact(numDocs), -1, false, UNBOUNDED_MAX_MERGE_SEGMENTS)); // TODO: somehow we should fix this merge so it's // abortable so that IW.close(false) is able to stop it @@ -3797,7 +3797,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable { infoStream.message("IW", "after commitMerge: " + segString()); } - if (merge.maxNumSegments != -1 && !dropSegment) { + if (merge.maxNumSegments != UNBOUNDED_MAX_MERGE_SEGMENTS && !dropSegment) { // cascade the forceMerge: if (!segmentsToMerge.containsKey(merge.info)) { segmentsToMerge.put(merge.info, Boolean.FALSE); @@ -3876,7 +3876,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable { if (infoStream.isEnabled("IW")) { infoStream.message("IW", "hit exception during merge"); } - } else if (merge.rateLimiter.getAbort() == false && (merge.maxNumSegments != -1 || (!closed && !closing))) { + } else if (merge.rateLimiter.getAbort() == false && (merge.maxNumSegments != UNBOUNDED_MAX_MERGE_SEGMENTS || (!closed && !closing))) { // This merge (and, generally, any change to the // segments) may now enable new merges, so we call // merge policy & update pending merges. @@ -4015,7 +4015,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable { testPoint("startMergeInit"); assert merge.registerDone; - assert merge.maxNumSegments == -1 || merge.maxNumSegments > 0; + assert merge.maxNumSegments == UNBOUNDED_MAX_MERGE_SEGMENTS || merge.maxNumSegments > 0; if (tragedy != null) { throw new IllegalStateException("this writer hit an unrecoverable error; cannot merge", tragedy);