|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.index.IndexReader org.apache.lucene.index.CompositeReader org.apache.lucene.index.BaseCompositeReader<R>
public abstract class BaseCompositeReader<R extends IndexReader>
Base class for implementing CompositeReader
s based on an array
of sub-readers. The implementing class has to add code for
correctly refcounting and closing the sub-readers.
User code will most likely use MultiReader
to build a
composite reader on a set of sub-readers (like several
DirectoryReader
s).
For efficiency, in this API documents are often referred to via document numbers, non-negative integers which each name a unique document in the index. These document numbers are ephemeral -- they may change as documents are added to and deleted from an index. Clients should thus not rely on a given document having the same number between sessions.
NOTE: IndexReader
instances are completely thread
safe, meaning multiple threads can call any of its methods,
concurrently. If your application requires external
synchronization, you should not synchronize on the
IndexReader
instance; use your own
(non-Lucene) objects instead.
MultiReader
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.lucene.index.IndexReader |
---|
IndexReader.ReaderClosedListener |
Constructor Summary | |
---|---|
protected |
BaseCompositeReader(R[] subReaders)
Constructs a BaseCompositeReader on the given subReaders. |
Method Summary | |
---|---|
int |
docFreq(Term term)
Returns the number of documents containing the term . |
void |
document(int docID,
StoredFieldVisitor visitor)
Expert: visits the fields of a stored document, for custom processing/loading of each field. |
protected List<? extends R> |
getSequentialSubReaders()
Expert: returns the sequential sub readers that this reader is logically composed of. |
Fields |
getTermVectors(int docID)
Retrieve term vectors for this document, or null if term vectors were not indexed. |
boolean |
hasDeletions()
Returns true if any documents have been deleted |
int |
maxDoc()
Returns one greater than the largest possible document number. |
int |
numDocs()
Returns the number of documents in this index. |
protected int |
readerBase(int readerIndex)
Helper method for subclasses to get the docBase of the given sub-reader index. |
protected int |
readerIndex(int docID)
Helper method for subclasses to get the corresponding reader for a doc ID |
long |
totalTermFreq(Term term)
Returns the number of documents containing the term term . |
Methods inherited from class org.apache.lucene.index.CompositeReader |
---|
getContext, toString |
Methods inherited from class org.apache.lucene.index.IndexReader |
---|
addReaderClosedListener, close, decRef, doClose, document, document, ensureOpen, equals, getCombinedCoreAndDeletesKey, getCoreCacheKey, getRefCount, getTermVector, hashCode, incRef, leaves, numDeletedDocs, open, open, open, open, open, registerParentReader, removeReaderClosedListener, tryIncRef |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected BaseCompositeReader(R[] subReaders)
BaseCompositeReader
on the given subReaders.
subReaders
- the wrapped sub-readers. This array is returned by
getSequentialSubReaders()
and used to resolve the correct
subreader for docID-based methods. Please note: This array is not
cloned and not protected for modification, the subclass is responsible
to do this.Method Detail |
---|
public final Fields getTermVectors(int docID) throws IOException
IndexReader
getTermVectors
in class IndexReader
IOException
public final int numDocs()
IndexReader
numDocs
in class IndexReader
public final int maxDoc()
IndexReader
maxDoc
in class IndexReader
public final void document(int docID, StoredFieldVisitor visitor) throws IOException
IndexReader
IndexReader.document(int)
. If you want to load a subset, use
DocumentStoredFieldVisitor
.
document
in class IndexReader
IOException
public final boolean hasDeletions()
IndexReader
hasDeletions
in class IndexReader
public final int docFreq(Term term) throws IOException
IndexReader
term
. This method returns 0 if the term or
field does not exists. This method does not take into
account deleted documents that have not yet been merged
away.
docFreq
in class IndexReader
IOException
TermsEnum.docFreq()
public final long totalTermFreq(Term term) throws IOException
IndexReader
term
. This method returns 0 if the term or
field does not exists, or -1 if the Codec does not support
the measure. This method does not take into account deleted
documents that have not yet been merged away.
totalTermFreq
in class IndexReader
IOException
TermsEnum.totalTermFreq()
protected final int readerIndex(int docID)
protected final int readerBase(int readerIndex)
protected final List<? extends R> getSequentialSubReaders()
CompositeReader
null
.
NOTE: In contrast to previous Lucene versions this method
is no longer public, code that wants to get all AtomicReader
s
this composite is composed of should use IndexReader.leaves()
.
getSequentialSubReaders
in class CompositeReader
IndexReader.leaves()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |