gpt4 book ai didi

java - ChainReducer.setReducer 方法抛出错误 "ChainReducer is not applicable for the arguments"

转载 作者:可可西里 更新时间:2023-11-01 14:52:43 24 4
gpt4 key购买 nike

我有两个映射器类。所以使用ChainMapper.addMapper方法添加Mapper,使用ChainReducer.setReducer方法设置Reducer。 ChainMapper.addMapper 方法正常 但是 Chain.setReducer 方法抛出语法错误

The method setReducer(Job, Class<? extends Reducer>, Class<?>, Class<?>, Class<?>, Class<?>, Configuration) in the type ChainReducer is not applicable for the arguments (JobConf, Class<FileComparisionReduce>, Class<LongWritable>, Class<Text>, Class<LongWritable>, Class<Text>, boolean, JobConf)

这是我的驱动程序类:

package fileComparision;

import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.JobClient;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.FileInputFormat;
import org.apache.hadoop.mapred.FileOutputFormat;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.Mapper;
import org.apache.hadoop.mapred.lib.ChainMapper;
import org.apache.hadoop.mapreduce.lib.chain.ChainReducer;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;

public class DriverComparision extends Configured implements Tool{


@Override
public int run(String[] arg0) throws Exception {
JobConf conf = new JobConf(true);
conf.setJobName("Comaprision of 2 file ");
JobConf Mapper1 = new JobConf(false);


ChainMapper.addMapper(conf, FileComparisionMapper1.class, LongWritable.class, Text.class, LongWritable.class, Text.class, true, Mapper1);

JobConf Mapper2 = new JobConf(false);
ChainMapper.addMapper(conf, FileComparisionMapper2.class, LongWritable.class, Text.class, LongWritable.class, Text.class, true, Mapper2);


JobConf Reduc = new JobConf(false);
ChainReducer.setReducer(conf, FileComparisionReduce.class, LongWritable.class, Text.class, LongWritable.class, Text.class, true , Reduc);


FileInputFormat.setInputPaths(conf, new Path(arg0[0]));
FileOutputFormat.setOutputPath(conf, new Path(arg0[1]));

conf.setMapOutputKeyClass(LongWritable.class);
conf.setMapOutputValueClass(Text.class);
conf.setOutputKeyClass(LongWritable.class);
conf.setOutputValueClass(Text.class);


JobClient.runJob(conf);

return 0;
}

还尝试通过删除 boolean 参数“true”

JobConf Reduc = new JobConf(false);
ChainReducer.setReducer(conf, FileComparisionReduce.class, LongWritable.class, Text.class, LongWritable.class, Text.class, true , Reduc);

最佳答案

终于找到解决办法了。 导入了错误的包,即。 导入 org.apache.hadoop.mapreduce.lib.chain.ChainReducer;而不是 import org.apache.hadoop.mapred.lib.ChainReducer;

关于java - ChainReducer.setReducer 方法抛出错误 "ChainReducer is not applicable for the arguments",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36350193/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com