With hadoop's old API, you can make your map class extends MapReduceBase,
and override the close() to do what you want.
In hadoop's new API, you can create your map extends
org.apache.hadoop.mapreduce.Mapper, and override the  cleanup(Context
context) method

Jeff Zhang


2009/12/18 Chris Dyer <[email protected]>

> You can write output in the mapper's close() method, which will be
> called after the last line of input is processed.  When I was last
> doing this (~ version 17), it was a bit of a pain, since by default
> you didn't have access to the relevant output object, making it
> necessary to store it in a field in the object.  I don't know if the
> interfaces have been improved since then.
>
> -Chris
>
> 2009/12/17 Gang Luo <[email protected]>:
> > Hi all,
> > most of the time, we focus on the map function to decide whether to
> output a record and what to output. Now I want to do something at the map
> task level. I want to output a record when a map task finish and this record
> should be processed by reducer properly. Is there any way to output (like
> output.collect in map function) a record outside map function?
> >
> > If that is impossible, to know whether I meet the last line for this map
> task is also helpful. Does anyone know how to tell whether the line I am
> processing now in map function is the last line for this map task?
> >
> > Thanks.
> >
> > -Gang
> >
> >
> >      ___________________________________________________________
> >  好玩贺卡等你发,邮箱贺卡全新上线!
> > http://card.mail.cn.yahoo.com/
> >
>

Reply via email to