【Hadoop】请问如果我想把两个mapreduce程序顺序连接起来应该怎么写程序
即两个mapreduce程序实现不同的功能而mapreduce1的输出将要作为mapreduce2的输入跪谢!!!...
即两个mapreduce程序实现不同的功能 而mapreduce1的输出将要作为mapreduce2的输入 跪谢!!!
展开
1个回答
展开全部
你可以自己设置输入输出路径,所以设置就行了。。。
example:
JobConf conf1 = new JobConf(YourClass.class);
//set configurations
...
//set inputformat
conf1.setInputFormat(SomeInputFormatExtendsFromInputFormat.class)
conf1.setOutputFormat(SomeOutputFormatExtendsFromOutputFormat.class)
//set input path
FileInputFormat.setInputPaths(conf1, "/your_input_dir");
FileOutputFormat.setOutputPaths(conf1, "/your_first_output_dir");
JobClient.runJob(conf1);
//at this point, the job should have finished. Use submitJob(conf1) to submit it asynchronisely.
JobConf conf2 = new JobConf();
//do the same for conf2, except the input path
FileInputFormat.setInputPaths(conf1, "/your_first_output_dir");
FileOutputFormat.setOutputPaths(conf1, "/your_first_input_dir");
JobClient.runJob(conf);
自己继承InputFormat, OutputFormat来定义合适的分割,读,写文件方式。mapreduce有一些实现好的,比如FileInputFormat, SequenceFileInputFormat。必要的时候读一下源代码,就清楚了。hadoop mapreduce 的最基本的文档见http://hadoop.apache.org/common/docs/r1.0.3/mapred_tutorial.html
example:
JobConf conf1 = new JobConf(YourClass.class);
//set configurations
...
//set inputformat
conf1.setInputFormat(SomeInputFormatExtendsFromInputFormat.class)
conf1.setOutputFormat(SomeOutputFormatExtendsFromOutputFormat.class)
//set input path
FileInputFormat.setInputPaths(conf1, "/your_input_dir");
FileOutputFormat.setOutputPaths(conf1, "/your_first_output_dir");
JobClient.runJob(conf1);
//at this point, the job should have finished. Use submitJob(conf1) to submit it asynchronisely.
JobConf conf2 = new JobConf();
//do the same for conf2, except the input path
FileInputFormat.setInputPaths(conf1, "/your_first_output_dir");
FileOutputFormat.setOutputPaths(conf1, "/your_first_input_dir");
JobClient.runJob(conf);
自己继承InputFormat, OutputFormat来定义合适的分割,读,写文件方式。mapreduce有一些实现好的,比如FileInputFormat, SequenceFileInputFormat。必要的时候读一下源代码,就清楚了。hadoop mapreduce 的最基本的文档见http://hadoop.apache.org/common/docs/r1.0.3/mapred_tutorial.html
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询