diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 7c28a8800e8..f49c7c0b210 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -112,6 +112,10 @@ Bug Fixes
seek/lookup which can cause sideeffects if done on a cached FST root arc.
(Simon Willnauer)
+* LUCENE-5161: Fix default chunk sizes in FSDirectory.java to not be unnecessarily large,
+ and fix setReadChunkSize to always work regardless of whether the machine is 32bit
+ or 64bit. (Uwe Schindler, Robert Muir)
+
API Changes
* LUCENE-5094: Add ramBytesUsed() to MultiDocValues.OrdinalMap.
diff --git a/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java b/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java
index 1c739bd2831..33b99845287 100644
--- a/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java
+++ b/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java
@@ -112,12 +112,9 @@ import org.apache.lucene.util.Constants;
public abstract class FSDirectory extends Directory {
/**
- * Default read chunk size. This is a conditional default: on 32bit JVMs, it defaults to 100 MB. On 64bit JVMs, it's
- * Integer.MAX_VALUE
.
- *
- * @see #setReadChunkSize
+ * Default read chunk size: 2*{@link BufferedIndexInput#MERGE_BUFFER_SIZE}.
*/
- public static final int DEFAULT_READ_CHUNK_SIZE = Constants.JRE_IS_64BIT ? Integer.MAX_VALUE : 100 * 1024 * 1024;
+ public static final int DEFAULT_READ_CHUNK_SIZE = BufferedIndexInput.MERGE_BUFFER_SIZE * 2;
protected final File directory; // The underlying filesystem directory
protected final Set
NOTE: This value should be as large as - * possible to reduce any possible performance impact. If - * you still encounter an incorrect OutOfMemoryError, - * trying lowering the chunk size.
*/ public final void setReadChunkSize(int chunkSize) { // LUCENE-1566 if (chunkSize <= 0) { throw new IllegalArgumentException("chunkSize must be positive"); } - if (!Constants.JRE_IS_64BIT) { - this.chunkSize = chunkSize; - } + this.chunkSize = chunkSize; } /** diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java index 985c1d205e7..90fc51b7458 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java +++ b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java @@ -20,6 +20,7 @@ package org.apache.lucene.util; import java.io.*; import java.lang.annotation.*; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.*; import java.util.concurrent.*; @@ -1135,9 +1136,10 @@ public abstract class LuceneTestCase extends Assert { FSDirectory d = null; try { d = CommandLineUtil.newFSDirectory(clazz, file); - } catch (Exception e) { - d = FSDirectory.open(file); + } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { + Rethrow.rethrow(e); } + d.setReadChunkSize(_TestUtil.nextInt(random(), 8, 32678)); return d; }