本文整理了Java中org.apache.hadoop.mapreduce.Counter.<init>()
方法的一些代码示例,展示了Counter.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Counter.<init>()
方法的具体详情如下:
包路径:org.apache.hadoop.mapreduce.Counter
类名称:Counter
方法名:<init>
[英]Create a counter.
[中]创建一个计数器。
代码示例来源:origin: com.facebook.hadoop/hadoop-core
/**
* Internal to find a counter in a group.
* @param counterName the name of the counter
* @param displayName the display name of the counter
* @return the counter that was found or added
*/
protected Counter findCounter(String counterName, String displayName) {
Counter result = counters.get(counterName);
if (result == null) {
result = new Counter(counterName, displayName);
counters.put(counterName, result);
}
return result;
}
代码示例来源:origin: org.apache.hadoop/hadoop-mapred
/**
* Find a counter in a group.
* @param counterName the name of the counter
* @param displayName the display name of the counter
* @return the counter that was found or added
*/
public Counter findCounter(String counterName, String displayName) {
Counter result = counters.get(counterName);
if (result == null) {
result = new Counter(counterName, displayName);
counters.put(counterName, result);
}
return result;
}
代码示例来源:origin: com.facebook.hadoop/hadoop-core
public synchronized Counter findCounter(String counterName) {
Counter result = counters.get(counterName);
if (result == null) {
String displayName = localize(counterName, counterName);
result = new Counter(counterName, displayName);
counters.put(counterName, result);
}
return result;
}
代码示例来源:origin: org.apache.hadoop/hadoop-mapred
public synchronized Counter findCounter(String counterName) {
Counter result = counters.get(counterName);
if (result == null) {
String displayName = localize(counterName, counterName);
result = new Counter(counterName, displayName);
counters.put(counterName, result);
}
return result;
}
代码示例来源:origin: org.apache.hadoop/hadoop-mapred
static Counters fromAvro(JhCounters counters) {
Counters result = new Counters();
for (JhCounterGroup g : counters.groups) {
CounterGroup group =
new CounterGroup(g.name.toString(), g.displayName.toString());
for (JhCounter c : g.counts) {
group.addCounter(new Counter(c.name.toString(),
c.displayName.toString(),
c.value));
}
result.addGroup(group);
}
return result;
}
代码示例来源:origin: org.apache.hadoop/hadoop-mapred
public synchronized void readFields(DataInput in) throws IOException {
displayName = Text.readString(in);
counters.clear();
int size = WritableUtils.readVInt(in);
for(int i=0; i < size; i++) {
Counter counter = new Counter();
counter.readFields(in);
counters.put(counter.getName(), counter);
}
}
代码示例来源:origin: com.facebook.hadoop/hadoop-core
public synchronized void readFields(DataInput in) throws IOException {
displayName = Text.readString(in);
counters.clear();
int size = WritableUtils.readVInt(in);
for(int i=0; i < size; i++) {
Counter counter = new Counter();
counter.readFields(in);
counters.put(counter.getName(), counter);
}
}
代码示例来源:origin: org.apache.hadoop/hadoop-mapred-test
/**
* Verify counter value works
*/
@Test
public void testCounterValue() {
final int NUMBER_TESTS = 100;
final int NUMBER_INC = 10;
final Random rand = new Random();
for (int i = 0; i < NUMBER_TESTS; i++) {
long initValue = rand.nextInt();
long expectedValue = initValue;
Counter counter = new Counter("foo", "bar", expectedValue);
assertEquals("Counter value is not initialized correctly",
expectedValue, counter.getValue());
for (int j = 0; j < NUMBER_INC; j++) {
int incValue = rand.nextInt();
counter.increment(incValue);
expectedValue += incValue;
assertEquals("Counter value is not incremented correctly",
expectedValue, counter.getValue());
}
expectedValue = rand.nextInt();
counter.setValue(expectedValue);
assertEquals("Counter value is not set correctly",
expectedValue, counter.getValue());
}
}
内容来源于网络,如有侵权,请联系作者删除!