Map-reduce JobConf -添加FileInputFormat错误



我使用语法创建了一个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的映射,因为我在mapper中使用outputCollectorReporter

在作业中,如果我使用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也出现同样的错误。

请给出解决方案

我认为问题是你导入了不合适的FileInputFormat。我猜你需要替换

import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;

import org.apache.hadoop.mapred.FileInputFormat;

您基本上混合了两个导入,mapred(旧的)和mapreduce(新的)。尝试只包含一个,并用新的mapreduce类

替换所有旧的

最新更新