• Post Reply Bookmark Topic Watch Topic
  • New Topic

Type casting in mapeduce  RSS feed

 
Priya chek
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,



I have written a mapreduce job, in which i I have written textoutput format as output format & output key & output vale also given. But I was excepting an exception because Textoutputformat outputs default key as Longwritable & value as text.But i have given output key class as text & Intwritable as value. j1.setOutputKeyClass(Text.class); j1.setOutputValueClass(IntWritable.class);


I want to know why it didnt throw excéption even if type mismatch occurs.

This is my code


public class WcDriver extends Configured implements Tool{

public static void main(String[] args) throws Exception {

int res=ToolRunner.run(new Configuration(), new WcDriver(), args);
System.exit(res);

}

@Override
public int run(String[] args) throws Exception {
// TODO Auto-generated method stub
Configuration c1=new Configuration();

Job j1 = new Job(c1,"wroc");
j1.setJarByClass(WcDriver.class);
j1.setMapperClass(MapTask.class);
j1.setReducerClass(ReduceTask.class);


j1.setOutputKeyClass(Text.class);
j1.setOutputValueClass(IntWritable.class);

j1.setOutputFormatClass(TextOutputFormat.class);

FileInputFormat.addInputPath(j1, new Path(args[0]));
FileOutputFormat.setOutputPath(j1, new Path(args[1]));
return j1.waitForCompletion(true) ? 0 : 1;
}

}

Please help me ASAP. Thanks for the valuable answers.
 
Priya chek
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know when it will throw exception & will it doing any casting beside that, if yes please show me with an example
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!