main方法中设置缓存文件
job.addCacheFile(new URI("file:/你的文件路径));
在Mapper类的setup方法中加载缓存文件,setup方法,在maptask运行前只调用一次,可进行初始化工作。
protected void setup(Context context)throws IOException, InterruptedException {
//获取缓存文件路径
Path[] cacheFiles = context.getLocalCacheFiles();
//读文件
BufferedReader bfr = new BufferedReader(new InputStreamReader(new
FileInputStream(cacheFiles[0].toUri().getPath())));
bfr.close();
}