Apache Lucene open-source search software
LUCENE-2791: set the optimal buffersize by default
Robert Muir030840239758
diff --git a/lucene/contrib/misc/src/java/org/apache/lucene/store/WindowsDirectory.cpp b/lucene/contrib/misc/src/java/org/apache/lucene/store/WindowsDirectory.cppindex e4c5bc43634..e6063b936f8 100644--- a/lucene/contrib/misc/src/java/org/apache/lucene/store/WindowsDirectory.cpp+++ b/lucene/contrib/misc/src/java/org/apache/lucene/store/WindowsDirectory.cpp@@ -113,7 +113,7 @@ JNIEXPORT jint JNICALL Java_org_apache_lucene_store_WindowsDirectory_readreturn -1;}- if (length <= 2048) { /* For small buffers, avoid GetByteArrayElements' copy */+ if (length <= 4096) { /* For small buffers, avoid GetByteArrayElements' copy */char buffer[length];if (ReadFile((HANDLE) fd, &buffer, length, &numRead, &io)) {diff --git a/lucene/contrib/misc/src/java/org/apache/lucene/store/WindowsDirectory.java b/lucene/contrib/misc/src/java/org/apache/lucene/store/WindowsDirectory.javaindex f6cfbb808f5..870ebfade1e 100644--- a/lucene/contrib/misc/src/java/org/apache/lucene/store/WindowsDirectory.java+++ b/lucene/contrib/misc/src/java/org/apache/lucene/store/WindowsDirectory.java@@ -38,6 +38,7 @@ import java.io.IOException;* @lucene.experimental*/public class WindowsDirectory extends FSDirectory {+ private static final int DEFAULT_BUFFERSIZE = 4096; /* default pgsize on ia32/amd64 */static {System.loadLibrary("WindowsDirectory");@@ -65,7 +66,7 @@ public class WindowsDirectory extends FSDirectory {public IndexInput openInput(String name, int bufferSize) throws IOException {ensureOpen();- return new WindowsIndexInput(new File(getDirectory(), name), bufferSize);+ return new WindowsIndexInput(new File(getDirectory(), name), Math.max(bufferSize, DEFAULT_BUFFERSIZE));}protected static class WindowsIndexInput extends BufferedIndexInput {