public static RowData decorateRowWithNeededHeadFields(
            @Nullable String timeFieldName,
            @Nullable String attributesFieldName,
            Timestamp time,
            Map<String, String> attributes,
            GenericRowData dataRow) {
        List<Object> headFields = new ArrayList<>();
        if (timeFieldName != null) {
            headFields.add(TIME_FIELD_CONVERTER.convert(time));
        }

        if (attributesFieldName != null) {
            headFields.add(ATTRIBUTES_FIELD_CONVERTER.convert(attributes));
        }

        GenericRowData rowData = new GenericRowData(headFields.size() + dataRow.getArity());
        for (int i = 0; i < headFields.size(); ++i) {
            rowData.setField(i, headFields.get(i));
        }

        for (int i = 0; i < dataRow.getArity(); ++i) {
            rowData.setField(i + headFields.size(), dataRow.getField(i));
        }

        return rowData;
    }
Creates the row with the given head fields and data row.

@param timeFieldName       The name of the time field. Null if the time field is not required.
@param attributesFieldName The name of the attributes field. Null if the attributes field is
                           not required.
@param time                The time of the inLongMsg.
@param attributes          The attributes of the inLongMsg.
@param dataRow             The data row.
@return The row decorated with head fields.
inlong-sort/sort-formats/format-rowdata/format-inlongmsg-rowdata-base/src/main/java/org/apache/inlong/sort/formats/inlongmsg/InLongMsgUtils.java