Hadoop application cannot find Reducer

I am trying to make a mapreduce application that reads from an Hbase table and writes the job results to a text file. My driver code looks like this:

    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);

      

when initTableMapperJob is called I get ClassNotFoundException: class reducecername not found.

The class is defined in another java file in the same package. I used almost the same configuration to try a regular wordcount example and worked great. Then I changed the type of the mapping and the way I set it up and I get this error. Can anyone help me?

Edit: code for the reducer class:

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);
    }

      

+3


source to share


1 answer


you have to use Map reduce utility like below:

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

      

than add a reducer and an adder



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

      

Instead of adding a reducer to a table mapping job

+2


source







All Articles