gpt4 book ai didi

java - Hadoop 应用程序找不到 Reducer

转载 作者:可可西里 更新时间:2023-11-01 14:33:29 27 4
gpt4 key购买 nike

我正在尝试制作一个 mapreduce 应用程序,它从 Hbase 表中读取并将作业结果写入文本文件。我的驱动程序代码如下所示:

    Configuration conf = HBaseConfiguration.create();
Job job = Job.getInstance (conf, "mr test");
job.setJarByClass(Driverclass.class);
job.setCombinerClass(reducername.class);
job.setReducerClass(reducername.class);

Scan scan = new Scan();
scan.setCaching(500);
scan.setCacheBlocks(false);

String qualifier = "qualifname"; // comma seperated
String family= "familyname";
scan.addColumn(Bytes.toBytes(family), Bytes.toBytes(qualifier));

TableMapReduceUtil.initTableMapperJob("tablename",
scan,
mappername.class,
Text.class, Text.class,
job);

当调用 initTableMapperJob 时,我得到一个 ClassNotFoundException: class reducername not found。

该类在同一个包内的另一个 java 文件中定义。我使用几乎相同的配置来尝试通常的 wordcount 示例并且工作正常。然后我改变了映射器的类型和它的配置方式,我得到了这个错误。有人可以帮助我吗?

编辑:reducer 类的代码是:

package mr.roadlevelmr;
import java.io.IOException;
import java.util.ArrayList;
import java.util.StringTokenizer;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.Reducer;
public class reducername extends Reducer <Text, Text, Text, Text>{
private Text result= new Text();

public void reduce (Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException{
ArrayList<String> means = new ArrayList<String>();
for (Text val : values){
means.add(String.valueOf(val.getBytes()));
}
result.set(newMean(means));
context.write(key, result);
}

最佳答案

您应该按如下方式使用 Map reduce 实用程序:

TableMapReduceUtil.initTableMapperJob("tablename", 
scan,
mappername.class,
Text.class, Text.class,
job);Ok think I found the issue!

比添加reducer和combiner

job.setCombinerClass(reducername.class);
job.setReducerClass(reducername.class);
boolean b = job.waitForCompletion(true);

而不是将 reducer 添加到表映射器作业中

关于java - Hadoop 应用程序找不到 Reducer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31160447/

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