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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds an aggregation result to this group.Adds a child group to this.addOrderBy
(ExpressionNode exp, boolean asc) Adds an order-by expression to this group.clone()
boolean
Returns this group's aggregation results.Returns the list of child groups to this.getId()
Returns the label to use for this group.double
getRank()
Return the rank score of this group.int
getTag()
Returns the tag of this group.int
hashCode()
boolean
This tells you if the children are ranked by the pure relevance or by a more complex expression.void
Merges the content of the given group into this.protected void
onDeserialize
(com.yahoo.vespa.objects.Deserializer buf) protected int
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) setId
(ResultNode id) Sets the label to use for this group.setRank
(double rank) Sets the relevancy to use for this group.setTag
(int tag) Assigns a tag to this group.void
Sorts the children by their id, if they are not sorted already.void
Sorts the children by their rank, if they are not sorted already.void
visitMembers
(com.yahoo.vespa.objects.ObjectVisitor visitor) Methods inherited from class com.yahoo.vespa.objects.Identifiable
create, createFromId, deserialize, deserializeOptional, deserializeWithId, equals, getClassId, getRawUtf8Bytes, getUtf8, putUtf8, registerClass, serialize, serializeOptional, serializeWithId, toString
Methods inherited from class com.yahoo.vespa.objects.Selectable
select, select
-
Field Details
-
classId
public static final int classId
-
-
Constructor Details
-
Group
public Group()
-
-
Method Details
-
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
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
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
Returns the label to use for this group. See comment onsetId(com.yahoo.searchlib.expression.ResultNode)
on the rationale of this being aResultNode
. -
setId
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
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
Adds a child group to this.- Parameters:
child
- The group to add.- Returns:
- This, to allow chaining.
-
getChildren
Returns the list of child groups to this. -
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
Assigns a tag to this group.- Parameters:
tag
- the numerical tag to set- Returns:
- this, to allow chaining
-
getAggregationResults
Returns this group's aggregation results.- Returns:
- the aggregation results
-
addAggregationResult
Adds an aggregation result to this group.- Parameters:
result
- the result to add- Returns:
- this, to allow chaining
-
addOrderBy
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
-
getOrderByIndexes
-
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
- Overrides:
equals
in classcom.yahoo.vespa.objects.Identifiable
-
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
-