Hadoop中java.lang.ClassCastException: partition解決方法

weixin_30639719發表於2020-04-05

java.lang.ClassCastException: partition.KpiWritable cannot be cast to org.apache.hadoop.io.LongWritable

at partition.KpiApp$MyPartition.getPartition(KpiApp.java:1)

at org.apache.hadoop.mapred.MapTask$NewOutputCollector.write(MapTask.java:691)

at org.apache.hadoop.mapreduce.TaskInputOutputContext.write(TaskInputOutputContext.java:80)

at partition.KpiApp$MyMapper.map(KpiApp.java:102)

at partition.KpiApp$MyMapper.map(KpiApp.java:1)

at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:144)

at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764)

at org.apache.hadoop.mapred.MapTask.run(MapTask.java:370)

at org.apache.hadoop.mapred.Child$4.run(Child.java:255)

at java.security.AccessController.doPrivileged(Native Method)

at javax.security.auth.Subject.doAs(Subject.java:396)

at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInforma

型別轉換錯誤,由於自定義的Partitioner類繼承HashPartitioner泛型中型別寫錯,該型別是跟K2,V2的型別一致。

轉載於:https://www.cnblogs.com/luguoyuanf/p/3594461.html

相關文章