Class SimpleFSDirectory
A straightforward implementation of FSDirectory using FileStream.
FSDirectory is ideal for use cases where efficient writing is required without utilizing too much RAM. However, reading is less efficient than when using MMapDirectory. This class has poor concurrent read performance (multiple threads will bottleneck) as it synchronizes when multiple threads read from the same file. It's usually better to use MMapDirectory for reading. NOTE: Unlike in Java, it is not recommended to use Interrupt() in .NET in conjunction with an open FSDirectory because it is not guaranteed to exit atomically. Anylock statement or Enter(object) call can throw a
ThreadInterruptedException, which makes shutting down unpredictable.
To exit parallel tasks safely, we recommend using Tasks
and "interrupt" them with CancellationTokens.
Implements
Inherited Members
Namespace: Lucene.Net.Store
Assembly: Lucene.Net.dll
Syntax
public class SimpleFSDirectory : FSDirectory, IDisposable
Constructors
SimpleFSDirectory(DirectoryInfo)
Create a new SimpleFSDirectory for the named location and NativeFSLockFactory.
Declaration
public SimpleFSDirectory(DirectoryInfo path)
Parameters
| Type | Name | Description |
|---|---|---|
| DirectoryInfo | path | the path of the directory |
Exceptions
| Type | Condition |
|---|---|
| IOException | if there is a low-level I/O error |
SimpleFSDirectory(DirectoryInfo, LockFactory)
Create a new SimpleFSDirectory for the named location.
Declaration
public SimpleFSDirectory(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); |
Exceptions
| Type | Condition |
|---|---|
| IOException | if there is a low-level I/O error |
SimpleFSDirectory(string)
Create a new SimpleFSDirectory for the named location and NativeFSLockFactory.
LUCENENET specific overload for convenience using string instead of DirectoryInfo.Declaration
public SimpleFSDirectory(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | the path of the directory |
Exceptions
| Type | Condition |
|---|---|
| IOException | if there is a low-level I/O error |
SimpleFSDirectory(string, LockFactory)
Create a new SimpleFSDirectory for the named location.
LUCENENET specific overload for convenience using string instead of DirectoryInfo.Declaration
public SimpleFSDirectory(string path, LockFactory lockFactory)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | the path of the directory |
| LockFactory | lockFactory | the lock factory to use, or null for the default (NativeFSLockFactory); |
Exceptions
| Type | Condition |
|---|---|
| IOException | if there is a low-level I/O error |
Methods
CreateSlicer(string, IOContext)
Creates an Directory.IndexInputSlicer for the given file name. Directory.IndexInputSlicer allows other Directory implementations to efficiently open one or more sliced IndexInput instances from a single file handle. The underlying file handle is kept open until the Directory.IndexInputSlicer is closed.
Throws FileNotFoundException if the file does not exist.Note
This API is for internal purposes only and might change in incompatible ways in the next release.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
public override Directory.IndexInputSlicer CreateSlicer(string name, IOContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | |
| IOContext | context |
Returns
| Type | Description |
|---|---|
| Directory.IndexInputSlicer |
Overrides
Exceptions
| Type | Condition |
|---|---|
| IOException | if an IOException occurs |
OpenInput(string, IOContext)
Creates an IndexInput for the file with the given name.
Declaration
public override IndexInput OpenInput(string name, IOContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | |
| IOContext | context |
Returns
| Type | Description |
|---|---|
| IndexInput |