本文整理汇总了Java中org.apache.hadoop.mapreduce.counters.AbstractCounters类的典型用法代码示例。如果您正苦于以下问题:Java AbstractCounters类的具体用法?Java AbstractCounters怎么用?Java AbstractCounters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractCounters类属于org.apache.hadoop.mapreduce.counters包,在下文中一共展示了AbstractCounters类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toEscapedCompactString
import org.apache.hadoop.mapreduce.counters.AbstractCounters; //导入依赖的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();
}
示例2: incrAllCounters
import org.apache.hadoop.mapreduce.counters.AbstractCounters; //导入依赖的package包/类
/** {@inheritDoc} */
@Override public synchronized void incrAllCounters(AbstractCounters<Counter, CounterGroup> other) {
for (CounterGroup group : other) {
for (Counter counter : group) {
findCounter(group.getName(), counter.getName()).increment(counter.getValue());
}
}
}
示例3: parseEscapedCompactString
import org.apache.hadoop.mapreduce.counters.AbstractCounters; //导入依赖的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;
}
示例4: parseEscapedCompactString
import org.apache.hadoop.mapreduce.counters.AbstractCounters; //导入依赖的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 =
getBlock(groupString, UNIT_OPEN, UNIT_CLOSE, groupIndex);
groupName = unescape(groupName);
// Get the display name
String groupDisplayName =
getBlock(groupString, UNIT_OPEN, UNIT_CLOSE, groupIndex);
groupDisplayName = 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 =
getBlock(counterString, UNIT_OPEN, UNIT_CLOSE, counterIndex);
counterName = unescape(counterName);
// Get the display name
String counterDisplayName =
getBlock(counterString, UNIT_OPEN, UNIT_CLOSE, counterIndex);
counterDisplayName = 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;
}
示例5: Counters
import org.apache.hadoop.mapreduce.counters.AbstractCounters; //导入依赖的package包/类
/**
* Construct the Counters object from the another counters object
* @param <C> the type of counter
* @param <G> the type of counter group
* @param counters the old counters object
*/
public <C extends Counter, G extends CounterGroupBase<C>>
Counters(AbstractCounters<C, G> counters) {
super(counters, groupFactory);
}