Hadoop中java.lang.ClassCastException: partition解决方法
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的类型一致。