protected static void updateCounters(ScanMetrics scanMetrics, long numScannerRestarts,
    TaskAttemptContext context, long numStale) {
    // we can get access to counters only if hbase uses new mapreduce APIs
    if (context == null) {
      return;
    }

    for (Map.Entry<String, Long> entry : scanMetrics.getMetricsMap().entrySet()) {
      Counter counter = context.getCounter(HBASE_COUNTER_GROUP_NAME, entry.getKey());
      if (counter != null) {
        counter.increment(entry.getValue());
      }
    }
    if (numScannerRestarts != 0L) {
      Counter counter = context.getCounter(HBASE_COUNTER_GROUP_NAME, "NUM_SCANNER_RESTARTS");
      if (counter != null) {
        counter.increment(numScannerRestarts);
      }
    }
    if (numStale != 0L) {
      Counter counter = context.getCounter(HBASE_COUNTER_GROUP_NAME, "NUM_SCAN_RESULTS_STALE");
      if (counter != null) {
        counter.increment(numStale);
      }
    }
  }
@deprecated since 2.4.0 and 2.3.2, will be removed in 4.0.0 Use
            {@link #updateCounters(ScanMetrics, long, TaskAttemptContext, long)} instead.
hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/TableRecordReaderImpl.java