MethodBuilder mb)
throws StandardException
{
int orderingItem = 0;
int aggInfoItem = 0;
FormatableArrayHolder orderingHolder;
/* Get the next ResultSet#, so we can number this ResultSetNode, its
* ResultColumnList and ResultSet.
*/
assignResultSetNumber();
// Get the final cost estimate from the child.
costEstimate = childResult.getFinalCostEstimate();
/*
** Get the column ordering for the sort. Note that
** for a scalar aggegate we may not have any ordering
** columns (if there are no distinct aggregates).
** WARNING: if a distinct aggregate is passed to
** SortResultSet it assumes that the last column
** is the distinct one. If this assumption changes
** then SortResultSet will have to change.
*/
orderingHolder = acb.getColumnOrdering(groupingList);
if (addDistinctAggregate)
{
orderingHolder = acb.addColumnToOrdering(
orderingHolder,
addDistinctAggregateColumnNum);
}
if (SanityManager.DEBUG)
{
if (SanityManager.DEBUG_ON("AggregateTrace"))
{
StringBuffer s = new StringBuffer();
s.append("Group by column ordering is (");
ColumnOrdering[] ordering =
(ColumnOrdering[])orderingHolder.getArray(ColumnOrdering.class);
for (int i = 0; i < ordering.length; i++)
{
s.append(ordering[i].getColumnId());
s.append(" ");