public final class TermStates
extends java.lang.Object
IndexReader TermState view over
IndexReader instances containing a single term. The
TermStates doesn't track if the given TermState
objects are valid, neither if the TermState instances refer to the
same terms in the associated readers.| Modifier and Type | Field and Description |
|---|---|
private int |
docFreq |
private static TermState |
EMPTY_TERMSTATE |
private TermState[] |
states |
private Term |
term |
private java.lang.Object |
topReaderContextIdentity |
private long |
totalTermFreq |
| Modifier | Constructor and Description |
|---|---|
|
TermStates(IndexReaderContext context)
Creates an empty
TermStates from a IndexReaderContext |
|
TermStates(IndexReaderContext context,
TermState state,
int ord,
int docFreq,
long totalTermFreq)
|
private |
TermStates(Term term,
IndexReaderContext context) |
| Modifier and Type | Method and Description |
|---|---|
void |
accumulateStatistics(int docFreq,
long totalTermFreq)
Expert: Accumulate term statistics.
|
static TermStates |
build(IndexReaderContext context,
Term term,
boolean needsStats)
|
void |
clear()
Clears the
TermStates internal state and removes all
registered TermStates |
int |
docFreq()
Returns the accumulated document frequency of all
TermState
instances passed to register(TermState, int, int, long). |
TermState |
get(LeafReaderContext ctx)
|
private static TermsEnum |
loadTermsEnum(LeafReaderContext ctx,
Term term) |
void |
register(TermState state,
int ord)
Expert: Registers and associates a
TermState with an leaf ordinal. |
void |
register(TermState state,
int ord,
int docFreq,
long totalTermFreq)
Registers and associates a
TermState with an leaf ordinal. |
java.lang.String |
toString() |
long |
totalTermFreq()
Returns the accumulated term frequency of all
TermState
instances passed to register(TermState, int, int, long). |
boolean |
wasBuiltFor(IndexReaderContext context)
Expert: Return whether this
TermStates was built for the given
IndexReaderContext. |
private static final TermState EMPTY_TERMSTATE
private final java.lang.Object topReaderContextIdentity
private final TermState[] states
private final Term term
private int docFreq
private long totalTermFreq
private TermStates(Term term, IndexReaderContext context)
public TermStates(IndexReaderContext context)
TermStates from a IndexReaderContextpublic TermStates(IndexReaderContext context, TermState state, int ord, int docFreq, long totalTermFreq)
public boolean wasBuiltFor(IndexReaderContext context)
TermStates was built for the given
IndexReaderContext. This is typically used for assertions.public static TermStates build(IndexReaderContext context, Term term, boolean needsStats) throws java.io.IOException
TermStates from a top-level IndexReaderContext and the
given Term. This method will lookup the given term in all context's leaf readers
and register each of the readers containing the term in the returned TermStates
using the leaf reader's ordinal.
Note: the given context must be a top-level context.
needsStats - if true then all leaf contexts will be visited up-front to
collect term statistics. Otherwise, the TermState objects
will be built only when requestedjava.io.IOExceptionprivate static TermsEnum loadTermsEnum(LeafReaderContext ctx, Term term) throws java.io.IOException
java.io.IOExceptionpublic void clear()
TermStates internal state and removes all
registered TermStatespublic void register(TermState state, int ord, int docFreq, long totalTermFreq)
TermState with an leaf ordinal. The leaf ordinal
should be derived from a IndexReaderContext's leaf ord.public void register(TermState state, int ord)
TermState with an leaf ordinal. The
leaf ordinal should be derived from a IndexReaderContext's leaf ord.
On the contrary to register(TermState, int, int, long) this method
does NOT update term statistics.public void accumulateStatistics(int docFreq,
long totalTermFreq)
public TermState get(LeafReaderContext ctx) throws java.io.IOException
TermState for a leaf reader context or null if no
TermState for the context was registered.ctx - the LeafReaderContext to get the TermState for.TermState for the given readers ord or null if no
TermState for the reader was registeredjava.io.IOExceptionpublic int docFreq()
TermState
instances passed to register(TermState, int, int, long).TermState
instances passed to register(TermState, int, int, long).public long totalTermFreq()
TermState
instances passed to register(TermState, int, int, long).TermState
instances passed to register(TermState, int, int, long).public java.lang.String toString()
toString in class java.lang.Object