如何使用MapReduce查询HBase数据?
嗨,我是MapReduce和HBase的新手。请导游。我正在使用MapReduce将表格数据移动到HBase。现在数据在HBase中访问(在HDFS中也是如此)。我已经创建了mapreduce作业,它将从文件中读取表格数据,并使用Hbase API将其放入Hbase 现在我的疑问是,我能否使用MapReduce查询HBase数据?我不想执行HBase命令来查询数据。是否可以使用MapReduce查询HBase的数据如何使用MapReduce查询HBase数据?,mapreduce,hbase,Mapreduce,Hbase,嗨,我是MapReduce和HBase的新手。请导游。我正在使用MapReduce将表格数据移动到HBase。现在数据在HBase中访问(在HDFS中也是如此)。我已经创建了mapreduce作业,它将从文件中读取表格数据,并使用Hbase API将其放入Hbase 现在我的疑问是,我能否使用MapReduce查询HBase数据?我不想执行HBase命令来查询数据。是否可以使用MapReduce查询HBase的数据 请提供帮助或建议。当然可以,HBase附带的帮助您配置MapReduce作业以扫
请提供帮助或建议。当然可以,HBase附带的帮助您配置MapReduce作业以扫描数据。它将自动为每个区域创建一个地图任务 请检查此示例:
Configuration config = HBaseConfiguration.create();
Job job = new Job(config, "ExampleRead");
job.setJarByClass(MyReadJob.class); // class that contains mapper
Scan scan = new Scan();
scan.setCaching(500); // 1 is the default in Scan, which will be bad for MapReduce jobs
scan.setCacheBlocks(false); // don't set to true for MR jobs
// set other scan attrs
...
TableMapReduceUtil.initTableMapperJob(
tableName, // input HBase table name
scan, // Scan instance to control CF and attribute selection
MyMapper.class, // mapper
null, // mapper output key
null, // mapper output value
job);
job.setOutputFormatClass(NullOutputFormat.class); // because we aren't emitting anything from mapper
boolean b = job.waitForCompletion(true);
if (!b) {
throw new IOException("error with job!");
}