public abstract class FilterDirectoryReader extends DirectoryReader
Modifier and Type | Class and Description |
---|---|
static class |
FilterDirectoryReader.SubReaderWrapper
Factory class passed to FilterDirectoryReader constructor that allows
subclasses to wrap the filtered DirectoryReader's subreaders.
|
IndexReader.ReaderClosedListener
Modifier and Type | Field and Description |
---|---|
protected DirectoryReader |
in
The filtered DirectoryReader
|
directory
Constructor and Description |
---|
FilterDirectoryReader(DirectoryReader in,
FilterDirectoryReader.SubReaderWrapper wrapper)
Create a new FilterDirectoryReader that filters a passed in DirectoryReader,
using the supplied SubReaderWrapper to wrap its subreader.
|
Modifier and Type | Method and Description |
---|---|
protected void |
doClose()
Implements close.
|
protected DirectoryReader |
doOpenIfChanged()
Implement this method to support
DirectoryReader.openIfChanged(DirectoryReader) . |
protected DirectoryReader |
doOpenIfChanged(IndexCommit commit)
Implement this method to support
DirectoryReader.openIfChanged(DirectoryReader,IndexCommit) . |
protected DirectoryReader |
doOpenIfChanged(IndexWriter writer,
boolean applyAllDeletes)
Implement this method to support
DirectoryReader.openIfChanged(DirectoryReader,IndexWriter,boolean) . |
protected abstract DirectoryReader |
doWrapDirectoryReader(DirectoryReader in)
Called by the doOpenIfChanged() methods to return a new wrapped DirectoryReader.
|
DirectoryReader |
getDelegate()
Returns the wrapped
DirectoryReader . |
IndexCommit |
getIndexCommit()
Expert: return the IndexCommit that this reader has opened.
|
long |
getVersion()
Version number when this IndexReader was opened.
|
boolean |
isCurrent()
Check whether any new changes have occurred to the
index since this reader was opened.
|
static DirectoryReader |
unwrap(DirectoryReader reader)
Get the wrapped instance by
reader as long as this reader is
an instance of FilterDirectoryReader . |
directory, indexExists, listCommits, open, open, open, open, openIfChanged, openIfChanged, openIfChanged, openIfChanged
docFreq, document, getDocCount, getSequentialSubReaders, getSumDocFreq, getSumTotalTermFreq, getTermVectors, maxDoc, numDocs, readerBase, readerIndex, totalTermFreq
getContext, toString
addReaderClosedListener, close, decRef, document, document, ensureOpen, equals, getCombinedCoreAndDeletesKey, getCoreCacheKey, getRefCount, getTermVector, hasDeletions, hashCode, incRef, leaves, numDeletedDocs, registerParentReader, removeReaderClosedListener, tryIncRef
protected final DirectoryReader in
public FilterDirectoryReader(DirectoryReader in, FilterDirectoryReader.SubReaderWrapper wrapper) throws IOException
in
- the DirectoryReader to filterwrapper
- the SubReaderWrapper to use to wrap subreadersIOException
public static DirectoryReader unwrap(DirectoryReader reader)
reader
as long as this reader is
an instance of FilterDirectoryReader
.protected abstract DirectoryReader doWrapDirectoryReader(DirectoryReader in) throws IOException
in
- the DirectoryReader to wrapIOException
protected final DirectoryReader doOpenIfChanged() throws IOException
DirectoryReader
DirectoryReader.openIfChanged(DirectoryReader)
.
If this reader does not support reopen, return null
, so
client code is happy. This should be consistent with DirectoryReader.isCurrent()
(should always return true
) if reopen is not supported.doOpenIfChanged
in class DirectoryReader
IOException
- if there is a low-level IO errorprotected final DirectoryReader doOpenIfChanged(IndexCommit commit) throws IOException
DirectoryReader
DirectoryReader.openIfChanged(DirectoryReader,IndexCommit)
.
If this reader does not support reopen from a specific IndexCommit
,
throw UnsupportedOperationException
.doOpenIfChanged
in class DirectoryReader
IOException
- if there is a low-level IO errorprotected final DirectoryReader doOpenIfChanged(IndexWriter writer, boolean applyAllDeletes) throws IOException
DirectoryReader
DirectoryReader.openIfChanged(DirectoryReader,IndexWriter,boolean)
.
If this reader does not support reopen from IndexWriter
,
throw UnsupportedOperationException
.doOpenIfChanged
in class DirectoryReader
IOException
- if there is a low-level IO errorpublic long getVersion()
DirectoryReader
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
.
getVersion
in class DirectoryReader
public boolean isCurrent() throws IOException
DirectoryReader
If this reader was created by calling DirectoryReader.open(org.apache.lucene.store.Directory)
,
then this method checks if any further commits
(see IndexWriter.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 calling DirectoryReader.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.
isCurrent
in class DirectoryReader
IOException
- if there is a low-level IO errorpublic IndexCommit getIndexCommit() throws IOException
DirectoryReader
getIndexCommit
in class DirectoryReader
IOException
protected void doClose() throws IOException
IndexReader
doClose
in class IndexReader
IOException
public DirectoryReader getDelegate()
DirectoryReader
.Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.