Skip to content

Apache Lucene open-source search software

Undo the change that made setMaxBufferedDocs(1) work because it had negative effects on indexing performance. Instead throw an exception if setMaxBufferedDocs(1) is called.

Daniel Naber7bc0ead011fc
diff --git a/CHANGES.txt b/CHANGES.txt
index f76db1a3da6..63beeb9d39a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,6 +4,13 @@ $Id$
1.9 RC2
+Bug fixes
+
+ 1. The fix that made IndexWriter.setMaxBufferedDocs(1) work had negative
+ effects on indexing performance and has thus been reverted. The
+ argument for setMaxBufferedDocs(int) must now at least be 2, otherwise
+ an exception is thrown.
+
Optimizations
1. Optimized BufferedIndexOutput.writeBytes() to use
diff --git a/src/java/org/apache/lucene/index/IndexWriter.java b/src/java/org/apache/lucene/index/IndexWriter.java
index 7e215a769a2..61109dcf5fd 100644
--- a/src/java/org/apache/lucene/index/IndexWriter.java
+++ b/src/java/org/apache/lucene/index/IndexWriter.java
@@ -318,11 +318,11 @@ public class IndexWriter {
*
* <p> The default value is 10.
*
- * @throws IllegalArgumentException if maxBufferedDocs is smaller than 1
+ * @throws IllegalArgumentException if maxBufferedDocs is smaller than 2
*/
public void setMaxBufferedDocs(int maxBufferedDocs) {
- if (maxBufferedDocs < 1)
- throw new IllegalArgumentException("maxBufferedDocs must at least be 1");
+ if (maxBufferedDocs < 2)
+ throw new IllegalArgumentException("maxBufferedDocs must at least be 2");
this.minMergeDocs = maxBufferedDocs;
}
@@ -637,7 +637,7 @@ public class IndexWriter {
int mergeDocs = 0;
while (--minSegment >= 0) {
SegmentInfo si = segmentInfos.info(minSegment);
- if (si.docCount > targetMergeDocs)
+ if (si.docCount >= targetMergeDocs)
break;
mergeDocs += si.docCount;
}