private int[] calculateTaskCountPerContainer(int taskCount, int prevContainerCount, int currentContainerCount) {
    int[] newTaskCountPerContainer = new int[Math.max(currentContainerCount, prevContainerCount)];
    Arrays.fill(newTaskCountPerContainer, 0);

    for (int i = 0; i < currentContainerCount; i++) {
      newTaskCountPerContainer[i] = taskCount / currentContainerCount;
      if (taskCount % currentContainerCount > i) {
        newTaskCountPerContainer[i]++;
      }
    }
    return newTaskCountPerContainer;
  }
Calculates the expected number of tasks for each container. The count is generated for
max(oldContainerCount, newContainerCount) s.t. if the container count has decreased,
the excess containers will have a count == 0, indicating that any tasks assigned to
them should be reassigned.

@param taskCount             the number of tasks to divide among the containers.
@param prevContainerCount    the previous number of containers.
@param currentContainerCount the current number of containers.
@return                      the expected number of tasks for each container.
samza-core/src/main/java/org/apache/samza/container/grouper/task/GroupByContainerCount.java