Hadoop Throws ClassCastException for the keytype of java.nio.ByteBuffer Hadoop Throws ClassCastException for the keytype of java.nio.ByteBuffer hadoop hadoop

Hadoop Throws ClassCastException for the keytype of java.nio.ByteBuffer


This is where the exception is being thrown. Here is the code from SVN.

public RawComparator getOutputKeyComparator() {    Class<? extends RawComparator> theClass = getClass("mapred.output.key.comparator.class",        null, RawComparator.class);    if (theClass != null)        return ReflectionUtils.newInstance(theClass, this);    return WritableComparator.get(getMapOutputKeyClass().asSubclass(WritableComparable.class));}

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.