public static void limitNumReduceTasks(String table, Job job) throws IOException {
    int regions = getRegionCount(job.getConfiguration(), TableName.valueOf(table));
    if (job.getNumReduceTasks() > regions) {
      job.setNumReduceTasks(regions);
    }
  }
Ensures that the given number of reduce tasks for the given job configuration does not exceed
the number of regions for the given table.
@param table The table to get the region count for.
@param job   The current job to adjust.
@throws IOException When retrieving the table details fails.
hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/TableMapReduceUtil.java