lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r988216 - in /lucene/dev/trunk/lucene/contrib: CHANGES.txt misc/src/java/org/apache/lucene/store/DirectIOLinuxDirectory.java misc/src/java/org/apache/lucene/store/NativePosixUtil.cpp
Date Mon, 23 Aug 2010 17:22:38 GMT
Author: mikemccand
Date: Mon Aug 23 17:22:37 2010
New Revision: 988216

URL: http://svn.apache.org/viewvc?rev=988216&view=rev
Log:
LUCENE-2615: don't create files w/ bogus permissions; don't hardwire buffer size to 1MB

Modified:
    lucene/dev/trunk/lucene/contrib/CHANGES.txt
    lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/store/DirectIOLinuxDirectory.java
    lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/store/NativePosixUtil.cpp

Modified: lucene/dev/trunk/lucene/contrib/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/CHANGES.txt?rev=988216&r1=988215&r2=988216&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/contrib/CHANGES.txt Mon Aug 23 17:22:37 2010
@@ -32,6 +32,7 @@ API Changes
     safety, serialization, and performance problems. If you have
     written a custom RegexCapabilities it will need to be updated
     to the new API.  (Robert Muir, Uwe Schindler)
+
 ======================= Lucene 3.x (not yet released) =======================
 
 Changes in backwards compatibility policy
@@ -109,6 +110,10 @@ Bug fixes
 
 * LUCENE-2524: FastVectorHighlighter: use mod for getting colored tag.
   (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
 

Modified: lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/store/DirectIOLinuxDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/store/DirectIOLinuxDirectory.java?rev=988216&r1=988215&r2=988216&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/store/DirectIOLinuxDirectory.java
(original)
+++ lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/store/DirectIOLinuxDirectory.java
Mon Aug 23 17:22:37 2010
@@ -46,37 +46,36 @@ public class DirectIOLinuxDirectory exte
   private final static long ALIGN = 512;
   private final static long ALIGN_NOT_MASK = ~(ALIGN-1);
 
+  private final int forcedBufferSize;
+
   /** Create a new NIOFSDirectory for the named location.
    * 
    * @param path the path of the directory
    * @param lockFactory the lock factory to use, or null for the default
    * ({@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
    */
-  public DirectIOLinuxDirectory(File path, LockFactory lockFactory) throws IOException {
+  public DirectIOLinuxDirectory(File path, LockFactory lockFactory, int forcedBufferSize)
throws IOException {
     super(path, lockFactory);
-  }
-
-  /** 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);
+    this.forcedBufferSize = forcedBufferSize;
   }
 
   @Override
   public IndexInput openInput(String name, int bufferSize) throws IOException {
     ensureOpen();
-    return new DirectIOLinuxIndexInput(new File(getDirectory(), name), bufferSize);
+    return new DirectIOLinuxIndexInput(new File(getDirectory(), name), forcedBufferSize ==
0 ? bufferSize : forcedBufferSize);
   }
 
   @Override
   public IndexOutput createOutput(String name) throws IOException {
     ensureOpen();
     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 {

Modified: lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/store/NativePosixUtil.cpp
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/store/NativePosixUtil.cpp?rev=988216&r1=988215&r2=988216&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/store/NativePosixUtil.cpp
(original)
+++ lucene/dev/trunk/lucene/contrib/misc/src/java/org/apache/lucene/store/NativePosixUtil.cpp
Mon Aug 23 17:22:37 2010
@@ -1,9 +1,11 @@
 #include <jni.h>
-#include <fcntl.h>   // posix_fadvise
+#include <fcntl.h>   // posix_fadvise, constants for open
 #include <string.h>   // strerror
 #include <errno.h>   // errno
 #include <unistd.h>   // pread
 #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
 
@@ -97,7 +99,7 @@ JNIEXPORT jobject JNICALL Java_org_apach
   if (readOnly) {
     fd = open(fname, O_RDONLY | O_DIRECT);
   } 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);



Mime
View raw message