public static List<Record> aggregateRecords(List<Record> records, Field groupBy) {
    return records.stream().collect(Collectors.groupingBy(r -> r.get(groupBy))).entrySet().stream()
      .flatMap(
        e -> e.getValue().stream().reduce(Record::combine).map(Stream::of).orElse(Stream.empty()))
      .collect(Collectors.toList());
  }
Group by records on the basis of supplied groupBy field and Aggregate records using
{@link Record#combine(Record)}
@param records records needs to be processed
@param groupBy Field to be used for group by
@return aggregated records
hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/mode/ModeStrategyUtils.java