資源簡介
hadoop實現(xiàn)k-means算法的java工程,具體過程參考http://blog.csdn.net/fansy1990/article/details/8028546這個,此工程和上面頁面的思路稍有改動,大致思路一致;
代碼片段和文件信息
package?cluster;
import?java.io.IOException;
import?org.apache.hadoop.io.*;
import?org.apache.hadoop.mapreduce.Mapper;
import?util.Utils;
public?class?CaclCenterMapper?extends?Mapper{
public?void?map(LongWritable?keyText?valueContext?context)?throws?IOException?InterruptedException{
int?index=(int)key.get();
DoubleArray?da=new?DoubleArray(3);
double[]?center={indexindexindex};
da.setCenter(center);
context.write(new?IntWritable(index)?da);
}
}
評論
共有 條評論