mirror of https://github.com/apache/lucene.git
LUCENE-2650: Improve Windows defaults in FSDirectory
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@999409 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2595c91906
commit
c89d2d3c3b
|
@ -108,6 +108,14 @@ Changes in backwards compatibility policy
|
||||||
* LUCENE-2600: Remove IndexReader.isDeleted in favor of
|
* LUCENE-2600: Remove IndexReader.isDeleted in favor of
|
||||||
IndexReader.getDeletedDocs(). (Mike McCandless)
|
IndexReader.getDeletedDocs(). (Mike McCandless)
|
||||||
|
|
||||||
|
Changes in Runtime Behavior
|
||||||
|
|
||||||
|
* 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
|
API Changes
|
||||||
|
|
||||||
* LUCENE-2302, LUCENE-1458, LUCENE-2111, LUCENE-2514: Terms are no longer
|
* LUCENE-2302, LUCENE-1458, LUCENE-2111, LUCENE-2514: Terms are no longer
|
||||||
|
|
|
@ -183,8 +183,9 @@ public abstract class FSDirectory extends Directory {
|
||||||
* The directory returned uses the {@link NativeFSLockFactory}.
|
* The directory returned uses the {@link NativeFSLockFactory}.
|
||||||
*
|
*
|
||||||
* <p>Currently this returns {@link NIOFSDirectory}
|
* <p>Currently this returns {@link NIOFSDirectory}
|
||||||
* on non-Windows JREs and {@link SimpleFSDirectory}
|
* on non-Windows JREs, {@link MMapDirectory} on 64-bit
|
||||||
* on Windows. It is highly recommended that you consult the
|
* 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
|
* implementation's documentation for your platform before
|
||||||
* using this method.
|
* using this method.
|
||||||
*
|
*
|
||||||
|
@ -193,11 +194,8 @@ public abstract class FSDirectory extends Directory {
|
||||||
* the event that higher performance defaults become
|
* the event that higher performance defaults become
|
||||||
* possible; if the precise implementation is important to
|
* possible; if the precise implementation is important to
|
||||||
* your application, please instantiate it directly,
|
* your application, please instantiate it directly,
|
||||||
* instead. On 64 bit systems, it may also good to
|
* instead. For optimal performance you should consider using
|
||||||
* return {@link MMapDirectory}, but this is disabled
|
* {@link MMapDirectory} on 64 bit JVMs.
|
||||||
* because of officially missing unmap support in Java.
|
|
||||||
* For optimal performance you should consider using
|
|
||||||
* this implementation on 64 bit JVMs.
|
|
||||||
*
|
*
|
||||||
* <p>See <a href="#subclasses">above</a> */
|
* <p>See <a href="#subclasses">above</a> */
|
||||||
public static FSDirectory open(File path) throws IOException {
|
public static FSDirectory open(File path) throws IOException {
|
||||||
|
@ -208,6 +206,9 @@ public abstract class FSDirectory extends Directory {
|
||||||
* also specify a custom {@link LockFactory}. */
|
* also specify a custom {@link LockFactory}. */
|
||||||
public static FSDirectory open(File path, LockFactory lockFactory) throws IOException {
|
public static FSDirectory open(File path, LockFactory lockFactory) throws IOException {
|
||||||
if (Constants.WINDOWS) {
|
if (Constants.WINDOWS) {
|
||||||
|
if (MMapDirectory.UNMAP_SUPPORTED && Constants.JRE_IS_64BIT)
|
||||||
|
return new MMapDirectory(path, lockFactory);
|
||||||
|
else
|
||||||
return new SimpleFSDirectory(path, lockFactory);
|
return new SimpleFSDirectory(path, lockFactory);
|
||||||
} else {
|
} else {
|
||||||
return new NIOFSDirectory(path, lockFactory);
|
return new NIOFSDirectory(path, lockFactory);
|
||||||
|
|
|
@ -64,7 +64,7 @@ import org.apache.lucene.util.Constants;
|
||||||
* an important limitation to be aware of.
|
* an important limitation to be aware of.
|
||||||
*
|
*
|
||||||
* <p>This class supplies the workaround mentioned in the bug report
|
* <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
|
* non-Sun JVMs. It forcefully unmaps the buffer on close by using
|
||||||
* an undocumented internal cleanup functionality.
|
* an undocumented internal cleanup functionality.
|
||||||
* {@link #UNMAP_SUPPORTED} is <code>true</code>, if the workaround
|
* {@link #UNMAP_SUPPORTED} is <code>true</code>, if the workaround
|
||||||
|
@ -78,7 +78,7 @@ import org.apache.lucene.util.Constants;
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class MMapDirectory extends FSDirectory {
|
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);
|
private int maxBBuf = Constants.JRE_IS_64BIT ? Integer.MAX_VALUE : (256 * 1024 * 1024);
|
||||||
|
|
||||||
/** Create a new MMapDirectory for the named location.
|
/** Create a new MMapDirectory for the named location.
|
||||||
|
|
|
@ -721,11 +721,7 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
tmpFile.mkdir();
|
tmpFile.mkdir();
|
||||||
try {
|
try {
|
||||||
Constructor<? extends Directory> ctor = clazz.getConstructor(File.class);
|
Constructor<? extends Directory> ctor = clazz.getConstructor(File.class);
|
||||||
Directory d = ctor.newInstance(tmpFile);
|
return 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;
|
|
||||||
} catch (Exception e2) {
|
} catch (Exception e2) {
|
||||||
// try .open(File)
|
// try .open(File)
|
||||||
Method method = clazz.getMethod("open", new Class[] { File.class });
|
Method method = clazz.getMethod("open", new Class[] { File.class });
|
||||||
|
|
Loading…
Reference in New Issue