Amazon web services 无法从EMR中的分布式缓存中读取序列文件
我试图从EMR中的分布式缓存中对文件排序,但无法从EMR中的分布式缓存中读取文件。我的代码在本地运行良好,但在emr上给我带来了问题。这是我的代码片段- 将序列文件放入分布式缓存-Amazon web services 无法从EMR中的分布式缓存中读取序列文件,amazon-web-services,mapreduce,amazon-emr,elastic-map-reduce,distributed-cache,Amazon Web Services,Mapreduce,Amazon Emr,Elastic Map Reduce,Distributed Cache,我试图从EMR中的分布式缓存中对文件排序,但无法从EMR中的分布式缓存中读取文件。我的代码在本地运行良好,但在emr上给我带来了问题。这是我的代码片段- 将序列文件放入分布式缓存- job.addCacheFile(new URI(status.getPath().toString())); 阅读路径- for (Path eachPath : cacheFilesLocal) { loadMap(eachPath.getName(),context.getConfiguration());
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();
}
}
}
如有任何帮助,我们将不胜感激。参数中提供了符合文档要求的S3路径 现在在Driver类中使用参数 比如: 在Mapper中,像往常一样使用缓存文件
cacheFiles = context.getCacheFiles();
if (cacheFiles != null) {
File cityCacheFile = new File("AreaCityCountryCache");
为我工作…我正在努力访问自定义JAR中的缓存文件。
cacheFiles = context.getCacheFiles();
if (cacheFiles != null) {
File cityCacheFile = new File("AreaCityCountryCache");