我正在尝试在我的 hadoop 作业的主要方法中读取一个文件。不在映射器或 reducer 中。 我正在使用带有自定义 JAR 的 EMR Amazon
The command line is arguments: -files s3://[path]#source.xml
在我正在做的主要功能中:
File file = new File("source.xml")
我不知道分布式缓存是在主函数上可用还是仅在映射器/缩减器函数中可用。我需要使用 DistributedCache API 吗?
AWS 正在执行的行代码:
hadoop jar /mnt/var/lib/hadoop/steps/s-1YBXTPYJ2YK44/JobTeste_SomenteLeitura.jar -files s3://stoneagebrasil/TesteBVS/sources.xml
如何做到这一点?
最佳答案
尝试,
FileSystem fs = FileSystem.get(configuration);
Path path = new Path("test.txt");
读取文件,
BufferedReader br = new BufferedReader(new InputStreamReader(
fs.open(path)));
String line;
line = br.readLine();
while (line != null) {
System.out.println(line);
line = br.readLine();
}
关于java - 在主函数中读取文件 - Hadoop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31947810/