List<Record> selectModeFieldsAndAddCountField(List<FieldInfo> fieldInfos, List<Record> records,
    Field countField) {

    return records.stream().map(
      record -> Record.ofEntries(fieldInfos.stream().filter(fi -> record.containsKey(fi.getField()))
        .map(fi -> Record.entry(fi.getField(), record.get(fi.getField())))))
      .map(record -> Record.builder().putAll(record).put(countField, 1).build())
      .collect(Collectors.toList());
  }
Form new record list with records formed by only fields provided through fieldInfo and add a
count field for each record with value 1 We are doing two operation of selecting and adding new
field because of saving some CPU cycles on rebuilding the record again
@param fieldInfos List of FieldInfos required in the record
@param records    List of records which needs to be processed
@param countField Field which needs to be added with value 1 for each record
@return records after selecting required fields and adding count field
hbase-hbtop/src/main/java/org/apache/hadoop/hbase/hbtop/mode/RegionModeStrategy.java