Class ReaderManager
Utility class to safely share DirectoryReader instances across multiple threads, while periodically reopening. This class ensures each reader is disposed only once all threads have finished using it.
Note
This API is experimental and might change in incompatible ways in the next release.
Implements
Inherited Members
Namespace: Lucene.Net.Index
Assembly: Lucene.Net.dll
Syntax
public sealed class ReaderManager : ReferenceManager<DirectoryReader>, IDisposable
Constructors
ReaderManager(IndexWriter, bool)
Creates and returns a new ReaderManager from the given IndexWriter.
Declaration
public ReaderManager(IndexWriter writer, bool applyAllDeletes)
Parameters
| Type | Name | Description |
|---|---|---|
| IndexWriter | writer | the IndexWriter to open the IndexReader from. |
| bool | applyAllDeletes | If |
Exceptions
| Type | Condition |
|---|---|
| IOException | If there is a low-level I/O error |
See Also
ReaderManager(Directory)
Creates and returns a new ReaderManager from the given Directory.
Declaration
public ReaderManager(Directory dir)
Parameters
| Type | Name | Description |
|---|---|---|
| Directory | dir | the directory to open the DirectoryReader on. |
Exceptions
| Type | Condition |
|---|---|
| IOException | If there is a low-level I/O error |
See Also
Methods
DecRef(DirectoryReader)
Decrement reference counting on the given reference.
Declaration
protected override void DecRef(DirectoryReader reference)
Parameters
| Type | Name | Description |
|---|---|---|
| DirectoryReader | reference |
Overrides
Exceptions
| Type | Condition |
|---|---|
| IOException | If reference decrement on the given resource failed. |
See Also
GetRefCount(DirectoryReader)
Returns the current reference count of the given reference.
Declaration
protected override int GetRefCount(DirectoryReader reference)
Parameters
| Type | Name | Description |
|---|---|---|
| DirectoryReader | reference |
Returns
| Type | Description |
|---|---|
| int |
Overrides
See Also
RefreshIfNeeded(DirectoryReader)
Refresh the given reference if needed. Returns null if no refresh
was needed, otherwise a new refreshed reference.
Declaration
protected override DirectoryReader RefreshIfNeeded(DirectoryReader referenceToRefresh)
Parameters
| Type | Name | Description |
|---|---|---|
| DirectoryReader | referenceToRefresh |
Returns
| Type | Description |
|---|---|
| DirectoryReader |
Overrides
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | If the reference manager has been Dispose()d. |
| IOException | If the refresh operation failed |
See Also
TryIncRef(DirectoryReader)
Try to increment reference counting on the given reference. Returns true if
the operation was successful.
Declaration
protected override bool TryIncRef(DirectoryReader reference)
Parameters
| Type | Name | Description |
|---|---|---|
| DirectoryReader | reference |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | if the reference manager has been Dispose()d. |