public class SimpleFSDirectory extends FSDirectory
FSDirectory
using Files.newByteChannel(Path, java.nio.file.OpenOption...)
.
However, this class has
poor concurrent performance (multiple threads will
bottleneck) as it synchronizes when multiple threads
read from the same file. It's usually better to use
NIOFSDirectory
or MMapDirectory
instead.
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 SimpleFSDirectory
will throw a ClosedChannelException
. If
your application uses either Thread.interrupt()
or
Future.cancel(boolean)
you should use the legacy RAFDirectory
from the Lucene misc
module in favor of SimpleFSDirectory
.
directory
isOpen, lockFactory
Constructor and Description |
---|
SimpleFSDirectory(Path path)
Create a new SimpleFSDirectory for the named location and
FSLockFactory.getDefault() . |
SimpleFSDirectory(Path path,
LockFactory lockFactory)
Create a new SimpleFSDirectory for the named location.
|
Modifier and Type | Method and Description |
---|---|
IndexInput |
openInput(String name,
IOContext context)
Creates an IndexInput for the file with the given name.
|
close, createOutput, createTempOutput, deleteFile, deletePendingFiles, ensureCanRead, fileLength, fsync, getDirectory, getPendingDeletions, listAll, listAll, open, open, rename, sync, syncMetaData, toString
ensureOpen, obtainLock
copyFrom, openChecksumInput
public SimpleFSDirectory(Path path, LockFactory lockFactory) throws IOException
path
- the path of the directorylockFactory
- the lock factory to useIOException
- if there is a low-level I/O errorpublic SimpleFSDirectory(Path path) throws IOException
FSLockFactory.getDefault()
.
The directory is created at the named location if it does not yet exist.path
- the path of the directoryIOException
- if there is a low-level I/O errorpublic IndexInput openInput(String name, IOContext context) throws IOException
openInput
in class Directory
name
- the name of an existing file.IOException
- in case of I/O errorCopyright © 2000-2019 Apache Software Foundation. All Rights Reserved.