首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 企业软件 > 行业软件 >

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

2012-08-22 
Type mismatch in key from map: expected .. Text, received … LongWritableCouple of things to be fixe

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

热点排行