LUCENE-2791: set the optimal buffersize by default

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1042373 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-12-05 15:24:34 +00:00
parent 4e44804c38
commit 0308402397
2 changed files with 3 additions and 2 deletions

View File

@ -113,7 +113,7 @@ JNIEXPORT jint JNICALL Java_org_apache_lucene_store_WindowsDirectory_read
return -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)) {

View File

@ -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 {