From faa1b9815eb38db478130d4ae64c19a3767b8ae9 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Tue, 20 Oct 2009 09:04:51 +0000 Subject: [PATCH] LUCENE-1995: don't let IndexWriter's ram buffer size exceed 2048 MB git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@827010 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 4 ++++ src/java/org/apache/lucene/index/IndexWriter.java | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index 907aaf9e656..64a1ac21894 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -110,6 +110,10 @@ Bug fixes * LUCENE-1992: Fix thread hazard if a merge is committing just as an exception occurs during sync (Uwe Schindler, Mike McCandless) +* LUCENE-1995: Note in javadocs that IndexWriter.setRAMBufferSizeMB + cannot exceed 2048 MB, and throw IllegalArgumentException if it + does. (Aaron McKee, Yonik Seeley, Mike McCandless) + New features * LUCENE-1933: Provide a convenience AttributeFactory that creates a diff --git a/src/java/org/apache/lucene/index/IndexWriter.java b/src/java/org/apache/lucene/index/IndexWriter.java index a7d38735ac9..2cf14050098 100644 --- a/src/java/org/apache/lucene/index/IndexWriter.java +++ b/src/java/org/apache/lucene/index/IndexWriter.java @@ -1338,6 +1338,14 @@ public class IndexWriter implements Closeable { * instead of RAM usage (each buffered delete Query counts * as one). * + *

NOTE: because IndexWriter uses + * ints when managing its internal storage, + * the absolute maximum value for this setting is somewhat + * less than 2048 MB. The precise limit depends on + * various factors, such as how large your documents are, + * how many fields have norms, etc., so it's best to set + * this value comfortably under 2048.

+ * *

The default value is {@link #DEFAULT_RAM_BUFFER_SIZE_MB}.

* * @throws IllegalArgumentException if ramBufferSize is @@ -1345,6 +1353,9 @@ public class IndexWriter implements Closeable { * when maxBufferedDocs is already disabled */ public void setRAMBufferSizeMB(double mb) { + if (mb > 2048.0) { + throw new IllegalArgumentException("ramBufferSize " + mb + " is too large; should be comfortably less than 2048"); + } if (mb != DISABLE_AUTO_FLUSH && mb <= 0.0) throw new IllegalArgumentException( "ramBufferSize should be > 0.0 MB when enabled");