{
nextTime += getElapsedMillis(beginTime);
return null;
}
ExecIndexRow nextRow = getNextRowFromRS();
/* Drain and merge rows until we find new distinct values for the grouping columns. */
while (nextRow != null)
{
/* We found a new set of values for the grouping columns.
* Update the current row and return this group.
*/
if (! sameGroupingValues(currSortedRow, nextRow))
{
ExecIndexRow result = currSortedRow;
/* Save a clone of the new row so that it doesn't get overwritten */
currSortedRow = (ExecIndexRow) nextRow.getClone();
initializeVectorAggregation(currSortedRow);
nextTime += getElapsedMillis(beginTime);
rowsReturned++;
return finishAggregation(result);
}
else
{
/* Same group - initialize the new row and then merge the aggregates */
initializeVectorAggregation(nextRow);
mergeVectorAggregates(nextRow, currSortedRow);
}
// Get the next row
nextRow = getNextRowFromRS();
}
// We've drained the source, so no more rows to return
ExecIndexRow result = currSortedRow;
currSortedRow = null;
nextTime += getElapsedMillis(beginTime);
return finishAggregation(result);
}
else
{
ExecIndexRow sortResult = null;
if ((sortResult = getNextRowFromRS()) != null)
{
setCurrentRow(sortResult);
}