我有一个 1.5 GB 的文件,其中包含一个序列化的 HashMap。
我在 Mapper 类中有一个 setup() 方法,我将其读入 HashMap 变量。
看起来它可以转到 read 方法,但会立即为任务抛出 java 堆空间错误。
我阅读了许多关于我们可能需要设置 mapred.child.opts 参数的讨论,我正在主程序代码中执行此操作。
我正在使用:conf.set("mapred.child.java.opts.", "-Xmx1024M");
我什至试图增加数量。为什么它在尝试将序列化文件读入 HashMap 变量时仍然抛出相同的错误?
这是我的 setup() 方法中的代码:
try {
test="hello";
Path pt=new Path("hdfs://localhost:9000/user/watsonuser/topic_dump.tsv");
FileSystem fs = FileSystem.get(new Configuration());
}catch(Exception e) {System.out.println("Exception while reading the nameMap
file."); e.printStackTrace();}
InputStream is = fs.open(pt);
ObjectInputStream s = new ObjectInputStream(is);
nameMap = (HashMap<String, String>) s.readObject();
s.close();
}catch(Exception e) {
System.out.println("Exception while reading the nameMap file.");
e.printStackTrace();
}