hadoop MR从hbase中读取数据写入到hbase中
来源:互联网 发布:带着淘宝去异界 编辑:程序博客网 时间:2024/06/05 07:59
hadoop MR从hbase中读取数据写入到hbase中的配置
public class WordCount { private static final Logger LOGGER= LoggerFactory.getLogger(WordCount.class); static class HbaseMapper extends TableMapper<ImmutableBytesWritable,Put>{ @Override protected void map(ImmutableBytesWritable row, Result result, Context context) throws IOException, InterruptedException { byte[] b = row.get(); String keys = Bytes.toString(b); byte[] value=result.getValue(Bytes.toBytes(Constants.COLUMN_FAMILY),Bytes.toBytes("f1")); LOGGER.info("------keys---::::"+keys); LOGGER.info("------values---::::"+Bytes.toString(value)); context.write(row, resultToPut(row,result)); } private static Put resultToPut(ImmutableBytesWritable key, Result result) throws IOException { Put put = new Put(key.get()); for (KeyValue kv : result.raw()) { put.add(kv); } return put; } } public static void main(String[] args) throws Exception { Configuration config = HBaseConfiguration.create(); Job job = Job.getInstance(config,"mytest"); job.setJarByClass(WordCount.class); // class that contains mapper Scan scan = new Scan(); //rpc请求的记录数 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 TableMapReduceUtil.initTableMapperJob( Constants.TableName.TEST, // input HBase table name scan, // Scan instance to control CF and attribute selection HbaseMapper.class, // mapper null, // mapper output key null, // mapper output value job); TableMapReduceUtil.initTableReducerJob( Constants.TableName.RECEIVE, // output table null, // reducer class job); job.setNumReduceTasks(0); System.exit(job.waitForCompletion(true) ? 0 : 1); }}
hadoop MR从hbase中读取数据写入到hbase中的配置
0 0
- hadoop MR从hbase中读取数据写入到hbase中
- 从hbase表1中读取数据,最终结果写入到hbase表2 ,如何通过MapReduce实现 ?
- mr任务之从多个Hbase表中读取数据进行处理
- mr任务之从多个Hbase表中读取数据进行处理
- 利用MR程序将数据从hbase中导入mysql
- HBase建表高级属性,hbase应用案例看行键设计,HBase和mapreduce结合,从Hbase中读取数据、分析,写入hdfs,从hdfs中读取数据写入Hbase,协处理器和二级索引
- 从hdfs中读取文件到hbase
- spark将数据写入hbase以及从hbase读取数据
- park将数据写入hbase以及从hbase读取数据
- spark将数据写入hbase以及从hbase读取数据
- Spark将数据写入Hbase以及从Hbase读取数据
- 从hdfs读取数据写入hbase
- hbase 下mapreduce 读取hbase中数据
- MR之wc数据写入Hbase
- 【hbase】bulkload数据到hbase表中
- 【hbase】bulkload数据到hbase表中
- [cloudera hadoop]用sqoop将数据从mysql迁移到hbase中出现的错误
- MapReduce 中如何处理HBase中的数据?如何读取HBase数据给Map?如何将结果存储到HBase中?
- #575 – PropertyMetadata 和其子类的区别(PropertyMetadata vs. FrameworkPropertyMetadata)
- UVA 1339 Ancient Cipher
- 从1至N中找出所有不重复加在一起等于N的数组
- Laravel框架路由配置总结、设置技巧大全
- 第十六周项目一 验证算法——归并排序
- hadoop MR从hbase中读取数据写入到hbase中
- C语言的指针
- Java源码分析之CountDownLatch
- 答题平台对接接口说明示例2017
- poj 3414 Pots
- Service是否在mainThread中执行,service里面是否能执行耗时操作
- configure: error: APR not found . Please read the documentation
- deque的简单用法
- SSD: Single Shot MultiBox Detector检测单张图片