Package org.apache.lucene.misc.store
Class RAFDirectory
- java.lang.Object
-
- org.apache.lucene.store.Directory
-
- org.apache.lucene.store.BaseDirectory
-
- org.apache.lucene.store.FSDirectory
-
- org.apache.lucene.misc.store.RAFDirectory
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class RAFDirectory extends FSDirectory
A straightforward implementation ofFSDirectory
using java.io.RandomAccessFile. 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 useNIOFSDirectory
orMMapDirectory
instead.NOTE: Because this uses RandomAccessFile, it will generally not work with non-default filesystem providers. It is only provided for applications that relied on the fact that RandomAccessFile's IO was not interruptible.
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.store.FSDirectory
directory
-
Fields inherited from class org.apache.lucene.store.BaseDirectory
isOpen, lockFactory
-
-
Constructor Summary
Constructors Constructor Description RAFDirectory(Path path)
Create a new RAFDirectory for the named location andFSLockFactory.getDefault()
.RAFDirectory(Path path, LockFactory lockFactory)
Create a new RAFDirectory for the named location.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IndexInput
openInput(String name, IOContext context)
Creates an IndexInput for the file with the given name.-
Methods inherited from class org.apache.lucene.store.FSDirectory
close, createOutput, createTempOutput, deleteFile, deletePendingFiles, ensureCanRead, fileLength, fsync, getDirectory, getPendingDeletions, listAll, listAll, open, open, rename, sync, syncMetaData, toString
-
Methods inherited from class org.apache.lucene.store.BaseDirectory
ensureOpen, obtainLock
-
Methods inherited from class org.apache.lucene.store.Directory
copyFrom, getTempFileName, openChecksumInput
-
-
-
-
Constructor Detail
-
RAFDirectory
public RAFDirectory(Path path, LockFactory lockFactory) throws IOException
Create a new RAFDirectory for the named location. The directory is created at the named location if it does not yet exist.- Parameters:
path
- the path of the directorylockFactory
- the lock factory to use- Throws:
IOException
- if there is a low-level I/O error
-
RAFDirectory
public RAFDirectory(Path path) throws IOException
Create a new RAFDirectory for the named location andFSLockFactory.getDefault()
. The directory is created at the named location if it does not yet exist.- Parameters:
path
- the path of the directory- Throws:
IOException
- if there is a low-level I/O error
-
-
Method Detail
-
openInput
public IndexInput openInput(String name, IOContext context) throws IOException
Creates an IndexInput for the file with the given name.- Specified by:
openInput
in classDirectory
- Throws:
IOException
-
-