HADOOP - невозможно инициализировать MapOutputCollector org.apache.hadoop.mapred.MapTask $ MapOutputBuffer java.lang.ClassCastException: класс java.lang.Double - PullRequest
1 голос
/ 31 октября 2019

У меня проблема с моим кодом, это моя ошибка:

Невозможно инициализировать MapOutputCollector org.apache.hadoop.mapred.MapTask $ MapOutputBuffer java.lang.ClassCastException: класс java.lang.Двойной

Я не знаю откуда. это мой код класса, где я настраиваю всю работу:

        conf.set("stripped", stripped);

        /* Creating the job object for the Hadoop processing */  
        @SuppressWarnings("deprecation")
        Job job = new Job(conf, "calculate error map reduce"); 

        /* Creating Filesystem object with the configuration */  
        FileSystem fs = FileSystem.get(conf);  

        /* Check if output path (args[1])exist or not */  
        if (fs.exists(new Path(output))) {  
            /* If exist delete the output path */  
            fs.delete(new Path(output), true);  
        }
        // Setting Driver class  
        job.setJarByClass(StrippedPartition.class);  

        // Setting the Mapper class  
        job.setMapperClass(MapperCalculateError.class);  

        // Setting the Reducer class  
        job.setReducerClass(ReduceCalculateError.class);  

        // Setting the Output Key class per il mapper 
        job.setOutputKeyClass(Double.class);  
        // Setting the Output value class per il mapper
        job.setOutputValueClass(DoubleWritable.class); 

это мой класс картографа:

    public static class MapperCalculateError extends Mapper<Object, Text, Double, DoubleWritable>{

        private final static DoubleWritable error1 = new DoubleWritable(1.0);
        private double error,max;
        private ObjectBigArrayBigList<LongBigArrayBigList> Contain = new ObjectBigArrayBigList<LongBigArrayBigList>();
        private ObjectBigArrayBigList<LongBigArrayBigList> Stripped = new ObjectBigArrayBigList<LongBigArrayBigList>();


        public void map(Object key, Text value, Context context) throws IOException, InterruptedException {

            Configuration conf = context.getConfiguration();
            String stripped = conf.get("stripped");
            Stripped = new Gson().fromJson(stripped.toString(), ObjectBigArrayBigList.class);



            StringTokenizer itr = new StringTokenizer(value.toString());
            Contain = new Gson().fromJson(value.toString(), ObjectBigArrayBigList.class);

            //stuff in map function, i avoid in this exeple because is not important    
            }
            context.write(max,error1);

        }

, а это мой класс сокращения:


    public static class ReduceCalculateError extends Reducer<Double, DoubleWritable, Double, Double>{

        private double massimo=0;
        private double errore=0;

        //public ReduceCalculateError() {} 

        public void reduce(double max, Iterable<DoubleWritable> error, Context context)  throws IOException, InterruptedException {
            Configuration conf = context.getConfiguration();
            double sum=0;


            //other stuff that i avoid 

            context.write(this.massimo,sum);


        }

Я не знаю, где ошибка, карта и уменьшение никогда не запускаются, потому что это покажет мне карту: 0% уменьшение: 0%

1 Ответ

0 голосов
/ 01 ноября 2019

Везде, где у вас есть Double, вам нужно использовать DoubleWritable. Это потому, что Hadoop не знает, как сериализовать Double, но знает, как сериализовать DoubleWritable.

Каждый раз, когда вы делаете context.write(...), вам нужно убедиться, что оба аргумента Writable. Например, ваша карта выводит context.write(max,error1);, но max это Double, тогда как это должно быть DoubleWritable.

...