@Override
  public void close() {

    // No row was processed
    if (oc == null) {
      LOG.trace("Close called without any rows processed");
    }

    try {
      if (groupKey != null) {
        // If a operator wants to do some work at the end of a group
        LOG.trace("End Group");
        reducer.endGroup();
      }

      reducer.close(abort);
      ReportStats rps = new ReportStats(rp, jc);
      reducer.preorderMap(rps);

    } catch (Exception e) {
      if (!abort) {
        // signal new failure to map-reduce
        LOG.error("Hit error while closing operators - failing tree");
        throw new RuntimeException("Hive Runtime Error while closing operators: "
            + e.getMessage(), e);
      }
    } finally {
      MapredContext.close();
      Utilities.clearWorkMap(jc);
    }
  }
ExecReducer is the generic Reducer class for Hive. Together with ExecMapper it is
the bridge between the map-reduce framework and the Hive operator pipeline at
execution time. It's main responsibilities are:

- Load and setup the operator pipeline from XML
- Run the pipeline by transforming key, value pairs to records and forwarding them to the operators
- Sending start and end group messages to separate records with same key from one another
- Catch and handle errors during execution of the operators.
ql/src/java/org/apache/hadoop/hive/ql/exec/mr/ExecReducer.java