Iterable to ArrayList elements change

旧街凉风 提交于 2019-12-04 20:26:56

I figured it out. Hadoop has an odd memory usage so when I iterated over the values the first time it was just adding the same object over and over again to the arraylist.

Instead I need to do this:

for(FreqDataWritable i : values) {
    filenames.add(new String(i.getFilename()));
}
for(String filename : filenames) {
  System.out.println(fn);
}

Let me know if this will help?

Have you tried an iterator-based method?

Iterator i = values.iterator();
fileNames.add(i.next().getFileName());
for(i; i.hasNext();) {
    String stringI = i.next().getLast().getFileName();
    if(!stringI.equals(fileNames.get(fileNames.size() - 1)))
        fileNames.add(i.next().getLast().getFileName());
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!