title: Hadoop (java) change the type of Mapper output values
body: <p>I am writing a mapper function that generates  the keys as some user_id and the values are also Text type. Here is how I do this</p>
  
  <pre><code>public static class UserMapper extends Mapper&lt;Object, Text, Text, IntWritable&gt; {
      private final static IntWritable one = new IntWritable(1);
      private Text userid = new Text();
      private Text catid = new Text();
  
      /* map method */
      public void map(Object key, Text value, Context context)
                  throws IOException, InterruptedException {
          StringTokenizer itr = new StringTokenizer(value.toString(), ","); /* separated by "," */
          int count = 0;
  
          userid.set(itr.nextToken());
  
          while (itr.hasMoreTokens()) {
              if (++count == 3) {
                  catid.set(itr.nextToken());
                  context.write(userid, catid);
              }else {
                  itr.nextToken();
              }
          }
      }
  }
  </code></pre>
  
  <p>And then, in the main program, I set the output class of the mapper as follows:</p>
  
  <pre><code>    Job job = new Job(conf, "Customer Analyzer");
      job.setJarByClass(popularCategories.class);
      job.setMapperClass(UserMapper.class);
      job.setCombinerClass(UserReducer.class);
      job.setReducerClass(UserReducer.class);
  
      job.setMapOutputKeyClass(Text.class);
      job.setMapOutputValueClass(Text.class);
  </code></pre>
  
  <p>So even though I have set the class of the output values to be of <strong>Text.class</strong>, still I get the following error when compile it:</p>
  
  <pre><code>popularCategories.java:39: write(org.apache.hadoop.io.Text,org.apache.hadoop.io.IntWritable)
   in org.apache.hadoop.mapreduce.TaskInputOutputContext&lt;java.lang.Object,
   org.apache.hadoop.io.Text,org.apache.hadoop.io.Text,
   org.apache.hadoop.io.IntWritable&gt; 
   cannot be applied to (org.apache.hadoop.io.Text,org.apache.hadoop.io.Text)
   context.write(userid, catid);
                             ^
  </code></pre>
  
  <p>According to this error, it is still considering a mapper class of this format: <code>write(org.apache.hadoop.io.Text,org.apache.hadoop.io.IntWritable)</code></p>
  
  <p>So, when I change the class definition as follows, the problem is solved. </p>
  
  <pre><code> public static class UserMapper extends Mapper&lt;Object, Text, Text, Text&gt; {
  
   }
  </code></pre>
  
  <p>So, I want to understand what is the difference between the class definition and setting the mapper output vaue class.</p>