Type mismatch in key from map: expected .. Text, received … LongWritable

Couple of things to be fixed in the code

  1. The old (o.a.h.mapred) and the new API (o.a.h.mapreduce) are not compatible, so they should not be mixed.

    import org.apache.hadoop.mapred.OutputCollector;
    import org.apache.hadoop.mapred.Reporter;
    import org.apache.hadoop.mapreduce.Job;
    import org.apache.hadoop.mapreduce.Mapper;
    import org.apache.hadoop.mapreduce.Reducer;

  2. Make sure the input/output for the mappers/reducers are of the type o.a.h.io.Writable. The input key for the Mapper is Object, make it LongWritable.

  3. Looks like the Combiner and the Reducer functionality is the same, so you need not repeat it.

    job.setCombinerClass(Reducer.class);

猜你喜欢

转载自irwenqiang.iteye.com/blog/1513787