Hadoop: LongWritable ne peut pas être lancé pour org.apache.hadoop.io.IntWritable
Je veux prendre une valeur moyenne d'une température donnée dans un fichier d'entrée et mon Mappeur et Réducteur synatax semble très bien pour moi, mais je reçois toujours le message d'erreur suivant:
Unable to load realm info from SCDynamicStore
13/02/17 08:03:28 INFO mapred.JobClient: Task Id : attempt_201302170552_0009_m_000000_1, Status : FAILED
java.lang.ClassCastException: org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.IntWritable
at org.apache.hadoop.examples.TempMeasurement$TempMapper.map(TempMeasurement.java:26)
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(UserGroupInformation.java:1121)
at org.apache.hadoop.mapred.Child.main(Child.java:249)
Mon Mapper la fonction est: est-ce
public static class TempMapper extends Mapper<IntWritable, Text, IntWritable, FloatWritable>{
@Override
protected void map(IntWritable key, Text value, Context context)
throws IOException, InterruptedException {
//code for getting date and temperature
String temp = columns.get(3);
context.write(new IntWritable(year), new FloatWritable(Float.valueOf(temp)));
}
}
Et de Réduire l'est:
public static class IntSumReducer
extends Reducer<IntWritable, FloatWritable, IntWritable ,FloatWritable> {
private FloatWritable result = new FloatWritable();
public void reduce(IntWritable key, Iterable<FloatWritable> values,
Context context
) throws IOException, InterruptedException {
//code for making calculations
context.write(key, result);
}
}
Fichier d'entrée est:
11111 , 0,19900101, 44.04 ,
11112, 0, 19900102, 50.00,
11113, 3, 19910203, 30.00,
Toute aide serait appréciée
OriginalL'auteur Junaid | 2013-02-17
Vous devez vous connecter pour publier un commentaire.
La touche de classe à un mappeur qui mappe les fichiers texte est toujours
LongWritable
. C'est parce qu'elle contient l'offset d'octet de la ligne en cours et on pourrait facilement le dépassement d'un nombre entier.Fondamentalement, vous avez besoin de modifier votre code:
OriginalL'auteur Thomas Jungblut