Mapreduce代碼編寫問題彙總

1、job.setOutputFormatClass(TextOutputFormat.class);報錯

The method setOutputFormatClass(Class< ? extends OutputFormat>) in the type Job is not applicable for the arguments (Class< TextOutputFormat>)

原因:新舊API混合着用了 把以org.apache.hadoop.mapred開頭導入的包都改成新版本的API。引入的是org.apache.hadoop.mapred.TextOutputFormat;換成 org.apache.hadoop.mapreduce.lib.input.TextInputFormat;

2、Error: java.io.IOException: Unable to initialize any output collector

原因:代碼中job.setMapOutputKeyClass(Text.class);job.setOutputValueClass(Text.class);分別定義了Map輸出的key和最終輸出value類型都是Text類。但是代碼中引入的是 com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider.Text;實際上應該是org.apache.hadoop.io.Text;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章