Package org.apache.lucene.index
Class TermContext
- java.lang.Object
-
- org.apache.lucene.index.TermContext
-
public final class TermContext extends java.lang.ObjectMaintains aIndexReaderTermStateview overIndexReaderinstances containing a single term. TheTermContextdoesn't track if the givenTermStateobjects are valid, neither if theTermStateinstances refer to the same terms in the associated readers.
-
-
Field Summary
Fields Modifier and Type Field Description IndexReaderContexttopReaderContextHolds theIndexReaderContextof the top-levelIndexReader, used internally only for asserting.
-
Constructor Summary
Constructors Constructor Description TermContext(IndexReaderContext context)Creates an emptyTermContextfrom aIndexReaderContextTermContext(IndexReaderContext context, TermState state, int ord, int docFreq, long totalTermFreq)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TermContextbuild(IndexReaderContext context, Term term)voidclear()Clears theTermContextinternal state and removes all registeredTermStatesintdocFreq()Returns the accumulated document frequency of allTermStateinstances passed toregister(TermState, int, int, long).TermStateget(int ord)voidregister(TermState state, int ord, int docFreq, long totalTermFreq)Registers and associates aTermStatewith an leaf ordinal.voidsetDocFreq(int docFreq)expert: only available for queries that want to lie about docfreqlongtotalTermFreq()Returns the accumulated term frequency of allTermStateinstances passed toregister(TermState, int, int, long).
-
-
-
Field Detail
-
topReaderContext
public final IndexReaderContext topReaderContext
Holds theIndexReaderContextof the top-levelIndexReader, used internally only for asserting.
-
-
Constructor Detail
-
TermContext
public TermContext(IndexReaderContext context)
Creates an emptyTermContextfrom aIndexReaderContext
-
TermContext
public TermContext(IndexReaderContext context, TermState state, int ord, int docFreq, long totalTermFreq)
-
-
Method Detail
-
build
public static TermContext build(IndexReaderContext context, Term term) throws java.io.IOException
Creates aTermContextfrom a top-levelIndexReaderContextand the givenTerm. This method will lookup the given term in all context's leaf readers and register each of the readers containing the term in the returnedTermContextusing the leaf reader's ordinal.Note: the given context must be a top-level context.
- Throws:
java.io.IOException
-
clear
public void clear()
Clears theTermContextinternal state and removes all registeredTermStates
-
register
public void register(TermState state, int ord, int docFreq, long totalTermFreq)
Registers and associates aTermStatewith an leaf ordinal. The leaf ordinal should be derived from aIndexReaderContext's leaf ord.
-
get
public TermState get(int ord)
-
docFreq
public int docFreq()
Returns the accumulated document frequency of allTermStateinstances passed toregister(TermState, int, int, long).- Returns:
- the accumulated document frequency of all
TermStateinstances passed toregister(TermState, int, int, long).
-
totalTermFreq
public long totalTermFreq()
Returns the accumulated term frequency of allTermStateinstances passed toregister(TermState, int, int, long).- Returns:
- the accumulated term frequency of all
TermStateinstances passed toregister(TermState, int, int, long).
-
setDocFreq
public void setDocFreq(int docFreq)
expert: only available for queries that want to lie about docfreq
-
-