Database Reference
In-Depth Information
Job job = new Job(config, "Read Write from Customer Table");
job.setJarByClass(HBaseMRTest.class);
Scan scan = new Scan();
// 1 is the default in Scan
scan.setCaching(1000);
scan.setCacheBlocks(false);
// define input hbase table
TableMapReduceUtil.initTableMapperJob(
"tab1", // input table
scan, // Scan instance to control CF and attribute selection
HBaseTestMapper.class, // mapper class
Text.class, // mapper output key
IntWritable.class, // mapper output value
job);
// define output table
TableMapReduceUtil.initTableReducerJob(
"tab1Copy", // output table
HBaseTestReducer.class, // reducer class
job);
System.exit(job.waitForCompletion(true) ? 0 : 1);
} catch (Exception e) {
System.out.println("MR Execution Error");
System.exit(1);
}
}
}
Build the JAR ile and run the hadoop jar command for HBaseMRTestclass . This
will populate the data to the output HBase table, tab1copy . MapReduce can be used
with HBase for many use cases such as data import/export between the HBase table
and iles, data consolidation, and so on.
 
Search WWH ::




Custom Search