mirror of https://github.com/apache/lucene.git
LUCENE-2615: don't create files w/ bogus permissions; don't hardwire buffer size to 1MB
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@988216 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
07df8d5210
commit
4e737ef56e
|
@ -32,6 +32,7 @@ API Changes
|
||||||
safety, serialization, and performance problems. If you have
|
safety, serialization, and performance problems. If you have
|
||||||
written a custom RegexCapabilities it will need to be updated
|
written a custom RegexCapabilities it will need to be updated
|
||||||
to the new API. (Robert Muir, Uwe Schindler)
|
to the new API. (Robert Muir, Uwe Schindler)
|
||||||
|
|
||||||
======================= Lucene 3.x (not yet released) =======================
|
======================= Lucene 3.x (not yet released) =======================
|
||||||
|
|
||||||
Changes in backwards compatibility policy
|
Changes in backwards compatibility policy
|
||||||
|
@ -110,6 +111,10 @@ Bug fixes
|
||||||
* LUCENE-2524: FastVectorHighlighter: use mod for getting colored tag.
|
* LUCENE-2524: FastVectorHighlighter: use mod for getting colored tag.
|
||||||
(Koji Sekiguchi)
|
(Koji Sekiguchi)
|
||||||
|
|
||||||
|
* LUCENE-2615: Fix DirectIOLinuxDirectory to not assign bogus
|
||||||
|
permissions to newly created files, and to not silently hardwire
|
||||||
|
buffer size to 1 MB. (Mark Miller, Robert Muir, Mike McCandless)
|
||||||
|
|
||||||
API Changes
|
API Changes
|
||||||
|
|
||||||
* LUCENE-2147: Spatial GeoHashUtils now always decode GeoHash strings
|
* LUCENE-2147: Spatial GeoHashUtils now always decode GeoHash strings
|
||||||
|
|
|
@ -46,37 +46,36 @@ public class DirectIOLinuxDirectory extends FSDirectory {
|
||||||
private final static long ALIGN = 512;
|
private final static long ALIGN = 512;
|
||||||
private final static long ALIGN_NOT_MASK = ~(ALIGN-1);
|
private final static long ALIGN_NOT_MASK = ~(ALIGN-1);
|
||||||
|
|
||||||
|
private final int forcedBufferSize;
|
||||||
|
|
||||||
/** Create a new NIOFSDirectory for the named location.
|
/** Create a new NIOFSDirectory for the named location.
|
||||||
*
|
*
|
||||||
* @param path the path of the directory
|
* @param path the path of the directory
|
||||||
* @param lockFactory the lock factory to use, or null for the default
|
* @param lockFactory the lock factory to use, or null for the default
|
||||||
* ({@link NativeFSLockFactory});
|
* ({@link NativeFSLockFactory});
|
||||||
|
* @param forcedBufferSize if this is 0, just use Lucene's
|
||||||
|
* default buffer size; else, force this buffer size.
|
||||||
|
* For best performance, force the buffer size to
|
||||||
|
* something fairly large (eg 1 MB), but note that this
|
||||||
|
* will eat up the JRE's direct buffer storage space
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public DirectIOLinuxDirectory(File path, LockFactory lockFactory) throws IOException {
|
public DirectIOLinuxDirectory(File path, LockFactory lockFactory, int forcedBufferSize) throws IOException {
|
||||||
super(path, lockFactory);
|
super(path, lockFactory);
|
||||||
}
|
this.forcedBufferSize = forcedBufferSize;
|
||||||
|
|
||||||
/** Create a new NIOFSDirectory for the named location and {@link NativeFSLockFactory}.
|
|
||||||
*
|
|
||||||
* @param path the path of the directory
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
public DirectIOLinuxDirectory(File path) throws IOException {
|
|
||||||
super(path, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexInput openInput(String name, int bufferSize) throws IOException {
|
public IndexInput openInput(String name, int bufferSize) throws IOException {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
return new DirectIOLinuxIndexInput(new File(getDirectory(), name), bufferSize);
|
return new DirectIOLinuxIndexInput(new File(getDirectory(), name), forcedBufferSize == 0 ? bufferSize : forcedBufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexOutput createOutput(String name) throws IOException {
|
public IndexOutput createOutput(String name) throws IOException {
|
||||||
ensureOpen();
|
ensureOpen();
|
||||||
ensureCanWrite(name);
|
ensureCanWrite(name);
|
||||||
return new DirectIOLinuxIndexOutput(new File(getDirectory(), name), 4096);
|
return new DirectIOLinuxIndexOutput(new File(getDirectory(), name), forcedBufferSize == 0 ? BufferedIndexOutput.BUFFER_SIZE : forcedBufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static class DirectIOLinuxIndexOutput extends IndexOutput {
|
private final static class DirectIOLinuxIndexOutput extends IndexOutput {
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
#include <fcntl.h> // posix_fadvise
|
#include <fcntl.h> // posix_fadvise, constants for open
|
||||||
#include <string.h> // strerror
|
#include <string.h> // strerror
|
||||||
#include <errno.h> // errno
|
#include <errno.h> // errno
|
||||||
#include <unistd.h> // pread
|
#include <unistd.h> // pread
|
||||||
#include <sys/mman.h> // posix_madvise, madvise
|
#include <sys/mman.h> // posix_madvise, madvise
|
||||||
|
#include <sys/types.h> // constants for open
|
||||||
|
#include <sys/stat.h> // constants for open
|
||||||
|
|
||||||
// java -cp .:lib/junit-4.7.jar:./build/classes/test:./build/classes/java:./build/classes/demo -Dlucene.version=2.9-dev -DtempDir=build -ea org.junit.runner.JUnitCore org.apache.lucene.index.TestDoc
|
// java -cp .:lib/junit-4.7.jar:./build/classes/test:./build/classes/java:./build/classes/demo -Dlucene.version=2.9-dev -DtempDir=build -ea org.junit.runner.JUnitCore org.apache.lucene.index.TestDoc
|
||||||
|
|
||||||
|
@ -97,7 +99,7 @@ JNIEXPORT jobject JNICALL Java_org_apache_lucene_store_NativePosixUtil_open_1dir
|
||||||
if (readOnly) {
|
if (readOnly) {
|
||||||
fd = open(fname, O_RDONLY | O_DIRECT);
|
fd = open(fname, O_RDONLY | O_DIRECT);
|
||||||
} else {
|
} else {
|
||||||
fd = open(fname, O_RDWR | O_CREAT | O_DIRECT);
|
fd = open(fname, O_RDWR | O_CREAT | O_DIRECT, 0666);
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("open %s -> %d; ro %d\n", fname, fd, readOnly); fflush(stdout);
|
//printf("open %s -> %d; ro %d\n", fname, fd, readOnly); fflush(stdout);
|
||||||
|
|
Loading…
Reference in New Issue