gpt4 book ai didi

hadoop - 从放置在DistributedCache Hadoop中的序列文件读取

转载 作者:行者123 更新时间:2023-12-02 21:38:57 25 4
gpt4 key购买 nike

如何从分布式缓存中读取序列文件?

我已经尝试了一些方法,但是我总是收到FileNotFoundException。

我正在将文件添加到分布式缓存中

DistributedCache.addCacheFile(new URI(currentMedoids), conf);

并在mapper的设置方法中读取
        Configuration conf = context.getConfiguration();
FileSystem fs = FileSystem.get(conf);

Path[] paths = DistributedCache.getLocalCacheFiles(conf);

List<Element> sketch = new ArrayList<Element>();

SequenceFile.Reader medoidsReader = new SequenceFile.Reader(fs, paths[0], conf);

Writable medoidKey = (Writable) medoidsReader.getKeyClass().newInstance();
Writable medoidValue = (Writable) medoidsReader.getValueClass().newInstance();

while(medoidsReader.next(medoidKey, medoidValue)){

ElementWritable medoidWritable = (ElementWritable)medoidValue;
sketch.add(medoidWritable.getElement());
}

最佳答案

似乎我应该使用getCacheFiles()返回URL [],而不是getLocalCacheFiles()返回Path []。

现在,在进行更改后,它便可以工作了。

关于hadoop - 从放置在DistributedCache Hadoop中的序列文件读取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30171213/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com