Map-reduce JobConf - 添加FileInputFormat时出错

Ani*_*ram 0 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)
    --
}
Run Code Online (Sandbox Code Playgroud)

在作业中,我创建了一个Job对象:

Job job = new Job(getConf());
Run Code Online (Sandbox Code Playgroud)

对于这项工作,我无法使用以下方法添加Mapper类:

job.setMapper(xyz);
Run Code Online (Sandbox Code Playgroud)

错误信息:

The method setMapperClass(Class<? extends Mapper>) in the type Job is not applicable for the arguments (Class<InvertedIndMap1>)
Run Code Online (Sandbox Code Playgroud)

我不能使用带有extend的地图,Mapper因为我正在使用outputCollector和Reporter在mapper.

在工作中,如果我使用JobConf而不是像以下那样的工作:

JobConf conf = new JobConf(getConf());
Run Code Online (Sandbox Code Playgroud)

然后conf.setMapper(xyz)工作.

但是无法使用以下方法设置输入路径:

FileInputFormat.addInputPaths(conf,new Path(args[0]));
Run Code Online (Sandbox Code Playgroud)

错误信息:

The method addInputPaths(Job, String) in the type FileInputFormat is not applicable for the arguments (JobConf, Path)
Run Code Online (Sandbox Code Playgroud)

我试过setInputPaths,setInputpath,addInputPath.但同样的错误.发生相同的错误addOutputPath/SetOuputpath.

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

Ale*_*kov 5

我认为问题是你导入的不合适FileInputFormat.我想你需要更换

import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
Run Code Online (Sandbox Code Playgroud)

同

import org.apache.hadoop.mapred.FileInputFormat;
Run Code Online (Sandbox Code Playgroud)