hadoop-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthieu Labour <matth...@actionx.com>
Subject Can a mapper forward its input text or does it have to copy it?
Date Tue, 30 Jul 2013 20:08:11 GMT
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());
}
}

Mime
View raw message