You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by Arindam Khaled <ak...@msstate.edu> on 2010/11/15 22:50:52 UTC

wrong value class error

Hello,

I am new to Hadoop. I am getting the following error in my reducer.

10/11/15 15:29:11 WARN mapred.LocalJobRunner: job_local_0001
java.io.IOException: wrong value class: class org.apache.hadoop.io.Text is
not class org.apache.hadoop.io.IntWritable

Here is my reduce class:

 public static class BFIDAReducer
       extends Reducer<Text,IntWritable,Text,Text> {
    private Text result = new Text();

    public void reduce(Text key, Iterable<IntWritable> values,
                       Context context
                       ) throws IOException, InterruptedException {
      Text result = new Text();
      GameFunctions gf = GameFunctions.getInstance();


      String line = "";

      for(IntWritable val: values)
        {
            line = line + val.toString() + ",";
        }

        if(line.length() > 1)
            line = (String) line.subSequence(0, line.length() - 1);

    if (gf.isSolved(key.toString(), size))
            solved = true;

      result.set(line);
      context.write(key, result);
    }
  }

And here is my partial code from job configuration:

    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(Text.class);
    job.setMapOutputKeyClass(Text.class);
    job.setMapOutputValueClass(IntWritable.class);

Can anyone help me?

Thanks in advance.

Arindam

Re: wrong value class error

Posted by Alex Baranau <al...@gmail.com>.
The message refers to the value not being an IntWritable, which is an
*input* value type of your reducer (and the output value type of your
mapper). Looks like you have a problem with mapper, not reducer.

Alex Baranau
----
Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch - Hadoop - HBase

On Mon, Nov 15, 2010 at 11:50 PM, Arindam Khaled <ak...@msstate.edu> wrote:

> Hello,
>
> I am new to Hadoop. I am getting the following error in my reducer.
>
> 10/11/15 15:29:11 WARN mapred.LocalJobRunner: job_local_0001
> java.io.IOException: wrong value class: class org.apache.hadoop.io.Text is
> not class org.apache.hadoop.io.IntWritable
>
> Here is my reduce class:
>
>  public static class BFIDAReducer
>       extends Reducer<Text,IntWritable,Text,Text> {
>    private Text result = new Text();
>
>    public void reduce(Text key, Iterable<IntWritable> values,
>                       Context context
>                       ) throws IOException, InterruptedException {
>      Text result = new Text();
>      GameFunctions gf = GameFunctions.getInstance();
>
>
>      String line = "";
>
>      for(IntWritable val: values)
>        {
>            line = line + val.toString() + ",";
>        }
>
>        if(line.length() > 1)
>            line = (String) line.subSequence(0, line.length() - 1);
>
>    if (gf.isSolved(key.toString(), size))
>            solved = true;
>
>      result.set(line);
>      context.write(key, result);
>    }
>  }
>
> And here is my partial code from job configuration:
>
>    job.setOutputKeyClass(Text.class);
>    job.setOutputValueClass(Text.class);
>    job.setMapOutputKeyClass(Text.class);
>    job.setMapOutputValueClass(IntWritable.class);
>
> Can anyone help me?
>
> Thanks in advance.
>
> Arindam
>