public abstract class AllGroupHeadsCollector<T> extends SimpleCollector
newCollector(GroupSelector, Sort)
Modifier and Type | Class and Description |
---|---|
static class |
AllGroupHeadsCollector.GroupHead<T>
Represents a group head.
|
private static class |
AllGroupHeadsCollector.ScoringGroupHead<T> |
private static class |
AllGroupHeadsCollector.ScoringGroupHeadsCollector<T>
Specialized implementation for sorting by score
|
private static class |
AllGroupHeadsCollector.SortingGroupHead<T> |
private static class |
AllGroupHeadsCollector.SortingGroupHeadsCollector<T>
General implementation using a
FieldComparator to select the group head |
Modifier and Type | Field and Description |
---|---|
protected int |
compIDXEnd |
protected LeafReaderContext |
context |
private GroupSelector<T> |
groupSelector |
protected java.util.Map<T,AllGroupHeadsCollector.GroupHead<T>> |
heads |
protected int[] |
reversed |
protected Scorable |
scorer |
protected Sort |
sort |
Modifier | Constructor and Description |
---|---|
private |
AllGroupHeadsCollector(GroupSelector<T> selector,
Sort sort) |
Modifier and Type | Method and Description |
---|---|
void |
collect(int doc)
Called once for every document matching a query, with the unbased document
number.
|
protected void |
doSetNextReader(LeafReaderContext context)
This method is called before collecting
context . |
protected java.util.Collection<? extends AllGroupHeadsCollector.GroupHead<T>> |
getCollectedGroupHeads()
Returns the collected group heads.
|
int |
groupHeadsSize() |
static <T> AllGroupHeadsCollector<T> |
newCollector(GroupSelector<T> selector,
Sort sort)
Create a new AllGroupHeadsCollector based on the type of within-group Sort required
|
protected abstract AllGroupHeadsCollector.GroupHead<T> |
newGroupHead(int doc,
T value,
LeafReaderContext context,
Scorable scorer)
Create a new GroupHead for the given group value, initialized with a doc, context and scorer
|
int[] |
retrieveGroupHeads() |
FixedBitSet |
retrieveGroupHeads(int maxDoc) |
ScoreMode |
scoreMode()
Indicates what features are required from the scorer.
|
void |
setScorer(Scorable scorer)
Called before successive calls to
LeafCollector.collect(int) . |
getLeafCollector
private final GroupSelector<T> groupSelector
protected final Sort sort
protected final int[] reversed
protected final int compIDXEnd
protected java.util.Map<T,AllGroupHeadsCollector.GroupHead<T>> heads
protected LeafReaderContext context
protected Scorable scorer
private AllGroupHeadsCollector(GroupSelector<T> selector, Sort sort)
public static <T> AllGroupHeadsCollector<T> newCollector(GroupSelector<T> selector, Sort sort)
T
- the group value typeselector
- a GroupSelector to define the groupssort
- the within-group sort to use to choose the group head documentpublic FixedBitSet retrieveGroupHeads(int maxDoc)
maxDoc
- The maxDoc of the top level IndexReader
.FixedBitSet
containing all group heads.public int[] retrieveGroupHeads()
public int groupHeadsSize()
protected java.util.Collection<? extends AllGroupHeadsCollector.GroupHead<T>> getCollectedGroupHeads()
public void collect(int doc) throws java.io.IOException
LeafCollector
Note: The collection of the current segment can be terminated by throwing
a CollectionTerminatedException
. In this case, the last docs of the
current LeafReaderContext
will be skipped and IndexSearcher
will swallow the exception and continue collection with the next leaf.
Note: This is called in an inner search loop. For good search performance,
implementations of this method should not call IndexSearcher.doc(int)
or
IndexReader.document(int)
on every hit.
Doing so can slow searches by an order of magnitude or more.
collect
in interface LeafCollector
collect
in class SimpleCollector
java.io.IOException
public ScoreMode scoreMode()
Collector
protected void doSetNextReader(LeafReaderContext context) throws java.io.IOException
SimpleCollector
context
.doSetNextReader
in class SimpleCollector
java.io.IOException
public void setScorer(Scorable scorer) throws java.io.IOException
LeafCollector
LeafCollector.collect(int)
. Implementations
that need the score of the current document (passed-in to
LeafCollector.collect(int)
), should save the passed-in Scorer and call
scorer.score() when needed.setScorer
in interface LeafCollector
setScorer
in class SimpleCollector
java.io.IOException
protected abstract AllGroupHeadsCollector.GroupHead<T> newGroupHead(int doc, T value, LeafReaderContext context, Scorable scorer) throws java.io.IOException
java.io.IOException