@Override
    @SuppressWarnings({"unchecked"})
    public int partition(T record, byte[] key, byte[] value, String targetTopic, int[] partitions) {
        Preconditions.checkArgument(
                partitions != null && partitions.length > 0,
                "Partitions of the target topic is empty.");
        int partition = 0;
        try {
            String partitionKey;
            if (PRIMARY_KEY.equals(partitionPattern)) {
                List<String> values = dynamicSchemaFormat.extractPrimaryKeyValues(value);
                if (values == null || values.isEmpty()) {
                    return partition;
                }
                partitionKey = StringUtils.join(values, "");
            } else {
                partitionKey = dynamicSchemaFormat.parse(value, partitionPattern);
            }
            if (datasourceAndPartitionMap != null && datasourceAndPartitionMap.containsKey(partitionKey)) {
                partition = Integer.parseInt(datasourceAndPartitionMap.getOrDefault(partitionKey, "0"));
            } else {
                partition = partitions[(partitionKey.hashCode() & Integer.MAX_VALUE) % partitions.length];
            }
        } catch (Exception e) {
            LOG.warn("Extract partition failed", e);
        }
        return partition;
    }
The format used to deserialization the raw data(bytes array)
inlong-sort/sort-flink/sort-flink-v1.13/sort-connectors/kafka/src/main/java/org/apache/inlong/sort/kafka/partitioner/RawDataHashPartitioner.java