a876147882
TTLGain
采纳率100%
2019-03-25 17:03

hbase中的 TableScanMR 使用方法是什么?

5
已采纳

之前看网上的大佬说:“HBase中Scan从大的层面来看主要有三种常见用法:ScanAPI、TableScanMR以及SnapshotScanMR。”但是我想知道TableScanMR和SnapshotScanMR 是怎么实现的呢?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

3条回答

  • a876147882 TTLGain 2年前
    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!");
    }
    
    点赞 评论 复制链接分享
  • qq_38707216 无疑是最好的选择 9月前

    怎么使用tableScanMr ?????在代码里面 Scan scan = new Scan(); 然后设置参数嘛

    点赞 评论 复制链接分享
  • dabocaiqq dabocaiqq 2年前