public static <T> List<T> averageAssign(List<T> source, int pageSize, int index) {

        if (source == null || source.isEmpty()) {
            return source;
        }

        int remainder = source.size() % pageSize;
        int number = source.size() / pageSize;
        int fromIndex = index * number;

        fromIndex += Math.min(index, remainder);
        boolean hasRemainder = index < remainder;
        int toIndex = fromIndex + number + (hasRemainder ? 1 : 0);

        if (fromIndex >= source.size()) {
            return new ArrayList<>();
        }

        if (toIndex > source.size()) {
            toIndex = source.size();
        }

        return source.subList(fromIndex, toIndex);
    }
group a batch of source, and get the part of given index.

@param  source   source to be grouped
@param  pageSize size of group
@param  index    current index
inlong-sort-standalone/sort-standalone-source/src/main/java/org/apache/inlong/sort/standalone/sink/kafka/PartitionerSelector.java