Class GroupedAggregateResultSet

All Implemented Interfaces:
CursorResultSet, NoPutResultSet, ResultSet, RowLocationRetRowSource, RowSource
Direct Known Subclasses:
DistinctGroupedAggregateResultSet

class GroupedAggregateResultSet extends GenericAggregateResultSet implements CursorResultSet
This ResultSet evaluates grouped, non distinct aggregates. It will scan the entire source result set and calculate the grouped aggregates when scanning the source during the first call to next(). The implementation is capable of computing multiple levels of grouping in a single result set (this is requested using GROUP BY ROLLUP). This implementation has 3 variations, which it chooses according to the following rules: - If the data are guaranteed to arrive already in sorted order, we make a single pass over the data, computing the aggregates in-line as the data are read. - If the statement requests either multiple ROLLUP levels, or a DISTINCT grouping, then the data are first sorted, then we make a single pass over the data as above. - Otherwise, the data are sorted, and a SortObserver is used to compute the aggregations inside the sort, and the results are read back directly from the sorter. Note that, as of the introduction of the ROLLUP support, we no longer ALWAYS compute the aggregates using a SortObserver, which is an arrangement by which the sorter calls back into the aggregates during the sort process each time it consolidates two rows with the same sort key. Using aggregate sort observers is an efficient technique, but it was complex to extend it to the ROLLUP case, so to simplify the code we just have one path for both already-sorted and un-sorted data sources in the ROLLUP case.
  • Field Details

    • rowsInput

      public int rowsInput
    • rowsReturned

      public int rowsReturned
    • order

      private ColumnOrdering[] order
    • hasDistinctAggregate

      public boolean hasDistinctAggregate
    • isInSortedOrder

      public boolean isInSortedOrder
    • numDistinctAggs

      private int numDistinctAggs
    • maxRowSize

      private int maxRowSize
    • scanController

      private ScanController scanController
    • sourceExecIndexRow

      private ExecIndexRow sourceExecIndexRow
    • sortResultRow

      private ExecIndexRow sortResultRow
    • resultsComplete

      private boolean resultsComplete
    • finishedResults

      private List<ExecRow> finishedResults
    • resultRows

      private ExecIndexRow[] resultRows
    • distinctValues

      private List<List<Set<DataValueDescriptor>>> distinctValues
    • rollup

      private boolean rollup
    • usingAggregateObserver

      private boolean usingAggregateObserver
    • genericSortId

      private long genericSortId
    • tc

    • sortProperties

      public Properties sortProperties
  • Constructor Details

    • GroupedAggregateResultSet

      GroupedAggregateResultSet(NoPutResultSet s, boolean isInSortedOrder, int aggregateItem, int orderingItem, Activation a, int ra, int maxRowSize, int resultSetNumber, double optimizerEstimatedRowCount, double optimizerEstimatedCost, boolean isRollup) throws StandardException
      Constructor
      Parameters:
      s - input result set
      isInSortedOrder - true if the source results are in sorted order
      aggregateItem - indicates the number of the SavedObject off of the PreparedStatement that holds the AggregatorInfoList used by this routine.
      orderingItem - indicates the number of the SavedObject off of the PreparedStatement that holds the ColumOrdering array used by this routine
      a - activation
      ra - saved object that builds an empty output row
      maxRowSize - approx row size, passed to sorter
      resultSetNumber - The resultSetNumber for this result set
      Throws:
      StandardException - Thrown on error
  • Method Details