Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Hadoop >> mail # user >> Re: Can a mapper forward its input text or does it have to copy it?


Copy link to this message
-
Re: Can a mapper forward its input text or does it have to copy it?
You can simply do the latter (example#2). The example#1 would work
too, but seems unnecessary.

On Wed, Jul 31, 2013 at 1:38 AM, Matthieu Labour <[EMAIL PROTECTED]> wrote:
>
> Hi
>
> When a mapper does nothing, can it forward the input text or does it have to
> allocate / deep copy it to a new Text?
>
> Which one is the recommended between example#1 and example#2?
>
> From reading the documentation, I am under the impression that example#1 is
> NOT correct as the input text reference is not immutable and can change. Am
> I wrong?
>
> Thank you for your help.
>
> example#1:
> static public class MySimpleMapper extends
> Mapper<LongWritable, Text, Text, NullWritable> {
> private final static Text MYNEWINPUTTEXT = new Text();
> @Override
> protected void map(LongWritable offset, Text text, Context context)
> throws IOException, InterruptedException {
> MYNEWINPUTTEXT.set(text);
> context.write(MYNEWINPUTTEXT, NullWritable.get());
> }
> }
>
> example#2:
> static public class MySimpleMapper extends
> Mapper<LongWritable, Text, Text, NullWritable> {
> private final static Text MYNEWINPUTTEXT = new Text();
> @Override
> protected void map(LongWritable offset, Text text, Context context)
> throws IOException, InterruptedException {
> context.write(text, NullWritable.get());
> }
> }

--
Harsh J
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB