public final class StandardDirectoryReader extends DirectoryReader
DirectoryReader.IndexReader.CacheHelper, IndexReader.CacheKey, IndexReader.ClosedListenerdirectorysubReadersSorter| 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). |
IndexCommit |
getIndexCommit()
Expert: return the IndexCommit that this reader has opened.
|
IndexReader.CacheHelper |
getReaderCacheHelper()
Optional method: Return a
IndexReader.CacheHelper that can be used to cache
based on the content of this reader. |
SegmentInfos |
getSegmentInfos()
Return the
SegmentInfos for this reader. |
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 |
open(Directory directory,
SegmentInfos infos,
List<? extends LeafReader> oldReaders,
Comparator<LeafReader> leafSorter)
This constructor is only used for
doOpenIfChanged(SegmentInfos), as well as NRT replication. |
String |
toString() |
directory, indexExists, listCommits, open, open, open, open, open, openIfChanged, openIfChanged, openIfChanged, openIfChangeddocFreq, document, getDocCount, getSequentialSubReaders, getSumDocFreq, getSumTotalTermFreq, getTermVectors, maxDoc, numDocs, readerBase, readerIndex, totalTermFreqgetContextclose, decRef, document, document, ensureOpen, equals, getRefCount, getTermVector, hasDeletions, hashCode, incRef, leaves, numDeletedDocs, registerParentReader, tryIncRefpublic static DirectoryReader open(Directory directory, SegmentInfos infos, List<? extends LeafReader> oldReaders, Comparator<LeafReader> leafSorter) throws IOException
doOpenIfChanged(SegmentInfos), as well as NRT replication.IOExceptionpublic String toString()
toString in class CompositeReaderprotected DirectoryReader doOpenIfChanged() throws IOException
DirectoryReaderDirectoryReader.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 DirectoryReaderIOException - if there is a low-level IO errorprotected DirectoryReader doOpenIfChanged(IndexCommit commit) throws IOException
DirectoryReaderDirectoryReader.openIfChanged(DirectoryReader,IndexCommit).
If this reader does not support reopen from a specific IndexCommit,
throw UnsupportedOperationException.doOpenIfChanged in class DirectoryReaderIOException - if there is a low-level IO errorprotected DirectoryReader doOpenIfChanged(IndexWriter writer, boolean applyAllDeletes) throws IOException
DirectoryReaderDirectoryReader.openIfChanged(DirectoryReader,IndexWriter,boolean).
If this reader does not support reopen from IndexWriter,
throw UnsupportedOperationException.doOpenIfChanged in class DirectoryReaderIOException - if there is a low-level IO errorpublic long getVersion()
DirectoryReaderThis 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 DirectoryReaderpublic SegmentInfos getSegmentInfos()
SegmentInfos for this reader.public boolean isCurrent()
throws IOException
DirectoryReaderIf 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 DirectoryReaderIOException - if there is a low-level IO errorprotected void doClose()
throws IOException
IndexReaderdoClose in class IndexReaderIOExceptionpublic IndexCommit getIndexCommit() throws IOException
DirectoryReadergetIndexCommit in class DirectoryReaderIOExceptionpublic IndexReader.CacheHelper getReaderCacheHelper()
IndexReaderIndexReader.CacheHelper that can be used to cache
based on the content of this reader. Two readers that have different data
or different sets of deleted documents will be considered different.
A return value of null indicates that this reader is not suited
for caching, which is typically the case for short-lived wrappers that
alter the content of the wrapped reader.
getReaderCacheHelper in class IndexReaderCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.