protected void appendGroupKeysToResult(List<DeviceEntry> deviceEntries, int deviceIndex) {
    ColumnBuilder[] columnBuilders = resultTsBlockBuilder.getValueColumnBuilders();
    for (int i = 0; i < groupingKeySize; i++) {
      if (TsTableColumnCategory.TAG == groupingKeySchemas.get(i).getColumnCategory()) {
        String id = getNthIdColumnValue(deviceEntries.get(deviceIndex), groupingKeyIndex[i]);
        if (id == null) {
          columnBuilders[i].appendNull();
        } else {
          columnBuilders[i].writeBinary(new Binary(id, TSFileConfig.STRING_CHARSET));
        }
      } else {
        Binary attribute =
            deviceEntries.get(deviceIndex).getAttributeColumnValues()[groupingKeyIndex[i]];
        if (attribute == null) {
          columnBuilders[i].appendNull();
        } else {
          columnBuilders[i].writeBinary(attribute);
        }
      }
    }
  }
Append a row of aggregation results to the result tsBlock.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/AbstractAggTableScanOperator.java