Class SelectGroups

java.lang.Object
org.h2.command.query.SelectGroups

public abstract class SelectGroups extends Object
Grouped data for aggregates.

Call sequence:

Call sequence for lazy group sorted result:

  • resetLazy() (not required before the first execution).
  • For each source group nextLazyGroup() should be invoked.
  • For each source row nextLazyRow() should be invoked. Each group can have one or more rows.
  • Method Details

    • getInstance

      public static SelectGroups getInstance(SessionLocal session, ArrayList<Expression> expressions, boolean isGroupQuery, int[] groupIndex)
      Creates new instance of grouped data.
      Parameters:
      session - the session
      expressions - the expressions
      isGroupQuery - is this query is a group query
      groupIndex - the indexes of group expressions, or null
      Returns:
      new instance of the grouped data.
    • isCurrentGroup

      public boolean isCurrentGroup()
      Is there currently a group-by active.
      Returns:
      true if there is currently a group-by active, otherwise returns false.
    • getCurrentGroupExprData

      public final Object getCurrentGroupExprData(Expression expr)
      Get the group-by data for the current group and the passed in expression.
      Parameters:
      expr - expression
      Returns:
      expression data or null
    • setCurrentGroupExprData

      public final void setCurrentGroupExprData(Expression expr, Object obj)
      Set the group-by data for the current group and the passed in expression.
      Parameters:
      expr - expression
      obj - expression data to set
    • getWindowExprData

      public final PartitionData getWindowExprData(DataAnalysisOperation expr, Value partitionKey)
      Get the window data for the specified expression.
      Parameters:
      expr - expression
      partitionKey - a key of partition
      Returns:
      expression data or null
    • setWindowExprData

      public final void setWindowExprData(DataAnalysisOperation expr, Value partitionKey, PartitionData obj)
      Set the window data for the specified expression.
      Parameters:
      expr - expression
      partitionKey - a key of partition
      obj - window expression data to set
    • getCurrentGroupRowId

      public int getCurrentGroupRowId()
      Returns identity of the current row. Used by aggregates to check whether they already processed this row or not.
      Returns:
      identity of the current row
    • reset

      public void reset()
      Resets this group data for reuse.
    • nextSource

      public abstract void nextSource()
      Invoked for each source row to evaluate group key and setup all necessary data for aggregates.
    • done

      public void done()
      Invoked after all source rows are evaluated.
    • next

      public abstract ValueRow next()
      Returns the key of the next group.
      Returns:
      the key of the next group, or null
    • remove

      public void remove()
      Removes the data for the current key.
      See Also:
    • resetLazy

      public void resetLazy()
      Resets this group data for reuse in lazy mode.
    • nextLazyGroup

      public void nextLazyGroup()
      Moves group data to the next group in lazy mode.
    • nextLazyRow

      public void nextLazyRow()
      Moves group data to the next row in lazy mode.