private byte[] serialize(int groupId) {
    boolean xNull = xNulls.get(groupId);
    int yLength = calculateValueLength(groupId, yDataType, false);
    int length = yLength + 1 + (xNull ? 0 : calculateValueLength(groupId, xDataType, true));
    byte[] bytes = new byte[length];

    writeIntermediate(groupId, false, yDataType, bytes, 0);
    boolToBytes(xNull, bytes, yLength);
    if (!xNull) {
      writeIntermediate(groupId, true, xDataType, bytes, yLength + 1);
    }

    return bytes;
  }
max(x,y) returns the value of x associated with the maximum value of y over all input values.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/GroupedMaxMinByBaseAccumulator.java