hadoop应用程序找不到reducer

bfnvny8b  于 2021-05-30  发布在  Hadoop
关注(0)|答案(1)|浏览(414)

我正在尝试制作一个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示例,效果很好。然后我改变了Map器的类型和配置方式,得到了这个错误。有人能帮我吗?
编辑: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);
    }
mec1mxoz

mec1mxoz1#

应按如下方式使用map reduce util:

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

再加上减速器和合路器

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

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

相关问题