* @return the sort controller
*/
private ScanController loadSorter()
throws StandardException
{
SortController sorter;
ExecRow sourceRow;
ExecIndexRow sortTemplateRow = getRowTemplate();
int inputRowCountEstimate = (int) optimizerEstimatedRowCount;
TransactionController tc = getTransactionController();
/*
** We have a distinct aggregate so, we'll need
** to do a sort. We use all of the sorting columns and
** drop the aggregation on the distinct column. Then
** we'll feed this into the sorter again w/o the distinct
** column in the ordering list.
*/
GenericAggregator[] aggsNoDistinct = getSortAggregators(aggInfoList, true,
activation.getLanguageConnectionContext(), source);
SortObserver sortObserver = new AggregateSortObserver(true, aggsNoDistinct, aggregates,
sortTemplateRow);
sortId = tc.createSort((Properties)null,
sortTemplateRow.getRowArray(),
order,
sortObserver,
false, // not in order
inputRowCountEstimate, // est rows, -1 means no idea
maxRowSize // est rowsize
);
sorter = tc.openSort(sortId);
dropDistinctAggSort = true;
while ((sourceRow = source.getNextRowCore())!=null)
{
sorter.insert(sourceRow.getRowArray());
rowsInput++;
}
/*
** End the sort and open up the result set
*/
sorter.completedInserts();
scanController =
tc.openSortScan(sortId, activation.getResultSetHoldability());
/*