当前位置: 首页>>代码示例>>Java>>正文


Java Counter.increment方法代码示例

本文整理汇总了Java中org.apache.hadoop.mapreduce.Counter.increment方法的典型用法代码示例。如果您正苦于以下问题:Java Counter.increment方法的具体用法?Java Counter.increment怎么用?Java Counter.increment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.mapreduce.Counter的用法示例。


在下文中一共展示了Counter.increment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateCounters

import org.apache.hadoop.mapreduce.Counter; //导入方法依赖的package包/类
protected static void updateCounters(ScanMetrics scanMetrics, long numScannerRestarts,
    Method getCounter, TaskAttemptContext context, long numStale) {
  // we can get access to counters only if hbase uses new mapreduce APIs
  if (getCounter == null) {
    return;
  }

  try {
    for (Map.Entry<String, Long> entry:scanMetrics.getMetricsMap().entrySet()) {
      Counter ct = (Counter)getCounter.invoke(context,
          HBASE_COUNTER_GROUP_NAME, entry.getKey());

      ct.increment(entry.getValue());
    }
    ((Counter) getCounter.invoke(context, HBASE_COUNTER_GROUP_NAME,
        "NUM_SCANNER_RESTARTS")).increment(numScannerRestarts);
    ((Counter) getCounter.invoke(context, HBASE_COUNTER_GROUP_NAME,
        "NUM_SCAN_RESULTS_STALE")).increment(numStale);
  } catch (Exception e) {
    LOG.debug("can't update counter." + StringUtils.stringifyException(e));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TableRecordReaderImpl.java

示例2: incrAllCounters

import org.apache.hadoop.mapreduce.Counter; //导入方法依赖的package包/类
@Override
public void incrAllCounters(CounterGroupBase<T> rightGroup) {
  try {
    for (Counter right : rightGroup) {
      Counter left = findCounter(right.getName(), right.getDisplayName());
      left.increment(right.getValue());
    }
  } catch (LimitExceededException e) {
    counters.clear();
    throw e;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:AbstractCounterGroup.java

示例3: map

import org.apache.hadoop.mapreduce.Counter; //导入方法依赖的package包/类
@Override
protected void map(ImmutableBytesWritable key, Result value, Context context)
    throws IOException, InterruptedException {
  byte[] row = value.getRow();
  Counter c = getCounter(row);
  c.increment(1);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:8,代码来源:IntegrationTestWithCellVisibilityLoadAndVerify.java

示例4: parseEscapedCompactString

import org.apache.hadoop.mapreduce.Counter; //导入方法依赖的package包/类
/**
 * Parse a pre 0.21 counters string into a counter object.
 * @param <C> type of the counter
 * @param <G> type of the counter group
 * @param <T> type of the counters object
 * @param compactString to parse
 * @param counters an empty counters object to hold the result
 * @return the counters object holding the result
 * @throws ParseException
 */
@SuppressWarnings("deprecation")
public static <C extends Counter, G extends CounterGroupBase<C>,
               T extends AbstractCounters<C, G>>
T parseEscapedCompactString(String compactString, T counters)
    throws ParseException {
  IntWritable index = new IntWritable(0);

  // Get the group to work on
  String groupString =
    getBlock(compactString, GROUP_OPEN, GROUP_CLOSE, index);

  while (groupString != null) {
    IntWritable groupIndex = new IntWritable(0);

    // Get the actual name
    String groupName =
        StringInterner.weakIntern(getBlock(groupString, UNIT_OPEN, UNIT_CLOSE, groupIndex));
    groupName = StringInterner.weakIntern(unescape(groupName));

    // Get the display name
    String groupDisplayName =
        StringInterner.weakIntern(getBlock(groupString, UNIT_OPEN, UNIT_CLOSE, groupIndex));
    groupDisplayName = StringInterner.weakIntern(unescape(groupDisplayName));

    // Get the counters
    G group = counters.getGroup(groupName);
    group.setDisplayName(groupDisplayName);

    String counterString =
      getBlock(groupString, COUNTER_OPEN, COUNTER_CLOSE, groupIndex);

    while (counterString != null) {
      IntWritable counterIndex = new IntWritable(0);

      // Get the actual name
      String counterName =
          StringInterner.weakIntern(getBlock(counterString, UNIT_OPEN, UNIT_CLOSE, counterIndex));
      counterName = StringInterner.weakIntern(unescape(counterName));

      // Get the display name
      String counterDisplayName =
          StringInterner.weakIntern(getBlock(counterString, UNIT_OPEN, UNIT_CLOSE, counterIndex));
      counterDisplayName = StringInterner.weakIntern(unescape(counterDisplayName));

      // Get the value
      long value =
        Long.parseLong(getBlock(counterString, UNIT_OPEN, UNIT_CLOSE,
                                counterIndex));

      // Add the counter
      Counter counter = group.findCounter(counterName);
      counter.setDisplayName(counterDisplayName);
      counter.increment(value);

      // Get the next counter
      counterString =
        getBlock(groupString, COUNTER_OPEN, COUNTER_CLOSE, groupIndex);
    }

    groupString = getBlock(compactString, GROUP_OPEN, GROUP_CLOSE, index);
  }
  return counters;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:74,代码来源:CountersStrings.java


注:本文中的org.apache.hadoop.mapreduce.Counter.increment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。