我正在使用java类而不是命令hadoop jar / input / output运行hadoop作业。
在这种情况下,我的命令如下所示。 hadoop jar Main.class /输入/位置/输出/位置/ thirdargument /文件。
我知道如何在Main的Driver类中添加输入路径和输出路径,但是如何添加输入所依赖的第三个参数以获取输出。
以下是我添加输入和输出路径的方式。
请帮助添加第三个参数。
FileInputFormat.addInputPath(job, new Path("/path1/")); //inputpath
FileOutputFormat.setOutputPath(job, new Path("/path2/")); //outputpath
第三论点加法?
最佳答案
我不知道是否可以通过添加其他路径来获取第三个文件,但是您可以使用,
try{
Path pt=new Path("hdfs://npvm11.np.wc1.yellowpages.com:9000/user/john/abc.txt");
FileSystem fs = FileSystem.get(new Configuration());
BufferedReader br=new BufferedReader(new InputStreamReader(fs.open(pt)));
String line;
line=br.readLine();
while (line != null){
System.out.println(line);
line=br.readLine();
}
}catch(Exception e){
}
我是从https://sites.google.com/site/hadoopandhive/home/hadoop-how-to-read-a-file-from-hdfs获得的
关于hadoop - 我如何在hadoop工作中通过Third Argument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25668245/