Package org.apache.lucene.index
Class ReaderManager
- All Implemented Interfaces:
Closeable,AutoCloseable
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.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.search.ReferenceManager
ReferenceManager.RefreshListener -
Constructor Summary
ConstructorsConstructorDescriptionReaderManager(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 Details
-
ReaderManager
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:
IOException- If there is a low-level I/O error
-
ReaderManager
Creates and returns a new ReaderManager from the givenDirectory.- Parameters:
dir- the directory to open the DirectoryReader on.- Throws:
IOException- If there is a low-level I/O error
-