public final class ReaderManager extends ReferenceManager<DirectoryReader>
DirectoryReader
instances across
multiple threads, while periodically reopening. This class ensures each
reader is closed only once all threads have finished using it.SearcherManager
ReferenceManager.RefreshListener
current
Constructor and Description |
---|
ReaderManager(Directory dir)
Creates and returns a new ReaderManager from the given
Directory . |
ReaderManager(DirectoryReader reader)
Creates and returns a new ReaderManager from the given
already-opened
DirectoryReader , stealing
the incoming reference. |
ReaderManager(IndexWriter writer)
Creates and returns a new ReaderManager from the given
IndexWriter . |
ReaderManager(IndexWriter writer,
boolean applyAllDeletes,
boolean writeAllDeletes)
Expert: creates and returns a new ReaderManager from the given
IndexWriter , controlling whether past deletions should be applied. |
Modifier and Type | Method and Description |
---|---|
protected void |
decRef(DirectoryReader reference)
Decrement reference counting on the given reference.
|
protected int |
getRefCount(DirectoryReader reference)
Returns the current reference count of the given reference.
|
protected DirectoryReader |
refreshIfNeeded(DirectoryReader referenceToRefresh)
Refresh the given reference if needed.
|
protected boolean |
tryIncRef(DirectoryReader reference)
Try to increment reference counting on the given reference.
|
acquire, addListener, afterClose, afterMaybeRefresh, close, maybeRefresh, maybeRefreshBlocking, release, removeListener
public ReaderManager(IndexWriter writer) throws IOException
IndexWriter
.writer
- the IndexWriter to open the IndexReader from.IOException
- If there is a low-level I/O errorpublic ReaderManager(IndexWriter writer, boolean applyAllDeletes, boolean writeAllDeletes) throws IOException
IndexWriter
, controlling whether past deletions should be applied.writer
- the IndexWriter to open the IndexReader from.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
DirectoryReader.openIfChanged(DirectoryReader, IndexWriter, boolean)
.writeAllDeletes
- If true
, new deletes will be forcefully written to index files.IOException
- If there is a low-level I/O errorpublic ReaderManager(Directory dir) throws IOException
Directory
.dir
- the directory to open the DirectoryReader on.IOException
- If there is a low-level I/O errorpublic ReaderManager(DirectoryReader reader) throws IOException
DirectoryReader
, stealing
the incoming reference.reader
- the directoryReader to use for future reopensIOException
- If there is a low-level I/O errorprotected void decRef(DirectoryReader reference) throws IOException
ReferenceManager
decRef
in class ReferenceManager<DirectoryReader>
IOException
- if reference decrement on the given resource failed.protected DirectoryReader refreshIfNeeded(DirectoryReader referenceToRefresh) throws IOException
ReferenceManager
null
if no refresh
was needed, otherwise a new refreshed reference.refreshIfNeeded
in class ReferenceManager<DirectoryReader>
IOException
- if the refresh operation failedprotected boolean tryIncRef(DirectoryReader reference)
ReferenceManager
tryIncRef
in class ReferenceManager<DirectoryReader>
protected int getRefCount(DirectoryReader reference)
ReferenceManager
getRefCount
in class ReferenceManager<DirectoryReader>
Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.