gpt4 book ai didi

java - 可写问题: Not able to print the contents

转载 作者:行者123 更新时间:2023-12-01 13:55:54 24 4
gpt4 key购买 nike

我的 reducer 输入值是一个 double 组。

719.000 501.000 -75.000
501.000 508.000 -62.000
-75.000 -62.000 10.000

在我的 reducer 中,我需要打印这个矩阵。所以我做了

public void reduce(IntWritable key,
Iterable<DoubleArrayWritable> values, Context context)
throws IOException, InterruptedException {

System.out.println("in reducer");
for (DoubleArrayWritable c :values) { // TODO - test me
System.out.println("C ="+c.toString());
}
}

其中 DoubleArrayWritable 位于

public static class DoubleArrayWritable extends TwoDArrayWritable {
public DoubleArrayWritable() {
super(DoubleWritable.class);
}
}

我的输出是C =edu.Driver$DoubleArrayWritable@32d16fe3但我需要以人类可读的格式打印整个矩阵。

最佳答案

您需要重写 DoubleArrayWritabletoString():

@Override
public String toString()
{
// return the string you want
}

关于java - 可写问题: Not able to print the contents,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19628350/

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