java—将mapreduce作业输出到标准输出,而不是本地文件

x3naxklr  于 2021-05-29  发布在  Hadoop
关注(0)|答案(0)|浏览(239)

我希望通过不指定outputdir(即本地输出文件)来运行hbase导出,而是将导出作业输出直接流式传输到远程主机,以避免本地临时存储。

  1. String tableName = args[0];
  2. **Path outputDir = new Path(args[1]);**
  3. Job job = new Job(conf, "export" + "_" + tableName);
  4. job.setJobName(NAME + "_" + tableName);
  5. job.setJarByClass(Exporter.class);
  6. // Set optional scan parameters
  7. Scan s = getConfiguredScanForJob(conf, args);
  8. TableMapReduceUtil.initTableMapperJob(tableName, s, Exporter.class, null,
  9. null, job);
  10. // No reducers. Just write straight to output files.
  11. job.setNumReduceTasks(0);
  12. job.setOutputFormatClass(SequenceFileOutputFormat.class);
  13. job.setOutputKeyClass(ImmutableBytesWritable.class);
  14. job.setOutputValueClass(Result.class);
  15. FileOutputFormat.setOutputPath(job, outputDir);
  16. job.waitForCompletion(true);

有些帖子提到我们可以覆盖formatclass的getrecordwriter()方法,但我不明白。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题