I am trying to group my stream and aggregate on several fields
i.e.
private class Row {
private String sku;
private int colA; // sum
private int colB; // sum
private int colC; // avg
}
Example
sku colA colB colC
---------------------------
ar5sg5h 4 3 4
sd6ad6d 2 5 3
ar5sg5h 6 5 6
sd6ad6d 5 6 3
sd6ad6d 3 7 3
Expected:
sku colA colB colC
---------------------------
ar5sg5h 10 8 5.0
sd6ad6d 10 18 3.0
I already have List<Row> rows, where I have intention to reduce rows with groupBy and aggregation of sum on colA and colB where as average on colC.
How can I achieve this with groupBy + multiple aggregation using Java-8 stream?