* @return the sort controller
*/
private ScanController loadSorter()
throws StandardException
{
SortController sorter;
long sortId;
ExecRow sourceRow;
ExecRow inputRow;
boolean inOrder = (order.length == 0 || isInSortedOrder);
int inputRowCountEstimate = (int) optimizerEstimatedRowCount;
// find the language context and
// Get the current transaction controller
TransactionController tc = getTransactionController();
sortId = tc.createSort((Properties)null,
sortTemplateRow.getRowArray(),
order,
observer,
inOrder,
inputRowCountEstimate, // est rows
maxRowSize // est rowsize
);
sorter = tc.openSort(sortId);
genericSortId = sortId;
dropGenericSort = true;
/* The sorter is responsible for doing the cloning */
while ((inputRow = getNextRowFromRS()) != null)
{
/* The sorter is responsible for doing the cloning */
sorter.insert(inputRow.getRowArray());
}
source.close();
sortProperties = sorter.getSortInfo().getAllSortInfo(sortProperties);
sorter.completedInserts();
return tc.openSortScan(sortId, activation.getResultSetHoldability());
}