You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2010/12/08 21:43:25 UTC

svn commit: r1043666 - in /lucene/dev/branches/branch_3x: ./ lucene/ lucene/src/java/org/apache/lucene/store/ lucene/src/test/org/apache/lucene/util/ solr/

Author: rmuir
Date: Wed Dec  8 20:43:25 2010
New Revision: 1043666

URL: http://svn.apache.org/viewvc?rev=1043666&view=rev
Log:
LUCENE-2650: Improve Windows defaults in FSDirectory

Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/lucene/CHANGES.txt
    lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/store/FSDirectory.java
    lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/store/MMapDirectory.java
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
    lucene/dev/branches/branch_3x/solr/   (props changed)

Modified: lucene/dev/branches/branch_3x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/CHANGES.txt?rev=1043666&r1=1043665&r2=1043666&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_3x/lucene/CHANGES.txt Wed Dec  8 20:43:25 2010
@@ -121,6 +121,12 @@ Changes in runtime behavior
   the index instead of for every commit. Committing or closing the IndexWriter
   without any changes to the index will not cause any index version increment.
   (Simon Willnauer, Mike Mccandless)
+
+* LUCENE-2650: The behavior of FSDirectory.open has changed. On 64-bit
+  Windows systems that support unmapping, FSDirectory.open returns
+  MMapDirectory. Additionally the behavior of MMapDirectory has been
+  changed to enable unmapping by default if supported by the JRE.
+  (Mike McCandless, Uwe Schindler, Robert Muir)
   
 API Changes
 

Modified: lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/store/FSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/store/FSDirectory.java?rev=1043666&r1=1043665&r2=1043666&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/store/FSDirectory.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/store/FSDirectory.java Wed Dec  8 20:43:25 2010
@@ -177,8 +177,9 @@ public abstract class FSDirectory extend
    *  The directory returned uses the {@link NativeFSLockFactory}.
    *
    *  <p>Currently this returns {@link NIOFSDirectory}
-   *  on non-Windows JREs and {@link SimpleFSDirectory}
-   *  on Windows. It is highly recommended that you consult the
+   *  on non-Windows JREs, {@link MMapDirectory} on 64-bit 
+   *  Sun Windows JREs, and {@link SimpleFSDirectory} for other
+   *  JRes on Windows. It is highly recommended that you consult the
    *  implementation's documentation for your platform before
    *  using this method.
    *
@@ -187,11 +188,8 @@ public abstract class FSDirectory extend
    * the event that higher performance defaults become
    * possible; if the precise implementation is important to
    * your application, please instantiate it directly,
-   * instead. On 64 bit systems, it may also good to
-   * return {@link MMapDirectory}, but this is disabled
-   * because of officially missing unmap support in Java.
-   * For optimal performance you should consider using
-   * this implementation on 64 bit JVMs.
+   * instead. For optimal performance you should consider using
+   * {@link MMapDirectory} on 64 bit JVMs.
    *
    * <p>See <a href="#subclasses">above</a> */
   public static FSDirectory open(File path) throws IOException {
@@ -202,7 +200,10 @@ public abstract class FSDirectory extend
    *  also specify a custom {@link LockFactory}. */
   public static FSDirectory open(File path, LockFactory lockFactory) throws IOException {
     if (Constants.WINDOWS) {
-      return new SimpleFSDirectory(path, lockFactory);
+      if (MMapDirectory.UNMAP_SUPPORTED && Constants.JRE_IS_64BIT)
+        return new MMapDirectory(path, lockFactory);
+      else
+        return new SimpleFSDirectory(path, lockFactory);
     } else {
       return new NIOFSDirectory(path, lockFactory);
     }

Modified: lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/store/MMapDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/store/MMapDirectory.java?rev=1043666&r1=1043665&r2=1043666&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/store/MMapDirectory.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/store/MMapDirectory.java Wed Dec  8 20:43:25 2010
@@ -64,7 +64,7 @@ import org.apache.lucene.util.Constants;
  * an important limitation to be aware of.
  *
  * <p>This class supplies the workaround mentioned in the bug report
- * (disabled by default, see {@link #setUseUnmap}), which may fail on
+ * (see {@link #setUseUnmap}), which may fail on
  * non-Sun JVMs. It forcefully unmaps the buffer on close by using
  * an undocumented internal cleanup functionality.
  * {@link #UNMAP_SUPPORTED} is <code>true</code>, if the workaround
@@ -78,7 +78,7 @@ import org.apache.lucene.util.Constants;
  * </p>
  */
 public class MMapDirectory extends FSDirectory {
-  private boolean useUnmapHack = false;
+  private boolean useUnmapHack = UNMAP_SUPPORTED;
   private int maxBBuf = Constants.JRE_IS_64BIT ? Integer.MAX_VALUE : (256 * 1024 * 1024);
 
   /** Create a new MMapDirectory for the named location.

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java?rev=1043666&r1=1043665&r2=1043666&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java Wed Dec  8 20:43:25 2010
@@ -696,11 +696,7 @@ public abstract class LuceneTestCase ext
         tmpFile.mkdir();
         try {
           Constructor<? extends Directory> ctor = clazz.getConstructor(File.class);
-          Directory d = ctor.newInstance(tmpFile);
-          // try not to enable this hack unless we must.
-          if (d instanceof MMapDirectory && Constants.WINDOWS && MMapDirectory.UNMAP_SUPPORTED)
-            ((MMapDirectory)d).setUseUnmap(true);
-          return d;
+          return ctor.newInstance(tmpFile);
         } catch (Exception e2) {
           // try .open(File)
           Method method = clazz.getMethod("open", new Class[] { File.class });