我使用以下语法创建了Mapper
:
public class xyz extends MapReduceBase implements Mapper<LongWritable, Text, Text, Text>{
-----
public void map(LongWritable key, Text value,
OutputCollector<Text, Text> output, Reporter reporter)
--
}
在工作中,我创建了一个Job对象:
Job job = new Job(getConf());
对于这项工作,我无法使用以下方法添加Mapper类:
job.setMapper(xyz);
错误消息:
The method setMapperClass(Class<? extends Mapper>) in the type Job is not applicable for the arguments (Class<InvertedIndMap1>)
当我在Mapper
中使用outputCollector
和Reporter
时,我无法使用带有mapper
扩展名的地图。
在工作中,如果我使用JobConf
而不是像以下那样的工作:
JobConf conf = new JobConf(getConf());
然后conf.setMapper(xyz)
正在运作。
但无法使用以下方式设置输入路径:
FileInputFormat.addInputPaths(conf,new Path(args[0]));
错误讯息:
The method addInputPaths(Job, String) in the type FileInputFormat is not applicable for the arguments (JobConf, Path)
我尝试了setInputPaths
,setInputpath
,addInputPath
。但同样的错误。
addOutputPath/SetOuputpath
发生了同样的错误。
请为此问题提出解决方案。
答案 0 :(得分:5)
我认为问题在于您导入了不合适的FileInputFormat
。我想你需要更换
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
与
import org.apache.hadoop.mapred.FileInputFormat;
答案 1 :(得分:0)
你基本上混合了两个导入,mapred(旧)和mapreduce(新)。尝试只包含一个并用新的mapreduce类替换所有旧的