title: Mapper input Key-Value pair in Hadoop
body: <p>Normally, we write the mapper in the form : </p>
  
  <pre><code>public static class Map extends Mapper&lt;**LongWritable**, Text, Text, IntWritable&gt;
  </code></pre>
  
  <p>Here the input key-value pair for the mapper is <code>&lt;LongWritable, Text&gt;</code> - as far as I know when the mapper gets the input data its goes through line by line - so the Key for the mapper signifies the line number - please correct me if I am wrong.</p>
  
  <p>My question is : If I give the input key-value pair for mapper as <code>&lt;Text, Text&gt;</code> then it is giving the error  </p>
  
  <pre><code> java.lang.ClassCastException: org.apache.hadoop.io.LongWritable cannot be cast to org.apache.hadoop.io.Text
  </code></pre>
  
  <p>Is it a mandatory to give the input key-value pair of mapper as <code>&lt;LongWritable, Text&gt;</code> - if yes then why ? if no then what the reason of the error ? Can you please help me understand the proper reasoning of the error ?</p>
  
  <p>Thanks in advance.</p>