Source:
<code>private void setSQLGroupByInAggregationResults(BrokerResponseNative brokerResponseNative, DataSchema dataSchema, Collection<DataTable> dataTables, DataTableReducerContext reducerContext) { List<String> groupByColumns = new ArrayList<>(_numGroupByExpressions); <START> int idx = 0; <END> while (idx < _numGroupByExpressions) { groupByColumns.add(dataSchema.getColumnName(idx)); idx++; } List<String> aggregationColumns = new ArrayList<>(_numAggregationFunctions); List<List<GroupByResult>> groupByResults = new ArrayList<>(_numAggregationFunctions); while (idx < _numColumns) { aggregationColumns.add(dataSchema.getColumnName(idx)); groupByResults.add(new ArrayList<>()); idx++; } if (!dataTables.isEmpty()) { IndexedTable indexedTable = getIndexedTable(dataSchema, dataTables, reducerContext); int limit = _queryContext.getLimit(); Iterator<Record> sortedIterator = indexedTable.iterator(); int numRows = 0; while (numRows < limit && sortedIterator.hasNext()) { Record nextRecord = sortedIterator.next(); Object[] values = nextRecord.getValues(); int index = 0; List<String> group = new ArrayList<>(_numGroupByExpressions); while (index < _numGroupByExpressions) { group.add(values[index].toString()); index++; } int aggNum = 0; while (index < _numColumns) { Serializable serializableValue = getSerializableValue(_aggregationFunctions[aggNum].extractFinalResult(values[index])); if (!_preserveType) { serializableValue = AggregationFunctionUtils.formatValue(serializableValue); } GroupByResult groupByResult = new GroupByResult(); groupByResult.setGroup(group); groupByResult.setValue(serializableValue); groupByResults.get(aggNum).add(groupByResult); index++; aggNum++; } numRows++; } } List<AggregationResult> aggregationResults = new ArrayList<>(_numAggregationFunctions); for (int i = 0; i < _numAggregationFunctions; i++) { AggregationResult aggregationResult = new AggregationResult(groupByResults.get(i), groupByColumns, aggregationColumns.get(i)); aggregationResults.add(aggregationResult); } brokerResponseNative.setAggregationResults(aggregationResults); }</code><technical_language>Return 1? need thread</technical_language>

Target:
private void setSQLGroupByInAggregationResults(BrokerResponseNative brokerResponseNative, DataSchema dataSchema, Collection<DataTable> dataTables, DataTableReducerContext reducerContext) throws TimeoutException { List<String> groupByColumns = new ArrayList<>(_numGroupByExpressions); int idx = 0; while (idx < _numGroupByExpressions) { groupByColumns.add(dataSchema.getColumnName(idx)); idx++; } List<String> aggregationColumns = new ArrayList<>(_numAggregationFunctions); List<List<GroupByResult>> groupByResults = new ArrayList<>(_numAggregationFunctions); while (idx < _numColumns) { aggregationColumns.add(dataSchema.getColumnName(idx)); groupByResults.add(new ArrayList<>()); idx++; } if (!dataTables.isEmpty()) { IndexedTable indexedTable = getIndexedTable(dataSchema, dataTables, reducerContext); int limit = _queryContext.getLimit(); Iterator<Record> sortedIterator = indexedTable.iterator(); int numRows = 0; while (numRows < limit && sortedIterator.hasNext()) { Record nextRecord = sortedIterator.next(); Object[] values = nextRecord.getValues(); int index = 0; List<String> group = new ArrayList<>(_numGroupByExpressions); while (index < _numGroupByExpressions) { group.add(values[index].toString()); index++; } int aggNum = 0; while (index < _numColumns) { Serializable serializableValue = getSerializableValue(_aggregationFunctions[aggNum].extractFinalResult(values[index])); if (!_preserveType) { serializableValue = AggregationFunctionUtils.formatValue(serializableValue); } GroupByResult groupByResult = new GroupByResult(); groupByResult.setGroup(group); groupByResult.setValue(serializableValue); groupByResults.get(aggNum).add(groupByResult); index++; aggNum++; } numRows++; } } List<AggregationResult> aggregationResults = new ArrayList<>(_numAggregationFunctions); for (int i = 0; i < _numAggregationFunctions; i++) { AggregationResult aggregationResult = new AggregationResult(groupByResults.get(i), groupByColumns, aggregationColumns.get(i)); aggregationResults.add(aggregationResult); } brokerResponseNative.setAggregationResults(aggregationResults); }