我会在这里查看给定 alexhomes 的 hadoop-book 的示例
我不明白为什么 close 方法是同步的?为什么只有 close() 而没有其他方法?
public synchronized void close() throws IOException {
reader.close();
}
有人可以解释一下吗?这将非常有帮助。
正如我在书中提到的,我使用ElephantBird项目的LzoJsonRecordReader类作为我的版本的基础,因为我想编写一个不需要 LZOP 压缩的类。ElephantBird 在他们的 RecordReader 中使用了同步关闭方法,因此也进入了我的版本。正如其他人所提到的,我知道没有理由在 MapReduce 中同步 close 方法。