Class NearRealTimeIndexReaderProvider
java.lang.Object
org.hibernate.search.backend.lucene.lowlevel.reader.impl.NearRealTimeIndexReaderProvider
- All Implemented Interfaces:
IndexReaderProvider
A index reader holder that opens an index reader from the index writer,
thereby providing a near-real-time view on the index.
The index reader is instantiated once and shared among all threads for as long as it is deemed "current", i.e. as long as there were no changes from the directory every time an index reader is requested.
Heavily inspired by org.hibernate.search.backend.impl.lucene.NRTWorkspaceImpl from Hibernate Search 5
by Sanne Grinovero.
-
Constructor Summary
ConstructorsConstructorDescriptionNearRealTimeIndexReaderProvider(IndexWriterProvider indexWriterProvider, TimingSource timingSource, int refreshInterval) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Closes and drops any cached resources (index readers in particular).org.apache.lucene.index.DirectoryReaderorg.apache.lucene.index.DirectoryReader
-
Constructor Details
-
NearRealTimeIndexReaderProvider
public NearRealTimeIndexReaderProvider(IndexWriterProvider indexWriterProvider, TimingSource timingSource, int refreshInterval)
-
-
Method Details
-
clear
Description copied from interface:IndexReaderProviderCloses and drops any cached resources (index readers in particular).Should be used when stopping the index, to clean up upon error, or simply to force the creation of a new reader (refresh) on the next call to
IndexReaderProvider.getOrCreate().- Specified by:
clearin interfaceIndexReaderProvider- Throws:
IOException
-
getOrCreate
- Specified by:
getOrCreatein interfaceIndexReaderProvider- Returns:
- A ready-to-use index reader, with its reference count already increased.
Callers are responsible for calling
IndexReader.decRef()when they are done with the index reader. Callers must not callIndexReader.close(), as the index reader may be shared. - Throws:
IOException
-
getCurrentForTests
- Specified by:
getCurrentForTestsin interfaceIndexReaderProvider- Throws:
IOException
-