【发布时间】:2014-10-30 03:51:45
【问题描述】:
我的工作流程如下:
我正在处理大量数据。我有一个需要缓存的MapFile。该文件的大小现在为 1 GB,但我预计它最终会增长。
MapFile 的内容是这样的:
12345,45464 192.34.23.1
33214,45321 123.45.32.1
- 在
map-phase中,我处理来自TextInputFormat中输入文件的每条记录。 我解析该行(由标记分割)并检索前两个标记,token1 和 token2。
如果 (token1,token2) 对不在缓存文件中,我会调用 API,获取信息,保存在缓存中(如果可能)并继续处理。
private Parser parser = new customParser();
protected void map(LongWritable key, Text value, Context context)
throws IOException, InterruptedException {
parser.parse(value);
Pair pair = new Pair();
pair.setFirst(parser.getFirst());
pair.setSecond(parser.getSecond());
IP ip = null;
//here is the catch
//check if pair exists in cache
if cache.contains(pair){
ip=cache.get(pair);
}
else {
ip=getFromAPI(pair);//This does API call outside network.
cache.put(pair,ip);
}
context.write(pair,ip);
}
}
我在这里看到的主要问题是
如何在所有节点的缓存中获取大文件。 DistributedCache 通过将文件复制到本地节点来工作。但由于这个文件更大,这里涉及到网络流量,对于我的日常工作,我不想继续分发它。
如何高效查找 MapFile(cache),整个 mapFile 不会在内存中。
如何写入作为我的缓存的 MapFile。
谢谢
【问题讨论】:
-
您可能应该放弃缓存的想法。不过,现在我无法提供替代方案。
标签: caching hadoop mapreduce distributed-cache map-files