如何在Reducer的close方法中发射 [英] How to emit in the close method of Reducer
问题描述
从 MapReduceBase
继承的 close
方法没有参数:
public void close()
没有 OutputCollector
作为 reduce
方法:
<$ p $ K2> $ reduce $(K2 key,Iterator V2> value,OutputCollector< K3,
在新的hadoop API中,我发现Reducer类有一个 setup
方法:
void setup(Context context)
I认为上下文参数可以发出键和值。
问题是我必须使用旧的API,我不知道如何在关闭方法中发出。
我想要的是在上次调用reduce方法并发出数据时运行一些代码。不幸的是你正在使用旧的API。新的API有一个 cleanup
方法(补充 setup
)。
我不知道Hadoop是否会允许您在Reducer类的私有数据成员中作弊并存储 OutputCollector
,然后请参阅close方法。我猜你不能,但可能值得一试。
The close
method inherited from MapReduceBase
has no argument:
public void close()
So I don't have OutputCollector
as reduce
method does:
void reduce(K2 key, Iterator<V2> values, OutputCollector<K3, V3> output, Reporter reporter)
In the new hadoop API, I find the Reducer class has a setup
method:
void setup(Context context)
I think the context argument can emit key and value. The problem is I have to use the old API and I don't know how to emit in the close method. What I want is to run some code when the last time reduce method is called and emit data.
It is unfortunate you are using the old API. The new API has a cleanup
method (complements setup
).
I wonder if Hadoop will let you cheat and store the OutputCollector
in a private data member in your Reducer class, then refer to that in the close method. I'm guessing you can't, but it might be worth a try.
这篇关于如何在Reducer的close方法中发射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!