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 Foss User <fo...@gmail.com> on 2009/05/08 08:10:58 UTC

How to write a map() method that needs no input?

Sometimes I would like to just execute a certain method in all nodes.
The method does not need inputs. So, there is no need of any
InputFormat implementation class. So, I would want to just write a
Mapper implementation class with a map() method. But, the problem with
map() method is that it always needs inputs. How do I avoid this?

Re: How to write a map() method that needs no input?

Posted by Todd Lipcon <to...@cloudera.com>.
On Thu, May 7, 2009 at 11:10 PM, Foss User <fo...@gmail.com> wrote:

> Sometimes I would like to just execute a certain method in all nodes.
> The method does not need inputs. So, there is no need of any
> InputFormat implementation class. So, I would want to just write a
> Mapper implementation class with a map() method. But, the problem with
> map() method is that it always needs inputs. How do I avoid this?
>

You can always implement your own InputFormat class - just make getSplits
return whatever number of splits you want (which you can just ignore). Then
make getRecordReader return a RecordReader implementation that outputs a
single NullWritable, NullWritable key.

-Todd

Re: How to write a map() method that needs no input?

Posted by Jothi Padmanabhan <jo...@yahoo-inc.com>.
You could write your own InputFormat to fake the split.
See src/test/org/apache/hadoop/mapred/EmptyInputFormat.java

Jothi

On 5/8/09 11:40 AM, "Foss User" <fo...@gmail.com> wrote:

> Sometimes I would like to just execute a certain method in all nodes.
> The method does not need inputs. So, there is no need of any
> InputFormat implementation class. So, I would want to just write a
> Mapper implementation class with a map() method. But, the problem with
> map() method is that it always needs inputs. How do I avoid this?