Class FilterDirectoryReader
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
ExitableDirectoryReader,SoftDeletesDirectoryReaderWrapper
Subclasses should implement doWrapDirectoryReader to return an instance of the subclass.
If the subclass wants to wrap the DirectoryReader's subreaders, it should also implement a SubReaderWrapper subclass, and pass an instance to its super constructor.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA DelegatingCacheHelper is a CacheHelper specialization for implementing long-lived caching behaviour for FilterDirectoryReader subclasses.static classFactory class passed to FilterDirectoryReader constructor that allows subclasses to wrap the filtered DirectoryReader's subreaders.Nested classes/interfaces inherited from class org.apache.lucene.index.IndexReader
IndexReader.CacheHelper, IndexReader.CacheKey, IndexReader.ClosedListener -
Field Summary
FieldsFields inherited from class org.apache.lucene.index.DirectoryReader
directoryFields inherited from class org.apache.lucene.index.BaseCompositeReader
subReadersSorter -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new FilterDirectoryReader that filters a passed in DirectoryReader, using the supplied SubReaderWrapper to wrap its subreader. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoClose()Implements close.protected final DirectoryReaderImplement this method to supportDirectoryReader.openIfChanged(DirectoryReader).protected final DirectoryReaderdoOpenIfChanged(IndexCommit commit) Implement this method to supportDirectoryReader.openIfChanged(DirectoryReader,IndexCommit).protected final DirectoryReaderdoOpenIfChanged(IndexWriter writer, boolean applyAllDeletes) Implement this method to supportDirectoryReader.openIfChanged(DirectoryReader,IndexWriter,boolean).protected abstract DirectoryReaderCalled by the doOpenIfChanged() methods to return a new wrapped DirectoryReader.Returns the wrappedDirectoryReader.Expert: return the IndexCommit that this reader has opened.longVersion number when this IndexReader was opened.booleanCheck whether any new changes have occurred to the index since this reader was opened.static DirectoryReaderunwrap(DirectoryReader reader) Get the wrapped instance byreaderas long as this reader is an instance ofFilterDirectoryReader.Methods inherited from class org.apache.lucene.index.DirectoryReader
directory, indexExists, listCommits, open, open, open, open, open, open, openIfChanged, openIfChanged, openIfChanged, openIfChangedMethods inherited from class org.apache.lucene.index.BaseCompositeReader
docFreq, getDocCount, getSequentialSubReaders, getSumDocFreq, getSumTotalTermFreq, maxDoc, numDocs, readerBase, readerIndex, storedFields, termVectors, totalTermFreqMethods inherited from class org.apache.lucene.index.CompositeReader
getContext, toStringMethods inherited from class org.apache.lucene.index.IndexReader
close, decRef, ensureOpen, equals, getReaderCacheHelper, getRefCount, hasDeletions, hashCode, incRef, leaves, notifyReaderClosedListeners, numDeletedDocs, registerParentReader, tryIncRef
-
Field Details
-
in
The filtered DirectoryReader
-
-
Constructor Details
-
FilterDirectoryReader
public FilterDirectoryReader(DirectoryReader in, FilterDirectoryReader.SubReaderWrapper wrapper) throws IOException Create a new FilterDirectoryReader that filters a passed in DirectoryReader, using the supplied SubReaderWrapper to wrap its subreader.- Parameters:
in- the DirectoryReader to filterwrapper- the SubReaderWrapper to use to wrap subreaders- Throws:
IOException
-
-
Method Details
-
unwrap
Get the wrapped instance byreaderas long as this reader is an instance ofFilterDirectoryReader. -
doWrapDirectoryReader
Called by the doOpenIfChanged() methods to return a new wrapped DirectoryReader.Implementations should just return an instantiation of themselves, wrapping the passed in DirectoryReader.
- Parameters:
in- the DirectoryReader to wrap- Returns:
- the wrapped DirectoryReader
- Throws:
IOException
-
doOpenIfChanged
Description copied from class:DirectoryReaderImplement this method to supportDirectoryReader.openIfChanged(DirectoryReader). If this reader does not support reopen, returnnull, so client code is happy. This should be consistent withDirectoryReader.isCurrent()(should always returntrue) if reopen is not supported.- Specified by:
doOpenIfChangedin classDirectoryReader- Returns:
- null if there are no changes; else, a new DirectoryReader instance.
- Throws:
IOException- if there is a low-level IO error
-
doOpenIfChanged
Description copied from class:DirectoryReaderImplement this method to supportDirectoryReader.openIfChanged(DirectoryReader,IndexCommit). If this reader does not support reopen from a specificIndexCommit, throwUnsupportedOperationException.- Specified by:
doOpenIfChangedin classDirectoryReader- Returns:
- null if there are no changes; else, a new DirectoryReader instance.
- Throws:
IOException- if there is a low-level IO error
-
doOpenIfChanged
protected final DirectoryReader doOpenIfChanged(IndexWriter writer, boolean applyAllDeletes) throws IOException Description copied from class:DirectoryReaderImplement this method to supportDirectoryReader.openIfChanged(DirectoryReader,IndexWriter,boolean). If this reader does not support reopen fromIndexWriter, throwUnsupportedOperationException.- Specified by:
doOpenIfChangedin classDirectoryReader- Returns:
- null if there are no changes; else, a new DirectoryReader instance.
- Throws:
IOException- if there is a low-level IO error
-
getVersion
public long getVersion()Description copied from class:DirectoryReaderVersion number when this IndexReader was opened.This method returns the version recorded in the commit that the reader opened. This version is advanced every time a change is made with
IndexWriter.- Specified by:
getVersionin classDirectoryReader
-
isCurrent
Description copied from class:DirectoryReaderCheck whether any new changes have occurred to the index since this reader was opened.If this reader was created by calling
DirectoryReader.open(org.apache.lucene.store.Directory), then this method checks if any further commits (seeIndexWriter.commit()) have occurred in the directory.If instead this reader is a near real-time reader (ie, obtained by a call to
DirectoryReader.open(IndexWriter), or by callingDirectoryReader.openIfChanged(org.apache.lucene.index.DirectoryReader)on a near real-time reader), then this method checks if either a new commit has occurred, or any new uncommitted changes have taken place via the writer. Note that even if the writer has only performed merging, this method will still return false.In any event, if this returns false, you should call
DirectoryReader.openIfChanged(org.apache.lucene.index.DirectoryReader)to get a new reader that sees the changes.- Specified by:
isCurrentin classDirectoryReader- Throws:
IOException- if there is a low-level IO error
-
getIndexCommit
Description copied from class:DirectoryReaderExpert: return the IndexCommit that this reader has opened.- Specified by:
getIndexCommitin classDirectoryReader- Throws:
IOException
-
doClose
Description copied from class:IndexReaderImplements close.- Specified by:
doClosein classIndexReader- Throws:
IOException
-
getDelegate
Returns the wrappedDirectoryReader.
-