public class NIOFSDirectory extends FSDirectory
FSDirectory
implementation that uses
java.nio's FileChannel's positional read, which allows
multiple threads to read from the same file without
synchronizing.
This class only uses FileChannel when reading; writing
is achieved with SimpleFSDirectory.SimpleFSIndexOutput
.
NOTE: NIOFSDirectory is not recommended on Windows because of a bug in how FileChannel.read is implemented in Sun's JRE. Inside of the implementation the position is apparently synchronized. See here for details.
NOTE: Accessing this class either directly or
indirectly from a thread while it's interrupted can close the
underlying file descriptor immediately if at the same time the thread is
blocked on IO. The file descriptor will remain closed and subsequent access
to NIOFSDirectory
will throw a ClosedChannelException
. If
your application uses either Thread.interrupt()
or
Future#cancel(boolean)
(on Java 1.5) you should use
SimpleFSDirectory
in favor of NIOFSDirectory
.
Modifier and Type | Class and Description |
---|---|
protected static class |
NIOFSDirectory.NIOFSIndexInput |
FSDirectory.FSIndexInput, FSDirectory.FSIndexOutput
DEFAULT_READ_CHUNK_SIZE, directory, LOCK_DIR
isOpen, lockFactory
Constructor and Description |
---|
NIOFSDirectory(java.io.File path)
Create a new NIOFSDirectory for the named location and
NativeFSLockFactory . |
NIOFSDirectory(java.io.File path,
LockFactory lockFactory)
Create a new NIOFSDirectory for the named location.
|
Modifier and Type | Method and Description |
---|---|
IndexOutput |
createOutput(java.lang.String name)
Creates an IndexOutput for the file with the given name.
|
IndexInput |
openInput(java.lang.String name,
int bufferSize)
Creates an IndexInput for the file with the given name.
|
close, deleteFile, fileExists, fileLength, fileModified, fileModified, getDirectory, getDirectory, getDirectory, getDirectory, getDirectory, getDirectory, getDisableLocks, getFile, getLockID, getReadChunkSize, initOutput, list, listAll, listAll, open, open, openInput, renameFile, setDisableLocks, setReadChunkSize, sync, toString, touchFile
clearLock, copy, ensureOpen, getLockFactory, makeLock, setLockFactory
public NIOFSDirectory(java.io.File path, LockFactory lockFactory) throws java.io.IOException
path
- the path of the directorylockFactory
- the lock factory to use, or null for the default
(NativeFSLockFactory
);java.io.IOException
public NIOFSDirectory(java.io.File path) throws java.io.IOException
NativeFSLockFactory
.path
- the path of the directoryjava.io.IOException
public IndexInput openInput(java.lang.String name, int bufferSize) throws java.io.IOException
openInput
in class FSDirectory
java.io.IOException
public IndexOutput createOutput(java.lang.String name) throws java.io.IOException
createOutput
in class FSDirectory
java.io.IOException
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.