Fork me on GitHub
  • API

    Show / Hide Table of Contents

    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.

    Inheritance
    object
    ReferenceManager<DirectoryReader>
    ReaderManager
    Implements
    IDisposable
    Inherited Members
    ReferenceManager<DirectoryReader>.Acquire()
    ReferenceManager<DirectoryReader>.Dispose()
    ReferenceManager<DirectoryReader>.MaybeRefresh()
    ReferenceManager<DirectoryReader>.MaybeRefreshBlocking()
    ReferenceManager<DirectoryReader>.Release(DirectoryReader)
    ReferenceManager<DirectoryReader>.AddListener(ReferenceManager.IRefreshListener)
    ReferenceManager<DirectoryReader>.RemoveListener(ReferenceManager.IRefreshListener)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    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 true, all buffered deletes will be applied (made visible) in the IndexSearcher / DirectoryReader. If false, the deletes may or may not be applied, but remain buffered (in IndexWriter) so that they will be applied in the future. Applying deletes can be costly, so if your app can tolerate deleted documents being returned you might gain some performance by passing false. See OpenIfChanged(DirectoryReader, IndexWriter, bool).

    Exceptions
    Type Condition
    IOException

    If there is a low-level I/O error

    See Also
    SearcherManager

    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
    SearcherManager

    Methods

    DecRef(DirectoryReader)

    Decrement reference counting on the given reference.

    Declaration
    protected override void DecRef(DirectoryReader reference)
    Parameters
    Type Name Description
    DirectoryReader reference
    Overrides
    ReferenceManager<DirectoryReader>.DecRef(DirectoryReader)
    Exceptions
    Type Condition
    IOException

    If reference decrement on the given resource failed.

    See Also
    SearcherManager

    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
    ReferenceManager<DirectoryReader>.GetRefCount(DirectoryReader)
    See Also
    SearcherManager

    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
    ReferenceManager<DirectoryReader>.RefreshIfNeeded(DirectoryReader)
    Exceptions
    Type Condition
    ObjectDisposedException

    If the reference manager has been Dispose()d.

    IOException

    If the refresh operation failed

    See Also
    SearcherManager

    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
    ReferenceManager<DirectoryReader>.TryIncRef(DirectoryReader)
    Exceptions
    Type Condition
    ObjectDisposedException

    if the reference manager has been Dispose()d.

    See Also
    SearcherManager

    Implements

    IDisposable

    Extension Methods

    ReferenceManagerExtensions.GetContext<T>(ReferenceManager<T>)

    See Also

    SearcherManager
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.