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.
Inherited Members
Assembly: DistributedLucene.Net.dll
Syntax
public abstract class FSDirectory : BaseDirectory
Constructors
Name | Description |
---|---|
FSDirectory(DirectoryInfo) | |
FSDirectory(DirectoryInfo, LockFactory) | Create a new FSDirectory for the named location (ctor for subclasses). |
Fields
Name | Description |
---|---|
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) |
m_directory |
Properties
Name | Description |
---|---|
Directory | the underlying filesystem directory |
ReadChunkSize | this setting has no effect anymore. |
Methods
Name | Description |
---|---|
CreateOutput(String, IOContext) | Creates an IndexOutput for the file with the given name. |
DeleteFile(String) | Removes an existing file in the directory. |
DirectoryExist() | |
Dispose(Boolean) | Closes the store to future operations. |
EnsureCanWrite(String) | |
FileExists(String) | Returns true iff a file with the given name exists. |
FileLength(String) | Returns the length in bytes of a file in the directory. |
GetLockID() | |
ListAll() | Lists all files (not subdirectories) in the directory. |
ListAll(DirectoryInfo) | Lists all files (not subdirectories) in the
directory. This method never returns |
OnIndexOutputClosed(FSDirectory.FSIndexOutput) | |
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. |
Open(DirectoryInfo, LockFactory, Int32) | Just like Open(DirectoryInfo), but allows you to also specify a custom LockFactory. |
Open(String) | Just like Open(DirectoryInfo), but
allows you to specify the directory as a |
Open(String, LockFactory, Int32) | Just like |
OpenForTool(DirectoryInfo, LockFactory, Int32) | |
SetLockFactory(LockFactory) | |
Sync(ICollection<String>) | |
ToString() | For debug output. |