【发布时间】:2017-06-16 16:22:09
【问题描述】:
我是 Hadoop 新手。我想知道以下代码:
DistributedCache.addCacheFile(new Path(args[0]).toUri(), conf);
我的意思:=> arg[0].toUri()
关于“addCachFile”
谢谢
【问题讨论】:
标签: java hadoop mapreduce arguments
我是 Hadoop 新手。我想知道以下代码:
DistributedCache.addCacheFile(new Path(args[0]).toUri(), conf);
我的意思:=> arg[0].toUri()
关于“addCachFile”
谢谢
【问题讨论】:
标签: java hadoop mapreduce arguments
adCacheFile() 方法获取要添加到分布式缓存的文件的 URI,new Path(args[0]) 无论此路径来自输入参数,它都将其转换为 URI,然后此 URI 用于添加文件到hadoop的分布式缓存中。
路径 - 可以是文件或目录的名称。
当这个文件被添加到分布式缓存时,所有映射器都可以使用这个文件,如果你有一个小文件,这是 hadoop 中的优化技术之一。您可以使其可供所有节点访问,以便更快地访问数据。
有关更多详细信息,您可以查看:-
https://hadoop.apache.org/docs/r1.2.1/api/org/apache/hadoop/fs/Path.html
【讨论】:
感谢帕里托什·阿胡贾,
我有两个关于 Polygon 的 txt 文件: 我的完整代码
public class OverlayPhase2 extends Configured implements Tool
{
public int run(String[] args) throws IOException
{
JobConf conf = new JobConf( getConf(), OverlayPhase2.class);
if (conf == null) {
return -1;
}
conf.setOutputKeyClass(IntWritable.class);
conf.setOutputValueClass(Text.class);
conf.setMapperClass(OverlayPhase2Mapper.class);
conf.setReducerClass(OverlayPhase2Reducer.class);
conf.setNumMapTasks(2);
conf.setNumReduceTasks(8);
DistributedCache.addCacheFile(new Path(args[0]).toUri(), conf);
Path inp1 = new Path(arg[1]);
Path inp2 = new Path(arg[2]);
Path out1 = new Path(arg[3]);
FileInputFormat.setInputPaths(conf, inp1 );
FileInputFormat.setInputPaths(conf, inp2 );
FileInputFormat.setOutputPath(conf, out1 );
JobClient.runJob(conf);
return 0;
}
public static void main(String[] args) throws Exception
{
int exitCode = ToolRunner.run(new OverlayPhase2(), args);
System.exit(exitCode);
}
我将 arg[1]、arg[2]、arg[3] 设置为:
arg[1] =/home/mostafa/Desktop/b1.txt
arg[2] = /home/mostafa/Desktop.b2.txt
arg[3] = /home/mostafa/Desktaop/output
好吧,arg[0] :?
最好的问候,穆斯塔法
【讨论】: