Class Group

  • All Implemented Interfaces:
    Cloneable

    public class Group
    extends com.yahoo.vespa.objects.Identifiable
    • Field Detail

      • classId

        public static final int classId
    • Constructor Detail

      • Group

        public Group()
    • 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 call postMerge(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.
      • setId

        public Group setId​(ResultNode id)
        Sets the label to use for this group. This is a ResultNode 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.
      • getChildren

        public List<Group> 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

        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 add
        asc - true to sort ascending, false to sort descending
        Returns:
        this, to allow chaining
      • getOrderByIndexes

        public List<Integer> getOrderByIndexes()
      • onGetClassId

        protected int onGetClassId()
        Overrides:
        onGetClassId in class com.yahoo.vespa.objects.Identifiable
      • onSerialize

        protected void onSerialize​(com.yahoo.vespa.objects.Serializer buf)
        Overrides:
        onSerialize in class com.yahoo.vespa.objects.Identifiable
      • onDeserialize

        protected void onDeserialize​(com.yahoo.vespa.objects.Deserializer buf)
        Overrides:
        onDeserialize in class com.yahoo.vespa.objects.Identifiable
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class com.yahoo.vespa.objects.Identifiable
      • equals

        public boolean equals​(Object obj)
        Overrides:
        equals in class com.yahoo.vespa.objects.Identifiable
      • clone

        public Group clone()
        Overrides:
        clone in class com.yahoo.vespa.objects.Identifiable
      • visitMembers

        public void visitMembers​(com.yahoo.vespa.objects.ObjectVisitor visitor)
        Overrides:
        visitMembers in class com.yahoo.vespa.objects.Identifiable
      • selectMembers

        public void selectMembers​(com.yahoo.vespa.objects.ObjectPredicate predicate,
                                  com.yahoo.vespa.objects.ObjectOperation operation)
        Overrides:
        selectMembers in class com.yahoo.vespa.objects.Selectable