我正在学习 Mahout 并阅读“Mahout in Action”。
当我尝试运行第 7 章 Simple KMeans Clustering.java 中的示例代码时,弹出了一个异常:
线程“main”中的异常 java.io.IOException:错误的值类:0.0:null 不是类 org.apache.mahout.clustering.WeightedPropertyVectorWritable at org.apache.hadoop.io.SequenceFile$Reader.next(SequenceFile.java:第 1874 章
我在 mahout-0.5 上成功执行了这段代码,但在 mahout-0.6 上我看到了这个异常。
即使我将目录名称从 cluster-0 更改为 cluster-0-final,我仍然面临这个异常。
KMeansDriver.run(conf, vectors, new Path(canopyCentroids, "clusters-0-final"), clusterOutput, new TanimotoDistanceMeasure(), 0.01, 20, true, false);//First, I changed this path.
SequenceFile.Reader reader = new SequenceFile.Reader(fs, new Path("output/clusters/clusteredPoints/part-m-00000"), conf);//I double checked this folder and filename.
IntWritable key = new IntWritable();
WeightedVectorWritable value = new WeightedVectorWritable();
int i=0;
while(reader.next(key, value)) {
System.out.println(value.toString() + " belongs to cluster " + key.toString());
i++;
}
System.out.println(i);
reader.close();
有人对这个例外有任何想法吗?我已经尝试解决这个问题很长时间了,但没有任何想法。而且互联网上的来源很少。
提前致谢