HBase0.94.5中加入了这个功能。org.apache.hadoop.hbase.mapreduce 包中有一个MultiTableInputFormat类,可以转换多个scan中的数据,然后供MapReduce中mapper或者reducer使用。
用法如下:
List scans = new ArrayList();
Scan scan1 = new Scan();
scan1.setStartRow(firstRow1);
scan1.setStopRow(lastRow1);
scan1.setAttribute(Scan.SCAN_ATTRIBUTES_TABLE_NAME, table1);
scans.add(scan1);
Scan scan2 = new Scan();
scan2.setStartRow(firstRow2);
scan2.setStopRow(lastRow2);
scan1.setAttribute(Scan.SCAN_ATTRIBUTES_TABLE_NAME, table2);
scans.add(scan2);
TableMapReduceUtil.initTableMapperJob(scans, TableMapper.class, Text.class, IntWritable.class, job);
jira中添加此功能的讨论链接:https://issues.apache.org/jira/browse/HBASE-3996