public final class SegmentReader extends CodecReader
Instances pointing to the same segment (but with different deletes, etc) may share the same core data.
IndexReader.CacheHelper, IndexReader.CacheKey, IndexReader.ClosedListener
Modifier and Type | Field and Description |
---|---|
(package private) SegmentCoreReaders |
core |
private IndexReader.CacheHelper |
coreCacheHelper
Wrap the cache helper of the core to add ensureOpen() calls that make
sure users do not register closed listeners on closed indices.
|
(package private) DocValuesProducer |
docValuesProducer |
(package private) FieldInfos |
fieldInfos |
private Bits |
hardLiveDocs |
(package private) boolean |
isNRT
True if we are holding RAM only liveDocs or DV updates, i.e.
|
private Bits |
liveDocs |
private LeafMetaData |
metaData |
private int |
numDocs |
private SegmentCommitInfo |
originalSi |
private IndexReader.CacheHelper |
readerCacheHelper |
private java.util.Set<IndexReader.ClosedListener> |
readerClosedListeners |
(package private) SegmentDocValues |
segDocValues |
private SegmentCommitInfo |
si |
Constructor and Description |
---|
SegmentReader(SegmentCommitInfo si,
int createdVersionMajor,
boolean openedFromWriter,
IOContext context,
java.util.Map<java.lang.String,java.lang.String> readerAttributes)
Constructs a new SegmentReader with a new core.
|
SegmentReader(SegmentCommitInfo si,
SegmentReader sr,
Bits liveDocs,
Bits hardLiveDocs,
int numDocs,
boolean isNRT)
Create new SegmentReader sharing core from a previous
SegmentReader and using the provided liveDocs, and recording
whether those liveDocs were carried in ram (isNRT=true).
|
Modifier and Type | Method and Description |
---|---|
private static boolean |
assertLiveDocs(boolean isNRT,
Bits hardLiveDocs,
Bits liveDocs) |
Directory |
directory()
Returns the directory this index resides in.
|
protected void |
doClose()
Implements close.
|
IndexReader.CacheHelper |
getCoreCacheHelper()
Optional method: Return a
IndexReader.CacheHelper that can be used to cache
based on the content of this leaf regardless of deletions. |
DocValuesProducer |
getDocValuesReader()
Expert: retrieve underlying DocValuesProducer
|
FieldInfos |
getFieldInfos()
Get the
FieldInfos describing all fields in
this reader. |
StoredFieldsReader |
getFieldsReader()
Expert: retrieve thread-private StoredFieldsReader
|
Bits |
getHardLiveDocs()
Returns the live docs that are not hard-deleted.
|
Bits |
getLiveDocs()
Returns the
Bits representing live (not
deleted) docs. |
LeafMetaData |
getMetaData()
Return metadata about this leaf.
|
NormsProducer |
getNormsReader()
Expert: retrieve underlying NormsProducer
|
(package private) SegmentCommitInfo |
getOriginalSegmentInfo()
Returns the original SegmentInfo passed to the segment reader on creation time.
|
PointsReader |
getPointsReader()
Expert: retrieve underlying PointsReader
|
FieldsProducer |
getPostingsReader()
Expert: retrieve underlying FieldsProducer
|
IndexReader.CacheHelper |
getReaderCacheHelper()
Optional method: Return a
IndexReader.CacheHelper that can be used to cache
based on the content of this reader. |
SegmentCommitInfo |
getSegmentInfo()
Return the SegmentInfoPerCommit of the segment this reader is reading.
|
java.lang.String |
getSegmentName()
Return the name of the segment this reader is reading.
|
TermVectorsReader |
getTermVectorsReader()
Expert: retrieve thread-private TermVectorsReader
|
private DocValuesProducer |
initDocValuesProducer()
init most recent DocValues for the current commit
|
private FieldInfos |
initFieldInfos()
init most recent FieldInfos for the current commit
|
int |
maxDoc()
Returns one greater than the largest possible document number.
|
(package private) void |
notifyReaderClosedListeners() |
int |
numDocs()
Returns the number of documents in this index.
|
java.lang.String |
toString() |
checkIntegrity, document, getBinaryDocValues, getChildResources, getNormValues, getNumericDocValues, getPointValues, getSortedDocValues, getSortedNumericDocValues, getSortedSetDocValues, getTermVectors, ramBytesUsed, terms
docFreq, getContext, getDocCount, getSumDocFreq, getSumTotalTermFreq, postings, postings, totalTermFreq
close, decRef, document, document, ensureOpen, equals, getRefCount, getTermVector, hasDeletions, hashCode, incRef, leaves, numDeletedDocs, registerParentReader, tryIncRef
private final SegmentCommitInfo si
private final SegmentCommitInfo originalSi
private final LeafMetaData metaData
private final Bits liveDocs
private final Bits hardLiveDocs
private final int numDocs
final SegmentCoreReaders core
final SegmentDocValues segDocValues
final boolean isNRT
final DocValuesProducer docValuesProducer
final FieldInfos fieldInfos
private final java.util.Set<IndexReader.ClosedListener> readerClosedListeners
private final IndexReader.CacheHelper readerCacheHelper
private final IndexReader.CacheHelper coreCacheHelper
SegmentReader(SegmentCommitInfo si, int createdVersionMajor, boolean openedFromWriter, IOContext context, java.util.Map<java.lang.String,java.lang.String> readerAttributes) throws java.io.IOException
CorruptIndexException
- if the index is corruptjava.io.IOException
- if there is a low-level IO errorSegmentReader(SegmentCommitInfo si, SegmentReader sr, Bits liveDocs, Bits hardLiveDocs, int numDocs, boolean isNRT) throws java.io.IOException
java.io.IOException
private static boolean assertLiveDocs(boolean isNRT, Bits hardLiveDocs, Bits liveDocs)
private DocValuesProducer initDocValuesProducer() throws java.io.IOException
java.io.IOException
private FieldInfos initFieldInfos() throws java.io.IOException
java.io.IOException
public Bits getLiveDocs()
LeafReader
Bits
representing live (not
deleted) docs. A set bit indicates the doc ID has not
been deleted. If this method returns null it means
there are no deleted documents (all documents are
live).
The returned instance has been safely published for
use by multiple threads without additional
synchronization.getLiveDocs
in class LeafReader
protected void doClose() throws java.io.IOException
IndexReader
doClose
in class CodecReader
java.io.IOException
public FieldInfos getFieldInfos()
LeafReader
FieldInfos
describing all fields in
this reader.
Note: Implementations should cache the FieldInfos
instance returned by this method such that subsequent
calls to this method return the same instance.getFieldInfos
in class LeafReader
public int numDocs()
IndexReader
numDocs
in class IndexReader
public int maxDoc()
IndexReader
maxDoc
in class IndexReader
public TermVectorsReader getTermVectorsReader()
CodecReader
getTermVectorsReader
in class CodecReader
public StoredFieldsReader getFieldsReader()
CodecReader
getFieldsReader
in class CodecReader
public PointsReader getPointsReader()
CodecReader
getPointsReader
in class CodecReader
public NormsProducer getNormsReader()
CodecReader
getNormsReader
in class CodecReader
public DocValuesProducer getDocValuesReader()
CodecReader
getDocValuesReader
in class CodecReader
public FieldsProducer getPostingsReader()
CodecReader
getPostingsReader
in class CodecReader
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getSegmentName()
public SegmentCommitInfo getSegmentInfo()
public Directory directory()
void notifyReaderClosedListeners() throws java.io.IOException
notifyReaderClosedListeners
in class IndexReader
java.io.IOException
public IndexReader.CacheHelper getReaderCacheHelper()
IndexReader
IndexReader.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 IndexReader
public IndexReader.CacheHelper getCoreCacheHelper()
LeafReader
IndexReader.CacheHelper
that can be used to cache
based on the content of this leaf regardless of deletions. Two readers
that have the same data but different sets of deleted documents or doc
values updates may be considered equal. Consider using
IndexReader.getReaderCacheHelper()
if you need deletions or dv updates to be
taken into account.
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 leaf reader.
getCoreCacheHelper
in class LeafReader
public LeafMetaData getMetaData()
LeafReader
getMetaData
in class LeafReader
SegmentCommitInfo getOriginalSegmentInfo()
getSegmentInfo()
returns a clone of this instance.public Bits getHardLiveDocs()