【问题标题】:Access Path variable in Distributed cache分布式缓存中的访问路径变量
【发布时间】:2014-06-02 04:58:44
【问题描述】:

我正在尝试访问分布式缓存中的 Path 变量。

//Job 1
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(MINMAX));
//job 2
FileInputFormat.addInputPath(job1, new Path(args[0]));
FileOutputFormat.setOutputPath(job1, new Path(args[1]));

在驱动程序中 DistributedCache.addCacheFile(new Path(MINMAX).toUri(),conf);

和

在设置()中

Path[] cacheFiles = DistributedCache.getLocalCacheFiles(conf);
BufferedReader bf = new BufferedReader(new InputStreamReader(fs.open(cacheFiles[0])));

但是显示

java.lang.Exception: java.lang.NullPointerException
    at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:354)
Caused by: java.lang.NullPointerException

我是不是做错了什么。

请提出建议。

【问题讨论】:

    标签: hadoop path mapreduce distributed-cache


    【解决方案1】:

    我找到了答案

    //Job 1
    FileInputFormat.addInputPath(job, new Path(args[0]));
    FileOutputFormat.setOutputPath(job, new Path(MINMAX));
    //job 2
    Path prevJob = new Path(new Path(MINMAX), "part-r-[0-9]*");
    FileStatus [] list = fs.globStatus(prevJob);
    for (FileStatus status : list) {
         DistributedCache.addCacheFile(status.getPath().toUri(), conf);
    }
    FileInputFormat.addInputPath(job1, new Path(args[0]));
    FileOutputFormat.setOutputPath(job1, new Path(args[1]));
    

    并在 Setup 方法中访问文件

    Path[] cacheFiles = DistributedCache.getLocalCacheFiles(conf);
    BufferedReader bf = new BufferedReader(new InputStreamReader(
            fs.open(cacheFiles[0])));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-19
      • 1970-01-01
      相关资源
      最近更新 更多