org.apache.lucene.store

## Class SimpleFSDirectory

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

- All Implemented Interfaces:
    Closeable, AutoCloseable

  Deprecated.
  This class is a less efficient implementation of what's available in `NIOFSDirectory`, and will be removed in future versions of Lucene.

      public class SimpleFSDirectory
      extends FSDirectory

  A straightforward implementation of `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`.

- - ### 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
    `SimpleFSDirectory(Path path)` Deprecated. Create a new SimpleFSDirectory for the named location and `FSLockFactory.getDefault()`.
    `SimpleFSDirectory(Path path, LockFactory lockFactory)` Deprecated. Create a new SimpleFSDirectory for the named location.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `IndexInput` | `openInput(String name, IOContext context)` Deprecated. 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`

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

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

- - ### Constructor Detail

    - #### SimpleFSDirectory

          public SimpleFSDirectory(Path path,
                                   LockFactory lockFactory)
                            throws IOException

      Deprecated.
      Create a new SimpleFSDirectory 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

    - #### SimpleFSDirectory

          public SimpleFSDirectory(Path path)
                            throws IOException

      Deprecated.
      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

      Deprecated.
      Creates an IndexInput for the file with the given name.
      Specified by:
        `openInput` in class `Directory`
      Parameters:
        `name` - the name of an existing file.
      Throws:
        `IOException` - in case of I/O error

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