Package com.yahoo.searchlib.aggregation
Class Group
- java.lang.Object
-
- com.yahoo.vespa.objects.Selectable
-
- com.yahoo.vespa.objects.Identifiable
-
- com.yahoo.searchlib.aggregation.Group
-
- All Implemented Interfaces:
Cloneable
public class Group extends com.yahoo.vespa.objects.Identifiable
-
-
Field Summary
Fields Modifier and Type Field Description static int
classId
-
Constructor Summary
Constructors Constructor Description Group()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Group
addAggregationResult(AggregationResult result)
Adds an aggregation result to this group.Group
addChild(Group child)
Adds a child group to this.Group
addOrderBy(ExpressionNode exp, boolean asc)
Adds an order-by expression to this group.Group
clone()
boolean
equals(Object obj)
List<AggregationResult>
getAggregationResults()
Returns this group's aggregation results.List<Group>
getChildren()
Returns the list of child groups to this.ResultNode
getId()
Returns the label to use for this group.List<ExpressionNode>
getOrderByExpressions()
List<Integer>
getOrderByIndexes()
double
getRank()
Return the rank score of this group.int
getTag()
Returns the tag of this group.int
hashCode()
boolean
isRankedByRelevance()
This tells you if the children are ranked by the pure relevance or by a more complex expression.void
merge(int firstLevel, int currentLevel, Group rhs)
Merges the content of the given group into this.protected void
onDeserialize(com.yahoo.vespa.objects.Deserializer buf)
protected int
onGetClassId()
protected void
onSerialize(com.yahoo.vespa.objects.Serializer buf)
void
postMerge(List<GroupingLevel> levels, int firstLevel, int currentLevel)
After merging, this method will prune all levels so that they do not exceed the configured maximum number of groups per level.void
selectMembers(com.yahoo.vespa.objects.ObjectPredicate predicate, com.yahoo.vespa.objects.ObjectOperation operation)
Group
setId(ResultNode id)
Sets the label to use for this group.Group
setRank(double rank)
Sets the relevancy to use for this group.Group
setTag(int tag)
Assigns a tag to this group.void
sortChildrenById()
Sorts the children by their id, if they are not sorted already.void
sortChildrenByRank()
Sorts the children by their rank, if they are not sorted already.void
visitMembers(com.yahoo.vespa.objects.ObjectVisitor visitor)
-
-
-
Method Detail
-
isRankedByRelevance
public boolean isRankedByRelevance()
This tells you if the children are ranked by the pure relevance or by a more complex expression. That indicates if the rank score from the child can be used for ordering.- Returns:
- true if it ranked by pure relevance.
-
merge
public void merge(int firstLevel, int currentLevel, Group rhs)
Merges the content of the given group into this. When this function returns, make sure to callpostMerge(java.util.List, int, int)
.- Parameters:
firstLevel
- The first level to merge.currentLevel
- The current level.rhs
- The group to merge with.
-
postMerge
public void postMerge(List<GroupingLevel> levels, int firstLevel, int currentLevel)
After merging, this method will prune all levels so that they do not exceed the configured maximum number of groups per level.- Parameters:
levels
- The specs of all grouping levels.firstLevel
- The first level to merge.currentLevel
- The current level.
-
sortChildrenById
public void sortChildrenById()
Sorts the children by their id, if they are not sorted already.
-
sortChildrenByRank
public void sortChildrenByRank()
Sorts the children by their rank, if they are not sorted already.
-
getId
public ResultNode getId()
Returns the label to use for this group. See comment onsetId(com.yahoo.searchlib.expression.ResultNode)
on the rationale of this being aResultNode
.
-
setId
public Group setId(ResultNode id)
Sets the label to use for this group. This is aResultNode
so that a group can be labeled with whatever value the classifier expression returns.- Parameters:
id
- the label to set- Returns:
- this, to allow chaining
-
setRank
public Group setRank(double rank)
Sets the relevancy to use for this group.- Parameters:
rank
- The rank to set.- Returns:
- This, to allow chaining.
-
getRank
public double getRank()
Return the rank score of this group.
-
addChild
public Group addChild(Group child)
Adds a child group to this.- Parameters:
child
- The group to add.- Returns:
- This, to allow chaining.
-
getTag
public int getTag()
Returns the tag of this group. This value is set per-level in the grouping request, and then becomes assigned to each group of that level in the grouping result as they are copied from the prototype.
-
setTag
public Group setTag(int tag)
Assigns a tag to this group.- Parameters:
tag
- the numerical tag to set- Returns:
- this, to allow chaining
-
getAggregationResults
public List<AggregationResult> getAggregationResults()
Returns this group's aggregation results.- Returns:
- the aggregation results
-
addAggregationResult
public Group addAggregationResult(AggregationResult result)
Adds an aggregation result to this group.- Parameters:
result
- the result to add- Returns:
- this, to allow chaining
-
addOrderBy
public Group addOrderBy(ExpressionNode exp, boolean asc)
Adds an order-by expression to this group. If the expression is an AggregationResult, it will be added to the list of this group's AggregationResults, and a reference to that expression is added instead. If the AggregationResult is already present, a reference to THAT result is created instead.- Parameters:
exp
- the result to addasc
- true to sort ascending, false to sort descending- Returns:
- this, to allow chaining
-
getOrderByExpressions
public List<ExpressionNode> getOrderByExpressions()
-
onGetClassId
protected int onGetClassId()
- Overrides:
onGetClassId
in classcom.yahoo.vespa.objects.Identifiable
-
onSerialize
protected void onSerialize(com.yahoo.vespa.objects.Serializer buf)
- Overrides:
onSerialize
in classcom.yahoo.vespa.objects.Identifiable
-
onDeserialize
protected void onDeserialize(com.yahoo.vespa.objects.Deserializer buf)
- Overrides:
onDeserialize
in classcom.yahoo.vespa.objects.Identifiable
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classcom.yahoo.vespa.objects.Identifiable
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classcom.yahoo.vespa.objects.Identifiable
-
clone
public Group clone()
- Overrides:
clone
in classcom.yahoo.vespa.objects.Identifiable
-
visitMembers
public void visitMembers(com.yahoo.vespa.objects.ObjectVisitor visitor)
- Overrides:
visitMembers
in classcom.yahoo.vespa.objects.Identifiable
-
selectMembers
public void selectMembers(com.yahoo.vespa.objects.ObjectPredicate predicate, com.yahoo.vespa.objects.ObjectOperation operation)
- Overrides:
selectMembers
in classcom.yahoo.vespa.objects.Selectable
-
-