gpt4 book ai didi

url - 如何调用包中已有的输入文件

转载 作者:可可西里 更新时间:2023-11-01 16:21:03 26 4
gpt4 key购买 nike

在我的 Hadoop Map Reduce 应用程序中,我有一个输入文件。我希望当我执行我的应用程序的 jar 时,输入文件将自动被调用。为此,我编写了一个类来指定输入、输出和文件本身,但从我调用文件的地方,我想指定文件路径。为此,我使用了这段代码:

 QueriesTest.class.getResourceAsStream("/src/main/resources/test") 
but it is not working (cannot read the input file from the generated jar)

所以我用过这个

URL url = this.getClass().getResource("/src/main/resources/test") here I am getting the problem of URL. So please help me out. I am using Hadoop 0.21.

最佳答案

我不确定您想通过资源加载告诉我们什么,但添加输入文件的常用方法是这样的:

Configuration conf = new Configuration();
Job job = new Job(conf);

Path in = new Path("YOUR_PATH_IN_HDFS");
FileInputFormat.addInputPath(job, in);

job.setInputFormatClass(TextInputFormat.class); // could be a sequencefile also
// set the other stuff
job.waitForCompletion(true);

然后确保您的文件驻留在 HDFS 中。

关于url - 如何调用包中已有的输入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6107637/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com