Class GroupReducer<T,C extends Collector>
- java.lang.Object
-
- org.apache.lucene.search.grouping.GroupReducer<T,C>
-
- Type Parameters:
T
- the type of the value used for groupingC
- the type ofCollector
used to reduce each group
- Direct Known Subclasses:
DistinctValuesCollector.DistinctValuesReducer
,TopGroupsCollector.TopDocsReducer
public abstract class GroupReducer<T,C extends Collector> extends java.lang.Object
Concrete implementations of this class define what to collect for individual groups during the second-pass of a grouping search.Each group is assigned a Collector returned by
newCollector()
, andLeafCollector.collect(int)
is called for each document that is in a group- See Also:
SecondPassGroupingCollector
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
GroupReducer.GroupCollector<C extends Collector>
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<T,GroupReducer.GroupCollector<C>>
groups
-
Constructor Summary
Constructors Constructor Description GroupReducer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
collect(T value, int doc)
Collect a given document into a given groupC
getCollector(T value)
Get the Collector for a given groupabstract boolean
needsScores()
Whether or not this reducer requires collected documents to be scoredprotected abstract C
newCollector()
Creates a new Collector for each groupvoid
setGroups(java.util.Collection<SearchGroup<T>> groups)
Define which groups should be reduced.void
setNextReader(LeafReaderContext ctx)
Called when the parentSecondPassGroupingCollector
moves to a new segmentvoid
setScorer(Scorable scorer)
Set the Scorer on all group collectors
-
-
-
Field Detail
-
groups
private final java.util.Map<T,GroupReducer.GroupCollector<C extends Collector>> groups
-
-
Method Detail
-
setGroups
public void setGroups(java.util.Collection<SearchGroup<T>> groups)
Define which groups should be reduced.Called by
SecondPassGroupingCollector
-
needsScores
public abstract boolean needsScores()
Whether or not this reducer requires collected documents to be scored
-
newCollector
protected abstract C newCollector()
Creates a new Collector for each group
-
collect
public final void collect(T value, int doc) throws java.io.IOException
Collect a given document into a given group- Throws:
java.io.IOException
- on error
-
setScorer
public final void setScorer(Scorable scorer) throws java.io.IOException
Set the Scorer on all group collectors- Throws:
java.io.IOException
-
setNextReader
public final void setNextReader(LeafReaderContext ctx) throws java.io.IOException
Called when the parentSecondPassGroupingCollector
moves to a new segment- Throws:
java.io.IOException
-
-