use of io.shardingjdbc.core.merger.dql.groupby.aggregation.AggregationUnit in project sharding-jdbc by shardingjdbc.
the class GroupByStreamMergedResult method aggregate.
private void aggregate(final Map<AggregationSelectItem, AggregationUnit> aggregationUnitMap) throws SQLException {
for (Entry<AggregationSelectItem, AggregationUnit> entry : aggregationUnitMap.entrySet()) {
List<Comparable<?>> values = new ArrayList<>(2);
if (entry.getKey().getDerivedAggregationSelectItems().isEmpty()) {
values.add(getAggregationValue(entry.getKey()));
} else {
for (AggregationSelectItem each : entry.getKey().getDerivedAggregationSelectItems()) {
values.add(getAggregationValue(each));
}
}
entry.getValue().merge(values);
}
}
use of io.shardingjdbc.core.merger.dql.groupby.aggregation.AggregationUnit in project sharding-jdbc by shardingjdbc.
the class GroupByMemoryMergedResult method initForFirstGroupByValue.
private void initForFirstGroupByValue(final QueryResult queryResult, final GroupByValue groupByValue, final Map<GroupByValue, MemoryQueryResultRow> dataMap, final Map<GroupByValue, Map<AggregationSelectItem, AggregationUnit>> aggregationMap) throws SQLException {
if (!dataMap.containsKey(groupByValue)) {
dataMap.put(groupByValue, new MemoryQueryResultRow(queryResult));
}
if (!aggregationMap.containsKey(groupByValue)) {
Map<AggregationSelectItem, AggregationUnit> map = Maps.toMap(selectStatement.getAggregationSelectItems(), new Function<AggregationSelectItem, AggregationUnit>() {
@Override
public AggregationUnit apply(final AggregationSelectItem input) {
return AggregationUnitFactory.create(input.getType());
}
});
aggregationMap.put(groupByValue, map);
}
}
Aggregations