我想使用hadoop计算两个点之间的距离并按键对它们的结果顺序进行排序,当运行hadoop jar knn.jar input output时,出现如下错误:

13/11/28 15:35:38 INFO mapred.JobClient: Task Id : attempt_2013
10221205_0036_m_000000_0, Status : FAILED
java.io.IOException: Type mismatch in key from map: expected or
g.apache.hadoop.io.Text, recieved org.apache.hadoop.io.DoubleWr
itable
        at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.col
lect(MapTask.java:1019)
        at org.apache.hadoop.mapred.MapTask$NewOutputCollector.
write(MapTask.java:690)
        at org.apache.hadoop.mapreduce.TaskInputOutputContext.w
rite(TaskInputOutputContext.java:80)
        at xautjzd.knn.hadoop.apache.KNN$KNNMapper.map(KNN.java
:35)
        at xautjzd.knn.hadoop.apache.KNN$KNNMapper.map(KNN.java
:1)
        at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:1
45)
        at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTas
k.java:764)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:36
4)
        at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
        at java.security.AccessController.doPrivileged(Native M
ethod)
        at javax.security.auth.Subject.doAs(Subject.java:415)
        at org.apache.hadoop.security.UserGroupInformation.doAs
(UserGroupInformation.java:1190)
        at org.apache.hadoop.mapred.Child.main(Child.java:249)

我的代码:

最佳答案

好像您已经将conf.setOutputKeyClass(Text.class)设置为conf.setOutputKeyClass(DoubleWrtable.class)一样

08-26 23:09
查看更多