Class Group

  • All Implemented Interfaces:
    java.lang.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​(java.lang.Object obj)  
      java.util.List<AggregationResult> getAggregationResults()
      Returns this group's aggregation results.
      java.util.List<Group> getChildren()
      Returns the list of child groups to this.
      ResultNode getId()
      Returns the label to use for this group.
      java.util.List<ExpressionNode> getOrderByExpressions()  
      java.util.List<java.lang.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​(java.util.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)  
      • Methods inherited from class com.yahoo.vespa.objects.Identifiable

        create, createFromId, deserialize, deserializeOptional, deserializeWithId, equals, getClassId, getUtf8, putUtf8, registerClass, serialize, serializeOptional, serializeWithId, toString
      • Methods inherited from class com.yahoo.vespa.objects.Selectable

        select, select
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • 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​(java.util.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 java.util.List<Group> getChildren()

        Returns the list of child groups to this.

        Returns:
        The children.
      • 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.

        Returns:
        The numerical tag.
      • 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 java.util.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 java.util.List<java.lang.Integer> getOrderByIndexes()
      • getOrderByExpressions

        public java.util.List<ExpressionNode> getOrderByExpressions()
      • 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​(java.lang.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