相关疑难解决方法(0)

文件未正确放入分布式缓存中

我使用以下代码将文件添加到分布式缓存:

Configuration conf2 = new Configuration();      
job = new Job(conf2);
job.setJobName("Join with Cache");
DistributedCache.addCacheFile(new URI("hdfs://server:port/FilePath/part-r-00000"), conf2);
Run Code Online (Sandbox Code Playgroud)

然后我将文件读入映射器:

protected void setup(Context context)throws IOException,InterruptedException{
Configuration conf = context.getConfiguration();

URI[] cacheFile = DistributedCache.getCacheFiles(conf);
FSDataInputStream in = FileSystem.get(conf).open(new Path(cacheFile[0].getPath()));
BufferedReader joinReader = new BufferedReader(new InputStreamReader(in));

String line;
        try {
              while ((line = joinReader.readLine()) != null) {
              s = line.toString().split("\t");
                  do stuff to s
                } finally {
                   joinReader.close();
                }
Run Code Online (Sandbox Code Playgroud)

问题是我只读了一行,而不是我放入缓存的文件.而是:cm9vdA ==,或base64中的root.

有没有其他人有这个问题,或看到我如何错误地使用分布式缓存?我正在使用Hadoop 0.20.2完全分发.

hadoop distributed-cache

4
推荐指数
1
解决办法
5692
查看次数

标签 统计

distributed-cache ×1

hadoop ×1