title: Hadoop - composite key
body: <p>Suppose I have a tab delimited file containing user activity data formatted like this:</p>
  
  <pre><code>timestamp  user_id  page_id  action_id
  </code></pre>
  
  <p>I want to write a hadoop job to count user actions on each page, so the output file should look like this:</p>
  
  <pre><code>user_id  page_id  number_of_actions
  </code></pre>
  
  <p>I need something like composite key here - it would contain user_id and page_id. Is there any generic way to do this with hadoop? I couldn't find anything helpful. So far I'm emitting key like this in mapper:</p>
  
  <pre><code>context.write(new Text(user_id + "\t" + page_id), one);
  </code></pre>
  
  <p>It works, but I feel that it's not the best solution.</p>