gpt4 book ai didi

hadoop - Java 映射减少 : how to store a list of LONGs in Hadoop Output

转载 作者:可可西里 更新时间:2023-11-01 15:07:11 24 4
gpt4 key购买 nike

我有一个 MapReduce Java 程序,它输出一个数字列表作为 String 作为最终输出。但是数量比较长,占用空间太大。我想将每个数字转换为 Long 并存储。我怎样才能做到这一点?

最佳答案

ArrayWritable 可以扩展为

public class LongArrayWritable extends ArrayWritable {
public LongArrayWritable() {
super(Text.class);
}

public LongArrayWritable(LongWritable[] values) {
super(LongWritable.class, values);
}
}

此外,字符串可以转换为 LongWritable

String s = "123456";
new LongWritable((new Long(s)).longValue());

关于hadoop - Java 映射减少 : how to store a list of LONGs in Hadoop Output,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13097193/

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