如何在 Hbase MapReduce 作业中使用 table 提供命名空间
How to provide namespace with table in HbaseMapReduce Job
我正在使用 Hbase 创建一个 Map Reduce Jon。所以我从映射器作业中的 table 获取一些输入,然后我使用 Reducer 作业。调用 reducer Job 我正在使用这个函数。
TableMapReduceUtil.initTableReducerJob(table, reducer, job);
此处table为String类型。我的问题是我需要在这里使用带命名空间的 table,但我不知道该怎么做。
如果是映射器作业。 Api 正在为 NameSpace 提供功能,即
TableMapReduceUtil.initTableMapperJob(table, scan, mapper, outputKeyClass, outputValueClass, job);
此处 table 的类型为 org.apache.hadoop.hbase.TableName。
那么谁能告诉我如何在 reducer 工作中做到这一点?
我猜你想使用 mapreduce 作业来读取你的 hbase table 并将一些数据写入 hdfs?如果是这样
看这里
void org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil.initTableMapperJob
(String table, Scan scan, Class<? extends TableMapper> mapper,
Class<?> outputKeyClass,
Class<?> outputValueClass, Job job, boolean addDependencyJars) throws IOException
此方法可以在设置中添加您的工作 (org.apache.hadoop.mapreduce.Job;
)。
job.setJarByClass(MapReduceReaderHbaseDriver.class);
job.setReducerClass(WordCountHBaseReducer.class);
FileOutputFormat.setOutputPath(job, new Path("hdfspath"));
使用这些方法可以使 reducer 连接到 hdfs
顺便说一句,从一个 hbase table 转换为另一个 hbase table 你可以使用导入或导出命令
例如
(1)old cluster:./hbase org.apache.hadoop.hbase.mapreduce.Export test hdfs://new cluster ip:9000/dic/test
(2)new cluster:./hbase org.apache.hadoop.hbase.mapreduce.Import test hdfs://new cluster ip:9000/dic/test
所以,我只需要提供 table 名称作为
命名空间:table名称
它会在内部处理。
我正在使用 Hbase 创建一个 Map Reduce Jon。所以我从映射器作业中的 table 获取一些输入,然后我使用 Reducer 作业。调用 reducer Job 我正在使用这个函数。
TableMapReduceUtil.initTableReducerJob(table, reducer, job);
此处table为String类型。我的问题是我需要在这里使用带命名空间的 table,但我不知道该怎么做。
如果是映射器作业。 Api 正在为 NameSpace 提供功能,即
TableMapReduceUtil.initTableMapperJob(table, scan, mapper, outputKeyClass, outputValueClass, job);
此处 table 的类型为 org.apache.hadoop.hbase.TableName。
那么谁能告诉我如何在 reducer 工作中做到这一点?
我猜你想使用 mapreduce 作业来读取你的 hbase table 并将一些数据写入 hdfs?如果是这样 看这里
void org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil.initTableMapperJob
(String table, Scan scan, Class<? extends TableMapper> mapper,
Class<?> outputKeyClass,
Class<?> outputValueClass, Job job, boolean addDependencyJars) throws IOException
此方法可以在设置中添加您的工作 (org.apache.hadoop.mapreduce.Job;
)。
job.setJarByClass(MapReduceReaderHbaseDriver.class);
job.setReducerClass(WordCountHBaseReducer.class);
FileOutputFormat.setOutputPath(job, new Path("hdfspath"));
使用这些方法可以使 reducer 连接到 hdfs
顺便说一句,从一个 hbase table 转换为另一个 hbase table 你可以使用导入或导出命令
例如
(1)old cluster:./hbase org.apache.hadoop.hbase.mapreduce.Export test hdfs://new cluster ip:9000/dic/test
(2)new cluster:./hbase org.apache.hadoop.hbase.mapreduce.Import test hdfs://new cluster ip:9000/dic/test
所以,我只需要提供 table 名称作为
命名空间:table名称
它会在内部处理。