【发布时间】:2020-03-26 11:13:15
【问题描述】:
我想访问 reducer 中的 myCounter.my 值:
public static class Map extends Mapper<LongWritable, Text, ImmutableBytesWritable, ImmutableBytesWritable>
{
public static enum myCounter{my};
@Override
public void map(LongWritable key, Text value, Context context)
{
context.getCounter(myCounter.my).increment(1);
context.write( new ImmutableBytesWritable ( ),new ImmutableBytesWritable() );
}
}
public static class Reduce extends Reducer<ImmutableBytesWritable, ImmutableBytesWritable, Text, Text>
{
@Override
public void reduce(ImmutableBytesWritable key,Iterable<ImmutableBytesWritable> result,Context context)
{
}
}
Accessing a mapper's counter from a reducer(for old API is given ) 如何使它适用于新的 API?
或者
我想知道映射器输出的总数?有没有更好的办法? (我无法访问 Reducer 中的计数器:
Group Name->org.apache.hadoop.mapred.Task$Counter Counter Name->MAP_OUTPUT_RECORDS)
谢谢
【问题讨论】:
-
您使用的是哪个 hadoop 版本?
-
@faizan: ty 但正如您所看到的,示例是通过 Job 访问计数器,只有在 Job 完成破坏后才能在 main(String args[]) 或其他函数中,我想在 Reduce 中访问它的位置。所以我的问题仍然没有解决。