title: HBase mapreduce job - Multiple scans - How to set the table of each Scan
body: <p>I use HBase 1.2. I would like to run a MapReduce job on HBase using multiple scans. In the API, there is : 
  <code>TableMapReduceUtil.initTableMapperJob(List&lt;Scan&gt; scans, Class&lt;? extends TableMapper&gt; mapper, Class&lt;?&gt; outputKeyClass, Class&lt;?&gt; outputValueClass, org.apache.hadoop.mapreduce.Job job)</code>.</p>
  
  <p>But how to specify the table of each scan ? I use the code below :</p>
  
  <pre><code>List&lt;Scan&gt; scans = new ArrayList&lt;&gt;();
  for (String firstPart : firstParts) {
      Scan scan = new Scan();
      scan.setRowPrefixFilter(Bytes.toBytes(firstPart));
      scan.setCaching(500);
      scan.setCacheBlocks(false);
      scans.add(scan);
  }
  TableMapReduceUtil.initTableMapperJob(scans, MyMapper.class, Text.class, Text.class, job);
  </code></pre>
  
  <p>It gives the following Exception</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
          at org.apache.hadoop.hbase.TableName.valueOf(TableName.java:436)
          at org.apache.hadoop.hbase.mapreduce.TableInputFormat.initialize(TableInputFormat.java:184)
          at org.apache.hadoop.hbase.mapreduce.TableInputFormatBase.getSplits(TableInputFormatBase.java:241)
          at org.apache.hadoop.hbase.mapreduce.TableInputFormat.getSplits(TableInputFormat.java:240)
          at org.apache.hadoop.mapreduce.lib.input.DelegatingInputFormat.getSplits(DelegatingInputFormat.java:115)
          at org.apache.hadoop.mapreduce.JobSubmitter.writeNewSplits(JobSubmitter.java:305)
          at org.apache.hadoop.mapreduce.JobSubmitter.writeSplits(JobSubmitter.java:322)
          at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:200)
          at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1307)
          at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1304)
          at java.security.AccessController.doPrivileged(Native Method)
          at javax.security.auth.Subject.doAs(Subject.java:422)
          at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1714)
          at org.apache.hadoop.mapreduce.Job.submit(Job.java:1304)
          at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1325)
  </code></pre>
  
  <p>I think it's normal since the tables on which each scan should be applied are not specified anywhere.</p>
  
  <p>But how to do it ?</p>
  
  <p>I tried to add</p>
  
  <pre><code>scan.setAttribute("scan.attributes.table.name", Bytes.toBytes("my_table"));
  </code></pre>
  
  <p>but it gives the same error</p>