Map-reduce JobConf - 添加FileInputFormat时出错

时间:2014-07-20 08:01:19

标签: hadoop mapreduce

我使用以下语法创建了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中使用outputCollectorReporter时,我无法使用带有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)

我尝试了setInputPathssetInputpathaddInputPath。但同样的错误。 addOutputPath/SetOuputpath发生了同样的错误。

请为此问题提出解决方案。

2 个答案:

答案 0 :(得分:5)

我认为问题在于您导入了不合适的FileInputFormat。我想你需要更换

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

import org.apache.hadoop.mapred.FileInputFormat;

答案 1 :(得分:0)

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