我正在尝试制作一个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);
}
1条答案
按热度按时间mec1mxoz1#
应按如下方式使用map reduce util:
再加上减速器和合路器
而不是将reducer添加到表Map器作业中