Mas*_*eek 1 java postgresql hadoop mapreduce
我遇到的问题是hadoop jar命令需要一个输入路径,但我的MapReduce作业从数据库获取其输入,因此不需要/有一个输入目录.我已将JobConf输入格式设置为DBInputFormat,但是如何在激活我的工作时表示这一点?
//Here is the command
hadoop jar <my-jar> <hdfs input> <hdfs output>
Run Code Online (Sandbox Code Playgroud)
我有一个输出文件夹,但不需要输入文件夹.有没有办法规避这个?我是否需要编写第二个程序将DB数据拉入文件夹,然后在MapReduce作业中使用它?
hadoop jar命令不需要命令行参数,除了主类之外.map/reduce作业的命令行参数将由程序本身决定.因此,如果它不再需要HDFS输入路径,那么您需要将代码更改为不需要.
public class MyJob extends Configured implements Tool
{
public void run(String[] args) throws Exception {
// ...
TextInputFormat.setInputPaths(job, new Path(args[0])); // or some other file input format
TextOutputFormat.setOutputPath(job, new Path(args[1]));
}
}
Run Code Online (Sandbox Code Playgroud)
所以你会删除输入路径语句.JAR的工作没有任何魔力,只需更改InputFormat(你说你做过),你应该设置好.
归档时间: |
|
查看次数: |
821 次 |
最近记录: |