Hadoop 为 java.nio.ByteBuffer 的 keytype 抛出 ClassCastException
我使用“hadoop-0.20.203.0rc1.tar.gz”进行集群设置。 每当我设置 job.setMapOutputKeyClass(ByteBuffer.class);
并运行作业时,我都会收到以下异常:
12/01/13 15:09:00 INFO mapred.JobClient: Task Id : attempt_201201131428_0005_m_000001_2, Status : FAILED
java.lang.ClassCastException: class java.nio.ByteBuffer
at java.lang.Class.asSubclass(Class.java:3018)
at org.apache.hadoop.mapred.JobConf.getOutputKeyComparator(JobConf.java:776)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.<init>(MapTask.java:958)
at org.apache.hadoop.mapred.MapTask$NewOutputCollector.<init>(MapTask.java:673)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:755)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:369)
at org.apache.hadoop.mapred.Child$4.run(Child.java:259)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1059)
at org.apache.hadoop.mapred.Child.main(Child.java:253)
我还注意到 ByteBuffer 是可比较的而不是可写的,这有什么区别吗? 如果需要任何其他信息,请告诉我。
I am using "hadoop-0.20.203.0rc1.tar.gz" for my cluster setup.
Whenever I set job.setMapOutputKeyClass(ByteBuffer.class);
and run the job I get following Exception:
12/01/13 15:09:00 INFO mapred.JobClient: Task Id : attempt_201201131428_0005_m_000001_2, Status : FAILED
java.lang.ClassCastException: class java.nio.ByteBuffer
at java.lang.Class.asSubclass(Class.java:3018)
at org.apache.hadoop.mapred.JobConf.getOutputKeyComparator(JobConf.java:776)
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.<init>(MapTask.java:958)
at org.apache.hadoop.mapred.MapTask$NewOutputCollector.<init>(MapTask.java:673)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:755)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:369)
at org.apache.hadoop.mapred.Child$4.run(Child.java:259)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1059)
at org.apache.hadoop.mapred.Child.main(Child.java:253)
Also i have noticed that ByteBuffer is Comparable and not Writable is that make any diffrence?
Let me know if any additional information needed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是抛出异常的地方。这是代码。
如果 JobConf 上未定义 mapred.output.key.comparator.class 属性,则该键必须实现 WritableComparable 接口。 ByteBuffer 类没有实现 WritableComparable 接口,因此出现异常。
顺便说一句,WritableComparable 接口是 Writable 和 Comparable 类的子接口。
This is where the exception is being thrown. Here is the code from SVN.
If
mapred.output.key.comparator.class
property is not defined on JobConf then the key must implement the WritableComparable interface. ByteBuffer class doesn't implement the WritableComparable interface, so the exception.BTW, WritableComparable interface is sub-interface of Writable and Comparable classes.