Java8进行多个字段分组统计实现
标签:records count col 实现 map type collect tin ring
// 分组统计
Map countMap = records.stream().collect(Collectors.groupingBy(o -> o.getProductType() + "_" + o.getCountry(), Collectors.counting()));
List countRecords = countMap.keySet().stream().map(key -> {
String[] temp = key.split("_");
String productType = temp[0];
String country = temp[1];
Record record = new Record();
record.set("device_type", productType);
record.set("location", country;
record.set("count", countMap.get(key).intValue());
return record;
}).collect(Collectors.toList());
Java8进行多个字段分组统计实现
标签:records count col 实现 map type collect tin ring
原文地址:https://www.cnblogs.com/30go/p/12853891.html
评论