在映射中的键中键入不匹配:预期的org.apache.hadoop.io.Text,收到org.apache.hadoo


    package Sort;
    import java.io.IOException;
    import org.apache.hadoop.io.DoubleWritable;
    import org.apache.hadoop.io.LongWritable;
    import org.apache.hadoop.io.Text;
    import org.apache.hadoop.mapreduce.Mapper;
    public class sortmapper extends                  Mapper<LongWritable,Text,Text,DoubleWritable> {
        public void map(Text key, Iterable<DoubleWritable> value, Context                            context) throws IOException, InterruptedException {
            String line = value.toString();
            String subId = line.substring(15, 26);
            Double bytes = Double.parseDouble(line.substring(45, 56));
            if (bytes == null) 
                bytes = 0.0;
            context.write(new Text(subId),new DoubleWritable(bytes));
        }
    }

这是我编写的映射器方法,但我收到上述错误。

问题就在这里:

  public class sortmapper extends Mapper<LongWritable,Text,Text,DoubleWritable> {
        public void map(Text key, Iterable<DoubleWritable> value, Context      

Mapper<LongWritable,Text,Text,DoubleWritable>

对于映射器,输入键和值为:

LongWritable and Text

输出键和值为:

Text and DoubleWritable

您的map()签名应为:

public void map(LongWritable key, Text value, Context context)

相关内容

  • 没有找到相关文章

最新更新