Show / Hide Table of Contents

    Class FSDirectory

    Base class for Directory implementations that store index files in the file system.

    There are currently three core subclasses:

    • SimpleFSDirectory is a straightforward implementation using . However, it has poor concurrent performance (multiple threads will bottleneck) as it synchronizes when multiple threads read from the same file.
    • NIOFSDirectory uses java.nio's FileChannel's positional io when reading to avoid synchronization when reading from the same file. Unfortunately, due to a Windows-only Sun JRE bug this is a poor choice for Windows, but on all other platforms this is the preferred choice. Applications using or should use SimpleFSDirectory instead. See NIOFSDirectory java doc for details.
    • MMapDirectory uses memory-mapped IO when reading. This is a good choice if you have plenty of virtual memory relative to your index size, eg if you are running on a 64 bit runtime, or you are running on a 32 bit runtime but your index sizes are small enough to fit into the virtual memory space.

      Applications using or should use SimpleFSDirectory instead. See MMapDirectory doc for details.

    Unfortunately, because of system peculiarities, there is no single overall best implementation. Therefore, we've added the Open(String) method (or one of its overloads), to allow Lucene to choose the best FSDirectory implementation given your environment, and the known limitations of each implementation. For users who have no reason to prefer a specific implementation, it's best to simply use Open(String) (or one of its overloads). For all others, you should instantiate the desired implementation directly.

    The locking implementation is by default NativeFSLockFactory, but can be changed by passing in a custom LockFactory instance.

    Inheritance
    System.Object
    Directory
    BaseDirectory
    FSDirectory
    MMapDirectory
    NIOFSDirectory
    SimpleFSDirectory
    Inherited Members
    BaseDirectory.IsOpen
    BaseDirectory.m_lockFactory
    BaseDirectory.MakeLock(String)
    BaseDirectory.ClearLock(String)
    BaseDirectory.LockFactory
    BaseDirectory.EnsureOpen()
    Directory.OpenInput(String, IOContext)
    Directory.OpenChecksumInput(String, IOContext)
    Directory.Dispose()
    Directory.Copy(Directory, String, String, IOContext)
    Directory.CreateSlicer(String, IOContext)
    Namespace: Lucene.Net.Store
    Assembly: Lucene.Net.dll
    Syntax
    public abstract class FSDirectory : BaseDirectory

    Constructors

    | Improve this Doc View Source

    FSDirectory(DirectoryInfo)

    Declaration
    protected FSDirectory(DirectoryInfo dir)
    Parameters
    Type Name Description
    DirectoryInfo dir
    | Improve this Doc View Source

    FSDirectory(DirectoryInfo, LockFactory)

    Create a new FSDirectory for the named location (ctor for subclasses).

    Declaration
    protected FSDirectory(DirectoryInfo path, LockFactory lockFactory)
    Parameters
    Type Name Description
    DirectoryInfo path

    the path of the directory

    LockFactory lockFactory

    the lock factory to use, or null for the default (NativeFSLockFactory);

    Fields

    | Improve this Doc View Source

    DEFAULT_READ_CHUNK_SIZE

    Default read chunk size: 8192 bytes (this is the size up to which the runtime does not allocate additional arrays while reading/writing)

    Declaration
    public const int DEFAULT_READ_CHUNK_SIZE = null
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    m_directory

    Declaration
    protected readonly DirectoryInfo m_directory
    Field Value
    Type Description
    DirectoryInfo

    Properties

    | Improve this Doc View Source

    Directory

    the underlying filesystem directory

    Declaration
    public virtual DirectoryInfo Directory { get; }
    Property Value
    Type Description
    DirectoryInfo
    | Improve this Doc View Source

    ReadChunkSize

    this setting has no effect anymore.

    Declaration
    public int ReadChunkSize { get; set; }
    Property Value
    Type Description
    System.Int32

    Methods

    | Improve this Doc View Source

    CreateOutput(String, IOContext)

    Creates an IndexOutput for the file with the given name.

    Declaration
    public override IndexOutput CreateOutput(string name, IOContext context)
    Parameters
    Type Name Description
    System.String name
    IOContext context
    Returns
    Type Description
    IndexOutput
    Overrides
    Directory.CreateOutput(String, IOContext)
    | Improve this Doc View Source

    DeleteFile(String)

    Removes an existing file in the directory.

    Declaration
    public override void DeleteFile(string name)
    Parameters
    Type Name Description
    System.String name
    Overrides
    Directory.DeleteFile(String)
    | Improve this Doc View Source

    Dispose(Boolean)

    Closes the store to future operations.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing
    Overrides
    Directory.Dispose(Boolean)
    | Improve this Doc View Source

    EnsureCanWrite(String)

    Declaration
    protected virtual void EnsureCanWrite(string name)
    Parameters
    Type Name Description
    System.String name
    | Improve this Doc View Source

    FileExists(String)

    Returns true iff a file with the given name exists.

    Declaration
    public override bool FileExists(string name)
    Parameters
    Type Name Description
    System.String name
    Returns
    Type Description
    System.Boolean
    Overrides
    Directory.FileExists(String)
    | Improve this Doc View Source

    FileLength(String)

    Returns the length in bytes of a file in the directory.

    Declaration
    public override long FileLength(string name)
    Parameters
    Type Name Description
    System.String name
    Returns
    Type Description
    System.Int64
    Overrides
    Directory.FileLength(String)
    | Improve this Doc View Source

    GetLockID()

    Declaration
    public override string GetLockID()
    Returns
    Type Description
    System.String
    Overrides
    Directory.GetLockID()
    | Improve this Doc View Source

    ListAll()

    Lists all files (not subdirectories) in the directory.

    Declaration
    public override string[] ListAll()
    Returns
    Type Description
    System.String[]
    Overrides
    Directory.ListAll()
    See Also
    ListAll(DirectoryInfo)
    | Improve this Doc View Source

    ListAll(DirectoryInfo)

    Lists all files (not subdirectories) in the directory. This method never returns null (throws instead).

    Declaration
    public static string[] ListAll(DirectoryInfo dir)
    Parameters
    Type Name Description
    DirectoryInfo dir
    Returns
    Type Description
    System.String[]
    | Improve this Doc View Source

    OnIndexOutputClosed(FSDirectory.FSIndexOutput)

    Declaration
    protected virtual void OnIndexOutputClosed(FSDirectory.FSIndexOutput io)
    Parameters
    Type Name Description
    FSDirectory.FSIndexOutput io
    | Improve this Doc View Source

    Open(DirectoryInfo)

    Creates an FSDirectory instance, trying to pick the best implementation given the current environment. The directory returned uses the NativeFSLockFactory.

    Currently this returns MMapDirectory for most Solaris and Windows 64-bit runtimes, NIOFSDirectory for other non-Windows runtimes, and SimpleFSDirectory for other runtimes on Windows. It is highly recommended that you consult the implementation's documentation for your platform before using this method.

    NOTE: this method may suddenly change which implementation is returned from release to release, in the event that higher performance defaults become possible; if the precise implementation is important to your application, please instantiate it directly, instead. For optimal performance you should consider using MMapDirectory on 64 bit runtimes.

    See FSDirectory.

    Declaration
    public static FSDirectory Open(DirectoryInfo path)
    Parameters
    Type Name Description
    DirectoryInfo path
    Returns
    Type Description
    FSDirectory
    | Improve this Doc View Source

    Open(DirectoryInfo, LockFactory)

    Just like Open(DirectoryInfo), but allows you to also specify a custom LockFactory.

    Declaration
    public static FSDirectory Open(DirectoryInfo path, LockFactory lockFactory)
    Parameters
    Type Name Description
    DirectoryInfo path
    LockFactory lockFactory
    Returns
    Type Description
    FSDirectory
    | Improve this Doc View Source

    Open(String)

    Just like Open(DirectoryInfo), but allows you to specify the directory as a .

    Declaration
    public static FSDirectory Open(string path)
    Parameters
    Type Name Description
    System.String path

    The path (to a directory) to open

    Returns
    Type Description
    FSDirectory

    An open FSDirectory

    | Improve this Doc View Source

    Open(String, LockFactory)

    Just like Open(DirectoryInfo, LockFactory), but allows you to specify the directory as a .

    Declaration
    public static FSDirectory Open(string path, LockFactory lockFactory)
    Parameters
    Type Name Description
    System.String path

    The path (to a directory) to open

    LockFactory lockFactory
    Returns
    Type Description
    FSDirectory

    An open FSDirectory

    | Improve this Doc View Source

    SetLockFactory(LockFactory)

    Declaration
    public override void SetLockFactory(LockFactory lockFactory)
    Parameters
    Type Name Description
    LockFactory lockFactory
    Overrides
    BaseDirectory.SetLockFactory(LockFactory)
    | Improve this Doc View Source

    Sync(ICollection<String>)

    Declaration
    public override void Sync(ICollection<string> names)
    Parameters
    Type Name Description
    ICollection<System.String> names
    Overrides
    Directory.Sync(ICollection<String>)
    | Improve this Doc View Source

    ToString()

    For debug output.

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String
    Overrides
    Directory.ToString()

    See Also

    Directory
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)