How can we pass List <Text> as Mapper output?

I am working on a Map-Reduce problem. But one day I got stuck with how to convey List<Text>

how Mapper output

? Is it possible or not? If so, how can we tell configuration

about Mapper output class

?

+3


source to share


1 answer


You can use the ArrayWritable class as a value object from the mapper class. Please refer to the below code snippet for your mapping class,

ArrayWritable arrayWritable = new ArrayWritable(Text.class);

Text [] textValues = new Text[2];
textValues[0] = new Text("value1");
textValues[1] = new Text("value1");

arrayWritable.set(textValues );
context.write(key , arrayWritable );

      



set the value class as the following in your driver class,

job.setMapOutputValueClass(ArrayWritable.class);

      

+4


source







All Articles