private void calculateFinishCondition(String sourceName) {
    // Get a deterministic count of number of tasks for the vertex.
    MutableInt prevVal = numExpectedEventsPerSource.get(sourceName);
    int prevValInt = prevVal.intValue();
    Preconditions.checkState(prevValInt < 0,
        "Invalid value for numExpectedEvents for source: " + sourceName + ", oldVal=" + prevValInt);
    prevVal.setValue((-1) * prevValInt * context.getVertexNumTasks(sourceName));
  }
DynamicPartitionPruner takes a list of assigned partitions at runtime (split
generation) and prunes them using events generated during execution of the
dag.
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/DynamicPartitionPruner.java