2

我想從EMR中的分佈式緩存中對文件進行排序,但無法從EMR中的分佈式緩存中讀取文件。我的代碼在本地工作正常,但它給我emr的問題。這裏是我的代碼snippet-無法從EMR中的分佈式緩存中讀取序列文件

把序列文件到分佈式的cache

job.addCacheFile(new URI(status.getPath().toString())); 

讀取路徑 -

for (Path eachPath : cacheFilesLocal) { 
loadMap(eachPath.getName(),context.getConfiguration()); 
} 

從路徑 -

private void loadMap(String filePath,Configuration conf) throws IOException 
    { 
     try { 
      Path somePath=new Path(filePath); 
      reader=new Reader(somePath.getFileSystem(conf),somePath,conf); 
     // brReader = new BufferedReader(new FileReader(filePath)); 
      Writable key= new Text(); 
      Writable value=new Text(); 
      // Read each line, split and load to HashMap 
      while (reader.next(key,value)) { 
      // String index[]=strLineRead.toString().split(Pattern.quote(" - ")); 
       rMap.put(key.toString(),value.toString()); 
      } 
     } 
     catch (FileNotFoundException e) { 
      e.printStackTrace(); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 
     finally { 
      if (reader != null) { 
       reader.close(); 
      } 
     } 
    } 

任何幫助閱讀文件將不勝感激。

+0

我與自定義JAR訪問求CacheFile掙扎。 – chetan

回答

0

在參數提供S3路徑按文件enter link description here

現在在Driver類使用的參數 這樣的:

job.addCacheFile(new URI(args[3])); 
    job.addCacheFile(new URI(args[4])); 
    job.addCacheFile(new URI(args[5])); 
    job.addCacheFile(new URI(args[5])); 

而在映射使用緩存文件如常。

cacheFiles = context.getCacheFiles(); 
     if (cacheFiles != null) { 
      File cityCacheFile = new File("AreaCityCountryCache"); 

工作對我來說...