Это происходит в несколько шагов. Клавиши сопоставляются с группами клавиш, а группы клавиш назначаются слотам. Вы найдете весь соответствующий код в org.apache.flink.runtime.state.KeyGroupRangeAssignment
. Начать здесь:
/**
* Assigns the given key to a parallel operator index.
*
* @param key the key to assign
* @param maxParallelism the maximum supported parallelism, aka the number of key-groups.
* @param parallelism the current parallelism of the operator
* @return the index of the parallel operator to which the given key should be routed.
*/
public static int assignKeyToParallelOperator(Object key, int maxParallelism, int parallelism) {
Preconditions.checkNotNull(key, "Assigned key must not be null!");
return computeOperatorIndexForKeyGroup(
maxParallelism, parallelism, assignToKeyGroup(key, maxParallelism));
}