Package org.apache.lucene.index
Class ReaderManager
- java.lang.Object
-
- org.apache.lucene.search.ReferenceManager<DirectoryReader>
-
- org.apache.lucene.index.ReaderManager
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public final class ReaderManager extends ReferenceManager<DirectoryReader>
Utility class to safely shareDirectoryReader
instances across multiple threads, while periodically reopening. This class ensures each reader is closed only once all threads have finished using it.- See Also:
SearcherManager
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.search.ReferenceManager
ReferenceManager.RefreshListener
-
-
Constructor Summary
Constructors Constructor Description ReaderManager(IndexWriter writer, boolean applyAllDeletes)
Creates and returns a new ReaderManager from the givenIndexWriter
.ReaderManager(Directory dir)
Creates and returns a new ReaderManager from the givenDirectory
.
-
Method Summary
-
Methods inherited from class org.apache.lucene.search.ReferenceManager
acquire, addListener, close, maybeRefresh, maybeRefreshBlocking, release, removeListener
-
-
-
-
Constructor Detail
-
ReaderManager
public ReaderManager(IndexWriter writer, boolean applyAllDeletes) throws java.io.IOException
Creates and returns a new ReaderManager from the givenIndexWriter
.- Parameters:
writer
- the IndexWriter to open the IndexReader from.applyAllDeletes
- Iftrue
, all buffered deletes will be applied (made visible) in theIndexSearcher
/DirectoryReader
. Iffalse
, 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 passingfalse
. SeeDirectoryReader.openIfChanged(DirectoryReader, IndexWriter, boolean)
.- Throws:
java.io.IOException
- If there is a low-level I/O error
-
-