2012-01-13 7 views
5

Estoy utilizando "hadoop-0.20.203.0rc1.tar.gz" para la configuración de mi clúster. Cada vez que me puse job.setMapOutputKeyClass(ByteBuffer.class);Hadoop lanza ClassCastException para el tipo de clave de java.nio.ByteBuffer

y ejecutar el trabajo consigo siguiente excepción:

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) 

También he notado que ByteBuffer es comparable y no se puede escribir es que hacer ningún diffrence? Avíseme si necesita información adicional.

Respuesta

5

Aquí es donde se lanza la excepción. Aquí está el code de 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)); 
} 

Si mapred.output.key.comparator.class propiedad no está definida en JobConf continuación, la tecla debe implementar la interfaz WritableComparable. La clase ByteBuffer no implementa la interfaz WritableComparable, por lo que es la excepción.

BTW, WritableComparable interfaz es sub-interfaz de clases escribibles y comparables.

+0

Será útil si puede elaborar cómo configurar esto para ByteBuffer .... – samarth

+0

@samarth Puede ajustar la matriz de bytes en org.apache.hadoop.io.BytesWritable en su lugar –

Cuestiones relacionadas