org.apache.lucene.store

## Class RAFDirectory

- java.lang.Object
- - org.apache.lucene.store.Directory
  - - org.apache.lucene.store.BaseDirectory
    - - org.apache.lucene.store.FSDirectory
      - - org.apache.lucene.store.RAFDirectory

- All Implemented Interfaces:
    Closeable, AutoCloseable

      public class RAFDirectory
      extends FSDirectory

  A straightforward implementation of `FSDirectory` 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 use `NIOFSDirectory` or `MMapDirectory` 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 and Description
    `RAFDirectory(Path path)` Create a new SimpleFSDirectory for the named location and `FSLockFactory.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 and 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, openChecksumInput`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### 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 directory
        `lockFactory` - 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 SimpleFSDirectory for the named location and `FSLockFactory.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 class `Directory`
      Throws:
        `IOException`

Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.