ReaderManager

Utility class to safely share DirectoryReader instances across multiple threads, while periodically reopening. This class ensures each reader is closed only once all threads have finished using it.

Constructors

Link copied to clipboard
constructor(writer: IndexWriter)
constructor(writer: IndexWriter, applyAllDeletes: Boolean, writeAllDeletes: Boolean)

Creates and returns a new ReaderManager from the given IndexWriter, controlling whether past deletions should be applied.

constructor(dir: Directory)

Creates and returns a new ReaderManager from the given Directory.

constructor(reader: DirectoryReader)

Creates and returns a new ReaderManager from the given already-opened DirectoryReader, stealing the incoming reference.

Functions

Link copied to clipboard

Obtain the current reference. You must match every call to acquire with one call to release; it's best to do so in a finally clause, and set the reference to null to prevent accidental usage after it has been released.

Link copied to clipboard

Adds a listener, to be notified when a reference is refreshed/swapped.

Link copied to clipboard
open override fun close()

Closes this ReferenceManager to prevent future acquire acquiring. A reference manager should be closed if the reference to the managed resource should be disposed or the application using the ReferenceManager is shutting down. The managed resource might not be released immediately, if the ReferenceManager user is holding on to a previously acquire acquired reference. The resource will be released once when the last reference is release released. Those references can still be used as if the manager was still active.

Link copied to clipboard

You must call this (or maybeRefreshBlocking), periodically, if you want that will return refreshed instances.

Link copied to clipboard

You must call this (or maybeRefresh), periodically, if you want that will return refreshed instances.

Link copied to clipboard
fun release(reference: DirectoryReader)

Release the reference previously obtained via acquire.

Link copied to clipboard

Removes a listener added by addListener.