You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by Uri Shani <SH...@il.ibm.com> on 2009/07/06 13:39:47 UTC

end of input event to a mapper

Hi.
How can the mapper task know this is the last map() call?
Do I need to intervene within the Hadoop framework? where?

Thanks,
- Uri

Re: end of input event to a mapper

Posted by Owen O'Malley <om...@apache.org>.
On Jul 6, 2009, at 1:09 PM, Hong Tang wrote:

> Sometime a user needs to output some more records after the last  
> record is seen. So, with the solution Jothi provided, a user still  
> has to cache the output collector (and reporter) object in his/her  
> Mapper class. This also requires that a mapper will be called with  
> the same output collector object for every map() call and its life  
> exists until after close() is called. Neither of them are explicitly  
> described in the documentation of the Mapper.map() API. Personally,  
> I think it might be better to add a boolean flag on the map() call,  
> or call map() one last time with null/null as key/value.

A boolean wouldn't be practical, since the framework doesn't know it  
is at the end until after the RecordReader fails to return one.

Fortunately, in the new API the close method is passed the context,  
which includes the methods for doing output.

-- Owen

Re: end of input event to a mapper

Posted by Hong Tang <ht...@yahoo-inc.com>.
Sometime a user needs to output some more records after the last  
record is seen. So, with the solution Jothi provided, a user still has  
to cache the output collector (and reporter) object in his/her Mapper  
class. This also requires that a mapper will be called with the same  
output collector object for every map() call and its life exists until  
after close() is called. Neither of them are explicitly described in  
the documentation of the Mapper.map() API. Personally, I think it  
might be better to add a boolean flag on the map() call, or call map()  
one last time with null/null as key/value.

On Jul 6, 2009, at 11:13 AM, Ted Dunning wrote:

> That does not quite mean that this is the last map() call in a global
> sense.  In fact, the entire map task could be run a second time by the
> framework.
>
> Close does mean that this particular mapper object will not receive  
> any more
> map() calls and thus can clean up any resources it owned.
>
> The original poster probably meant last Map() in the smaller sense,  
> but it
> is really important to think in terms of non-deterministic execution  
> of
> maps, so it is probably a good think to inject this slight  
> qualification to
> the answer.
>
> On Mon, Jul 6, 2009 at 4:48 AM, Jothi Padmanabhan <jothipn@yahoo-inc.com 
> >wrote:
>
>> For each map task, there is a configure() method and a close() that  
>> get
>> called before and after the actual map method itself. You could do  
>> your
>> processing there. You could get the current task ID in the  
>> configure method
>> and use that to decide and perform specific map related activities  
>> if you
>> so
>> wish.
>>
>> Jothi
>>
>>
>> On 7/6/09 5:09 PM, "Uri Shani" <SH...@il.ibm.com> wrote:
>>
>>> Hi.
>>> How can the mapper task know this is the last map() call?
>>> Do I need to intervene within the Hadoop framework? where?
>>>
>>> Thanks,
>>> - Uri
>>
>>
>
>
> -- 
> Ted Dunning, CTO
> DeepDyve
>
> 111 West Evelyn Ave. Ste. 202
> Sunnyvale, CA 94086
> http://www.deepdyve.com
> 858-414-0013 (m)
> 408-773-0220 (fax)


Re: end of input event to a mapper

Posted by Ted Dunning <te...@gmail.com>.
That does not quite mean that this is the last map() call in a global
sense.  In fact, the entire map task could be run a second time by the
framework.

Close does mean that this particular mapper object will not receive any more
map() calls and thus can clean up any resources it owned.

The original poster probably meant last Map() in the smaller sense, but it
is really important to think in terms of non-deterministic execution of
maps, so it is probably a good think to inject this slight qualification to
the answer.

On Mon, Jul 6, 2009 at 4:48 AM, Jothi Padmanabhan <jo...@yahoo-inc.com>wrote:

> For each map task, there is a configure() method and a close() that get
> called before and after the actual map method itself. You could do your
> processing there. You could get the current task ID in the configure method
> and use that to decide and perform specific map related activities if you
> so
> wish.
>
> Jothi
>
>
> On 7/6/09 5:09 PM, "Uri Shani" <SH...@il.ibm.com> wrote:
>
> > Hi.
> > How can the mapper task know this is the last map() call?
> > Do I need to intervene within the Hadoop framework? where?
> >
> > Thanks,
> > - Uri
>
>


-- 
Ted Dunning, CTO
DeepDyve

111 West Evelyn Ave. Ste. 202
Sunnyvale, CA 94086
http://www.deepdyve.com
858-414-0013 (m)
408-773-0220 (fax)

Re: end of input event to a mapper

Posted by Uri Shani <SH...@il.ibm.com>.
Thanks!



From:
Jothi Padmanabhan <jo...@yahoo-inc.com>
To:
<co...@hadoop.apache.org>
Date:
06/07/2009 02:49 PM
Subject:
Re: end of input event to a mapper



For each map task, there is a configure() method and a close() that get
called before and after the actual map method itself. You could do your
processing there. You could get the current task ID in the configure 
method
and use that to decide and perform specific map related activities if you 
so
wish.

Jothi


On 7/6/09 5:09 PM, "Uri Shani" <SH...@il.ibm.com> wrote:

> Hi.
> How can the mapper task know this is the last map() call?
> Do I need to intervene within the Hadoop framework? where?
> 
> Thanks,
> - Uri




Re: end of input event to a mapper

Posted by Jothi Padmanabhan <jo...@yahoo-inc.com>.
For each map task, there is a configure() method and a close() that get
called before and after the actual map method itself. You could do your
processing there. You could get the current task ID in the configure method
and use that to decide and perform specific map related activities if you so
wish.

Jothi


On 7/6/09 5:09 PM, "Uri Shani" <SH...@il.ibm.com> wrote:

> Hi.
> How can the mapper task know this is the last map() call?
> Do I need to intervene within the Hadoop framework? where?
> 
> Thanks,
> - Uri