private boolean checkForSourceCompletion(String name) {
    int expectedEvents = numExpectedEventsPerSource.get(name).getValue();
    if (expectedEvents < 0) {
      // Expected events not updated yet - vertex SUCCESS notification not received.
      return false;
    }

    int processedEvents = numEventsSeenPerSource.get(name).getValue();
    if (processedEvents == expectedEvents) {
      sourcesWaitingForEvents.remove(name);
      if (sourcesWaitingForEvents.isEmpty()) {
        return true;
      } else {
        LOG.info("Waiting for {} sources.", sourcesWaitingForEvents.size());
        return false;
      }
    } else if (processedEvents > expectedEvents) {
      throw new IllegalStateException(
          "Received too many events for " + name + ", Expected=" + expectedEvents +
              ", Received=" + processedEvents);
    }
    return false;
  }
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