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


Java CounterGroupBase类代码示例

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


CounterGroupBase类属于org.apache.hadoop.mapreduce.counters包,在下文中一共展示了CounterGroupBase类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: equals

import org.apache.hadoop.mapreduce.counters.CounterGroupBase; //导入依赖的package包/类
@Override
public synchronized boolean equals(Object genericRight) {
  if (genericRight instanceof CounterGroupBase<?>) {
    @SuppressWarnings("unchecked")
    CounterGroupBase<Counter> right = ((CounterGroupBase<Counter>) 
    genericRight).getUnderlyingGroup();
    return Iterators.elementsEqual(iterator(), right.iterator());
  }
  return false;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:Counters.java

示例2: toEscapedCompactString

import org.apache.hadoop.mapreduce.counters.CounterGroupBase; //导入依赖的package包/类
/**
 * Make the pre 0.21 counters string
 * @param <C> type of the counter
 * @param <G> type of the counter group
 * @param <T> type of the counters object
 * @param counters the object to stringify
 * @return the string in the following format
 * {(groupName)(group-displayName)[(counterName)(displayName)(value)]*}*
 */
public static <C extends Counter, G extends CounterGroupBase<C>,
               T extends AbstractCounters<C, G>>
String toEscapedCompactString(T counters) {
  StringBuilder builder = new StringBuilder();
  synchronized(counters) {
    for (G group : counters) {
      builder.append(toEscapedCompactString(group));
    }
  }
  return builder.toString();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:21,代码来源:CountersStrings.java

示例3: incrAllCounters

import org.apache.hadoop.mapreduce.counters.CounterGroupBase; //导入依赖的package包/类
@Override
public void incrAllCounters(CounterGroupBase<Counter> rightGroup) {
  realGroup.incrAllCounters(rightGroup);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:5,代码来源:Counters.java

示例4: getUnderlyingGroup

import org.apache.hadoop.mapreduce.counters.CounterGroupBase; //导入依赖的package包/类
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return realGroup;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:5,代码来源:Counters.java

示例5: getCounterValue

import org.apache.hadoop.mapreduce.counters.CounterGroupBase; //导入依赖的package包/类
static long getCounterValue(CounterGroupBase<Counter> group, String counterName) {
  Counter counter = group.findCounter(counterName, false);
  if (counter != null) return counter.getValue();
  return 0L;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:6,代码来源:Counters.java

示例6: getUnderlyingGroup

import org.apache.hadoop.mapreduce.counters.CounterGroupBase; //导入依赖的package包/类
@Override
public CounterGroupBase<Counter> getUnderlyingGroup() {
  return this;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:5,代码来源:Counters.java

示例7: toEscapedCompactString

import org.apache.hadoop.mapreduce.counters.CounterGroupBase; //导入依赖的package包/类
/**
 * Make the 0.21 counter group string.
 * format: {(actual-name)(display-name)(value)[][][]}
 * where [] are compact strings for the counters within.
 * @param <G> type of the group
 * @param group to stringify
 * @return the stringified result
 */
public static <G extends CounterGroupBase<?>>
String toEscapedCompactString(G group) {
  List<String> escapedStrs = Lists.newArrayList();
  int length;
  String escapedName, escapedDispName;
  synchronized(group) {
    // First up, obtain the strings that need escaping. This will help us
    // determine the buffer length apriori.
    escapedName = escape(group.getName());
    escapedDispName = escape(group.getDisplayName());
    int i = 0;
    length = escapedName.length() + escapedDispName.length();
    for (Counter counter : group) {
      String escapedStr = toEscapedCompactString(counter);
      escapedStrs.add(escapedStr);
      length += escapedStr.length();
    }
  }
  length += 6; // for all the delimiting characters below
  StringBuilder builder = new StringBuilder(length);
  builder.append(GROUP_OPEN); // group start

  // Add the group name
  builder.append(UNIT_OPEN);
  builder.append(escapedName);
  builder.append(UNIT_CLOSE);

  // Add the display name
  builder.append(UNIT_OPEN);
  builder.append(escapedDispName);
  builder.append(UNIT_CLOSE);

  // write the value
  for(String escaped : escapedStrs) {
    builder.append(escaped);
  }

  builder.append(GROUP_CLOSE); // group end
  return builder.toString();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:49,代码来源:CountersStrings.java

示例8: parseEscapedCompactString

import org.apache.hadoop.mapreduce.counters.CounterGroupBase; //导入依赖的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.counters.CounterGroupBase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。