/** * Configures the job with an HBase scan over a table as input. */ public static void initTableInput(String table, Scan scan, Job job) throws IOException { job.getConfiguration().set(TableInputFormat.INPUT_TABLE, table); initTableScan(scan, job); }
/** * Configures HTable input for the job if the mapper is an HTableReader. * * <p>If the mapper the job is configured to run is reading from an HBase table * (HTable), this method will make sure the mapper implements the HTableReader interface * and use its methods to configure the table scan specification required for the * HTableInputFormat.</p> * * <p>A mapper that reads its input from an HTable needs to specify the Scan descriptor * that describes what subset of rows and column cells should be processed. The mapper * communicates this by implementing the methods of the HTableReader interface. This * method calls the methods of that interface on the job's mapper and sets Scan * descriptor into the job configuration so the HTableInputFormat can read it.</p> * * @param job The job to configure. * @param mapper The Fiji mapper the job is configured to run. * @throws IOException If the HTable input cannot be configured. */ protected void configureHTableInput(Job job, FijiMapper<?, ?, ?, ?> mapper) throws IOException { if (mapper instanceof HTableReader) { HTableReader htableReader = (HTableReader) mapper; Scan hbaseInputTableScan = htableReader.getInputHTableScan(job.getConfiguration()); if (null == hbaseInputTableScan) { return; } LOG.debug("Configuring HTable scan: " + hbaseInputTableScan.toString()); GenericTableMapReduceUtil.initTableScan(hbaseInputTableScan, job); } }