hadoop下的Kmeans算法实现一

前一段时间,从配置hadoop到运行kmeans的mapreduce程序,着实让我纠结了几天,昨天终于把前面遇到的配置问题和程序运行问题搞定。Kmeans算法看起来很简单,但对于第一次接触mapreduce程序来说,还是有些挑战,还好基本都搞明白了。Kmeans算法是从网上下的在此分析一下过程。

Kmeans.java

[java]  view plain copy
  1. import org.apache.hadoop.conf.Configuration;  
  2. import org.apache.hadoop.fs.FileSystem;  
  3. import org.apache.hadoop.fs.Path;  
  4. import org.apache.hadoop.io.Text;  
  5. import org.apache.hadoop.mapreduce.Job;  
  6. import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;  
  7. import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;  
  8.   
  9. public class KMeans {  
  10.       
  11.     public static void main(String[] args) throws Exception  
  12.     {  
  13.         CenterInitial centerInitial = new CenterInitial();  
  14.         centerInitial.run(args);//初始化中心点  
  15.         int times=0;  
  16.         double s = 0,shold = 0.1;//shold是预制。  
  17.         do {  
  18.             Configuration conf = new Configuration();  
  19.             conf.set("fs.default.name""hdfs://localhost:9000");  
  20.             Job job = new Job(conf,"KMeans");//建立KMeans的MapReduce作业  
  21.             job.setJarByClass(KMeans.class);//设定作业的启动类  
  22.             job.setOutputKeyClass(Text.class);//设定Key输出的格式:Text  
  23.             job.setOutputValueClass(Text.class);//设定value输出的格式:Text  
  24.             job.setMapperClass(KMapper.class);//设定Mapper类  
  25.             job.setMapOutputKeyClass(Text.class);  
  26.             job.setMapOutputValueClass(Text.class);//设定Reducer类  
  27.             job.setReducerClass(KReducer.class);  
  28.             FileSystem fs = FileSystem.get(conf);  
  29.             fs.delete(new Path(args[2]),true);//args[2]是output目录,fs.delete是将已存在的output删除  
  30.                         //解析输入和输出参数,分别作为作业的输入和输出,都是文件   
  31.                         FileInputFormat.addInputPath(job, new Path(args[0]));  
  32.             FileOutputFormat.setOutputPath(job, new Path(args[2]));  
  33.                         //运行作业并判断是否完成成功  
  34.                         job.waitForCompletion(true);  
  35.             if(job.waitForCompletion(true))//上一次mapreduce过程结束  
  36.             {  
  37.                                 //上两个中心点做比较,如果中心点之间的距离小于阈值就停止;如果距离大于阈值,就把最近的中心点作为新中心点  
  38.                                 NewCenter newCenter = new NewCenter();  
  39.                 s = newCenter.run(args);  
  40.                 times++;  
  41.             }  
  42.         } while(s > shold);//当误差小于阈值停止。  
  43.         System.out.println("Iterator: " + times);//迭代次数       
  44.     }  
  45.   
  46. }  
问题:args[]是什么,这个问题纠结了几日才得到答案,args[]就是最开始向程序中传递的参数,具体在Run Configurations里配置,如下

hdfs://localhost:9000/home/administrator/hadoop/kmeans/input hdfs://localhost:9000/home/administrator/hadoop/kmeans hdfs://localhost:9000/home/administrator/hadoop/kmeans/output

代码的功能在程序中注释。

 

hadoop下的Kmeans算法实现二


输入数据,保存在2.txt中:(1,1) (9,9) (2,3) (10,30) (4,4) (34,40) (5,6) (15,20)

3.txt用于保存临时的中心

part-r-00000用于保存reduce的结果

程序的mapreduce过程及结果:

[java]  view plain copy
  1. 初始化过程:(10,30) (2,3)   
  2. 13/01/26 08:58:38 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable  
  3. 13/01/26 08:58:38 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.  
  4. 13/01/26 08:58:38 WARN mapred.JobClient: No job jar file set.  User classes may not be found. See JobConf(Class) or JobConf#setJar(String).  
  5. 13/01/26 08:58:38 INFO input.FileInputFormat: Total input paths to process : 2  
  6. 13/01/26 08:58:38 WARN snappy.LoadSnappy: Snappy native library not loaded  
  7. 13/01/26 08:58:38 INFO mapred.JobClient: Running job: job_local_0001  
  8. 13/01/26 08:58:39 INFO util.ProcessTree: setsid exited with exit code 0  
  9. 13/01/26 08:58:39 INFO mapred.Task:  Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@15718f2  
  10. 13/01/26 08:58:39 INFO mapred.MapTask: io.sort.mb = 100  
  11. 13/01/26 08:58:39 INFO mapred.MapTask: data buffer = 79691776/99614720  
  12. 13/01/26 08:58:39 INFO mapred.MapTask: record buffer = 262144/327680  
  13. 0list:1  
  14. 0c:10  
  15. 1list:1  
  16. 1c:30  
  17. 中心点(2,3)对应坐标(1,1)  
  18. Mapper输出:(2,3) (1,1)  
  19. 0list:9  
  20. 0c:10  
  21. 1list:9  
  22. 1c:30  
  23. 中心点(2,3)对应坐标(9,9)  
  24. Mapper输出:(2,3) (9,9)  
  25. 0list:2  
  26. 0c:10  
  27. 1list:3  
  28. 1c:30  
  29. 中心点(2,3)对应坐标(2,3)  
  30. Mapper输出:(2,3) (2,3)  
  31. 0list:10  
  32. 0c:10  
  33. 1list:30  
  34. 1c:30  
  35. 中心点(10,30)对应坐标(10,30)  
  36. Mapper输出:(10,30) (10,30)  
  37. 0list:4  
  38. 0c:10  
  39. 1list:4  
  40. 1c:30  
  41. 中心点(2,3)对应坐标(4,4)  
  42. Mapper输出:(2,3) (4,4)  
  43. 0list:34  
  44. 0c:10  
  45. 1list:40  
  46. 1c:30  
  47. 中心点(10,30)对应坐标(34,40)  
  48. Mapper输出:(10,30) (34,40)  
  49. 0list:5  
  50. 0c:10  
  51. 1list:6  
  52. 1c:30  
  53. 中心点(2,3)对应坐标(5,6)  
  54. Mapper输出:(2,3) (5,6)  
  55. 0list:15  
  56. 0c:10  
  57. 1list:20  
  58. 1c:30  
  59. 中心点(10,30)对应坐标(15,20)  
  60. Mapper输出:(10,30) (15,20)  
  61. 13/01/26 08:58:39 INFO mapred.MapTask: Starting flush of map output  
  62. 13/01/26 08:58:39 INFO mapred.MapTask: Finished spill 0  
  63. 13/01/26 08:58:39 INFO mapred.Task: Task:attempt_local_0001_m_000000_0 is done. And is in the process of commiting  
  64. 13/01/26 08:58:39 INFO mapred.JobClient:  map 0% reduce 0%  
  65. 13/01/26 08:58:42 INFO mapred.LocalJobRunner:   
  66. 13/01/26 08:58:42 INFO mapred.Task: Task 'attempt_local_0001_m_000000_0' done.  
  67. 13/01/26 08:58:42 INFO mapred.Task:  Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@77eaf8  
  68. 13/01/26 08:58:42 INFO mapred.MapTask: io.sort.mb = 100  
  69. 13/01/26 08:58:42 INFO mapred.MapTask: data buffer = 79691776/99614720  
  70. 13/01/26 08:58:42 INFO mapred.MapTask: record buffer = 262144/327680  
  71. 0list:2  
  72. 0c:10  
  73. 1list:3  
  74. 1c:30  
  75. 中心点(2,3)对应坐标(2,3)  
  76. Mapper输出:(2,3) (2,3)  
  77. 0list:10  
  78. 0c:10  
  79. 1list:30  
  80. 1c:30  
  81. 中心点(10,30)对应坐标(10,30)  
  82. Mapper输出:(10,30) (10,30)  
  83. 0list:34  
  84. 0c:10  
  85. 1list:40  
  86. 1c:30  
  87. 中心点(10,30)对应坐标(34,40)  
  88. Mapper输出:(10,30) (34,40)  
  89. 0list:1  
  90. 0c:10  
  91. 1list:1  
  92. 1c:30  
  93. 中心点(2,3)对应坐标(1,1)  
  94. Mapper输出:(2,3) (1,1)  
  95. 13/01/26 08:58:42 INFO mapred.MapTask: Starting flush of map output  
  96. 13/01/26 08:58:42 INFO mapred.MapTask: Finished spill 0  
  97. 13/01/26 08:58:42 INFO mapred.Task: Task:attempt_local_0001_m_000001_0 is done. And is in the process of commiting  
  98. 13/01/26 08:58:42 INFO mapred.JobClient:  map 100% reduce 0%  
  99. 13/01/26 08:58:45 INFO mapred.LocalJobRunner:   
  100. 13/01/26 08:58:45 INFO mapred.Task: Task 'attempt_local_0001_m_000001_0' done.  
  101. 13/01/26 08:58:45 INFO mapred.Task:  Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@18d7ace  
  102. 13/01/26 08:58:45 INFO mapred.LocalJobRunner:   
  103. 13/01/26 08:58:45 INFO mapred.Merger: Merging 2 sorted segments  
  104. 13/01/26 08:58:45 INFO mapred.Merger: Down to the last merge-pass, with 2 segments left of total size: 192 bytes  
  105. 13/01/26 08:58:45 INFO mapred.LocalJobRunner:   
  106. Reduce过程第一次  
  107. (10,30)Reduce  
  108. val:(10,30)  
  109. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@141fab6  
  110. temlength:2  
  111. val:(34,40)  
  112. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@141fab6  
  113. temlength:2  
  114. val:(10,30)  
  115. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@141fab6  
  116. temlength:2  
  117. val:(34,40)  
  118. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@141fab6  
  119. temlength:2  
  120. val:(15,20)  
  121. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@141fab6  
  122. temlength:2  
  123. count:5  
  124. outVal:(10,30) (34,40) (10,30) (34,40) (15,20) /outVal  
  125. ave0i103.0  
  126. ave1i160.0  
  127. 写入part:(10,30) (10,30) (34,40) (10,30) (34,40) (15,20)  (20.6,32.0)  
  128. Reduce过程第一次  
  129. (2,3)Reduce  
  130. val:(1,1)  
  131. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@141fab6  
  132. temlength:2  
  133. val:(9,9)  
  134. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@141fab6  
  135. temlength:2  
  136. val:(2,3)  
  137. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@141fab6  
  138. temlength:2  
  139. val:(4,4)  
  140. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@141fab6  
  141. temlength:2  
  142. val:(5,6)  
  143. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@141fab6  
  144. temlength:2  
  145. val:(2,3)  
  146. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@141fab6  
  147. temlength:2  
  148. val:(1,1)  
  149. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@141fab6  
  150. temlength:2  
  151. count:7  
  152. outVal:(1,1) (9,9) (2,3) (4,4) (5,6) (2,3) (1,1) /outVal  
  153. ave0i24.0  
  154. ave1i27.0  
  155. 写入part:(2,3) (1,1) (9,9) (2,3) (4,4) (5,6) (2,3) (1,1)  (3.4285715,3.857143)  
  156. 13/01/26 08:58:45 INFO mapred.Task: Task:attempt_local_0001_r_000000_0 is done. And is in the process of commiting  
  157. 13/01/26 08:58:45 INFO mapred.LocalJobRunner:   
  158. 13/01/26 08:58:45 INFO mapred.Task: Task attempt_local_0001_r_000000_0 is allowed to commit now  
  159. 13/01/26 08:58:45 INFO output.FileOutputCommitter: Saved output of task 'attempt_local_0001_r_000000_0' to hdfs://localhost:9000/home/administrator/hadoop/kmeans/output  
  160. 13/01/26 08:58:48 INFO mapred.LocalJobRunner: reduce > reduce  
  161. 13/01/26 08:58:48 INFO mapred.Task: Task 'attempt_local_0001_r_000000_0' done.  
  162. 13/01/26 08:58:48 INFO mapred.JobClient:  map 100% reduce 100%  
  163. 13/01/26 08:58:48 INFO mapred.JobClient: Job complete: job_local_0001  
  164. 13/01/26 08:58:48 INFO mapred.JobClient: Counters: 22  
  165. 13/01/26 08:58:48 INFO mapred.JobClient:   File Output Format Counters   
  166. 13/01/26 08:58:48 INFO mapred.JobClient:     Bytes Written=129  
  167. 13/01/26 08:58:48 INFO mapred.JobClient:   FileSystemCounters  
  168. 13/01/26 08:58:48 INFO mapred.JobClient:     FILE_BYTES_READ=1818  
  169. 13/01/26 08:58:48 INFO mapred.JobClient:     HDFS_BYTES_READ=450  
  170. 13/01/26 08:58:48 INFO mapred.JobClient:     FILE_BYTES_WRITTEN=122901  
  171. 13/01/26 08:58:48 INFO mapred.JobClient:     HDFS_BYTES_WRITTEN=171  
  172. 13/01/26 08:58:48 INFO mapred.JobClient:   File Input Format Counters   
  173. 13/01/26 08:58:48 INFO mapred.JobClient:     Bytes Read=82  
  174. 13/01/26 08:58:48 INFO mapred.JobClient:   Map-Reduce Framework  
  175. 13/01/26 08:58:48 INFO mapred.JobClient:     Map output materialized bytes=200  
  176. 13/01/26 08:58:48 INFO mapred.JobClient:     Map input records=2  
  177. 13/01/26 08:58:48 INFO mapred.JobClient:     Reduce shuffle bytes=0  
  178. 13/01/26 08:58:48 INFO mapred.JobClient:     Spilled Records=24  
  179. 13/01/26 08:58:48 INFO mapred.JobClient:     Map output bytes=164  
  180. 13/01/26 08:58:48 INFO mapred.JobClient:     Total committed heap usage (bytes)=498860032  
  181. 13/01/26 08:58:48 INFO mapred.JobClient:     CPU time spent (ms)=0  
  182. 13/01/26 08:58:48 INFO mapred.JobClient:     SPLIT_RAW_BYTES=262  
  183. 13/01/26 08:58:48 INFO mapred.JobClient:     Combine input records=0  
  184. 13/01/26 08:58:48 INFO mapred.JobClient:     Reduce input records=12  
  185. 13/01/26 08:58:48 INFO mapred.JobClient:     Reduce input groups=2  
  186. 13/01/26 08:58:48 INFO mapred.JobClient:     Combine output records=0  
  187. 13/01/26 08:58:48 INFO mapred.JobClient:     Physical memory (bytes) snapshot=0  
  188. 13/01/26 08:58:48 INFO mapred.JobClient:     Reduce output records=2  
  189. 13/01/26 08:58:48 INFO mapred.JobClient:     Virtual memory (bytes) snapshot=0  
  190. 13/01/26 08:58:48 INFO mapred.JobClient:     Map output records=12  
  191. 13/01/26 08:58:48 INFO mapred.JobClient: Running job: job_local_0001  
  192. 13/01/26 08:58:48 INFO mapred.JobClient: Job complete: job_local_0001  
  193. 13/01/26 08:58:48 INFO mapred.JobClient: Counters: 22  
  194. 13/01/26 08:58:48 INFO mapred.JobClient:   File Output Format Counters   
  195. 13/01/26 08:58:48 INFO mapred.JobClient:     Bytes Written=129  
  196. 13/01/26 08:58:48 INFO mapred.JobClient:   FileSystemCounters  
  197. 13/01/26 08:58:48 INFO mapred.JobClient:     FILE_BYTES_READ=1818  
  198. 13/01/26 08:58:48 INFO mapred.JobClient:     HDFS_BYTES_READ=450  
  199. 13/01/26 08:58:48 INFO mapred.JobClient:     FILE_BYTES_WRITTEN=122901  
  200. 13/01/26 08:58:48 INFO mapred.JobClient:     HDFS_BYTES_WRITTEN=171  
  201. 13/01/26 08:58:48 INFO mapred.JobClient:   File Input Format Counters   
  202. 13/01/26 08:58:48 INFO mapred.JobClient:     Bytes Read=82  
  203. 13/01/26 08:58:48 INFO mapred.JobClient:   Map-Reduce Framework  
  204. 13/01/26 08:58:48 INFO mapred.JobClient:     Map output materialized bytes=200  
  205. 13/01/26 08:58:48 INFO mapred.JobClient:     Map input records=2  
  206. 13/01/26 08:58:48 INFO mapred.JobClient:     Reduce shuffle bytes=0  
  207. 13/01/26 08:58:48 INFO mapred.JobClient:     Spilled Records=24  
  208. 13/01/26 08:58:48 INFO mapred.JobClient:     Map output bytes=164  
  209. 13/01/26 08:58:48 INFO mapred.JobClient:     Total committed heap usage (bytes)=498860032  
  210. 13/01/26 08:58:48 INFO mapred.JobClient:     CPU time spent (ms)=0  
  211. 13/01/26 08:58:48 INFO mapred.JobClient:     SPLIT_RAW_BYTES=262  
  212. 13/01/26 08:58:48 INFO mapred.JobClient:     Combine input records=0  
  213. 13/01/26 08:58:48 INFO mapred.JobClient:     Reduce input records=12  
  214. 13/01/26 08:58:48 INFO mapred.JobClient:     Reduce input groups=2  
  215. 13/01/26 08:58:48 INFO mapred.JobClient:     Combine output records=0  
  216. 13/01/26 08:58:48 INFO mapred.JobClient:     Physical memory (bytes) snapshot=0  
  217. 13/01/26 08:58:48 INFO mapred.JobClient:     Reduce output records=2  
  218. 13/01/26 08:58:48 INFO mapred.JobClient:     Virtual memory (bytes) snapshot=0  
  219. 13/01/26 08:58:48 INFO mapred.JobClient:     Map output records=12  
  220. 上一次MapReduce结果:第一行:(10,30)  (10,30) (34,40) (10,30) (34,40) (15,20) (20.6,32.0)  
  221. 第二行:(2,3)   (1,1) (9,9) (2,3) (4,4) (5,6) (2,3) (1,1) (3.4285715,3.857143)  
  222. 。  
  223. 0坐标距离:116.36001  
  224. 1坐标距离:2.7755103  
  225. 新中心点:(20.6,32.0) (3.4285715,3.857143)   
  226. 13/01/26 08:58:49 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.  
  227. 13/01/26 08:58:49 WARN mapred.JobClient: No job jar file set.  User classes may not be found. See JobConf(Class) or JobConf#setJar(String).  
  228. 13/01/26 08:58:49 INFO input.FileInputFormat: Total input paths to process : 2  
  229. 13/01/26 08:58:49 INFO mapred.JobClient: Running job: job_local_0002  
  230. 13/01/26 08:58:49 INFO mapred.Task:  Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@18aab40  
  231. 13/01/26 08:58:49 INFO mapred.MapTask: io.sort.mb = 100  
  232. 13/01/26 08:58:49 INFO mapred.MapTask: data buffer = 79691776/99614720  
  233. 13/01/26 08:58:49 INFO mapred.MapTask: record buffer = 262144/327680  
  234. 0list:1  
  235. 0c:20.6  
  236. 1list:1  
  237. 1c:32.0  
  238. 中心点(3.4285715,3.857143)对应坐标(1,1)  
  239. Mapper输出:(3.4285715,3.857143) (1,1)  
  240. 0list:9  
  241. 0c:20.6  
  242. 1list:9  
  243. 1c:32.0  
  244. 中心点(3.4285715,3.857143)对应坐标(9,9)  
  245. Mapper输出:(3.4285715,3.857143) (9,9)  
  246. 0list:2  
  247. 0c:20.6  
  248. 1list:3  
  249. 1c:32.0  
  250. 中心点(3.4285715,3.857143)对应坐标(2,3)  
  251. Mapper输出:(3.4285715,3.857143) (2,3)  
  252. 0list:10  
  253. 0c:20.6  
  254. 1list:30  
  255. 1c:32.0  
  256. 中心点(20.6,32.0)对应坐标(10,30)  
  257. Mapper输出:(20.6,32.0) (10,30)  
  258. 0list:4  
  259. 0c:20.6  
  260. 1list:4  
  261. 1c:32.0  
  262. 中心点(3.4285715,3.857143)对应坐标(4,4)  
  263. Mapper输出:(3.4285715,3.857143) (4,4)  
  264. 0list:34  
  265. 0c:20.6  
  266. 1list:40  
  267. 1c:32.0  
  268. 中心点(20.6,32.0)对应坐标(34,40)  
  269. Mapper输出:(20.6,32.0) (34,40)  
  270. 0list:5  
  271. 0c:20.6  
  272. 1list:6  
  273. 1c:32.0  
  274. 中心点(3.4285715,3.857143)对应坐标(5,6)  
  275. Mapper输出:(3.4285715,3.857143) (5,6)  
  276. 0list:15  
  277. 0c:20.6  
  278. 1list:20  
  279. 1c:32.0  
  280. 中心点(20.6,32.0)对应坐标(15,20)  
  281. Mapper输出:(20.6,32.0) (15,20)  
  282. 13/01/26 08:58:49 INFO mapred.MapTask: Starting flush of map output  
  283. 13/01/26 08:58:49 INFO mapred.MapTask: Finished spill 0  
  284. 13/01/26 08:58:49 INFO mapred.Task: Task:attempt_local_0002_m_000000_0 is done. And is in the process of commiting  
  285. 13/01/26 08:58:50 INFO mapred.JobClient:  map 0% reduce 0%  
  286. 13/01/26 08:58:52 INFO mapred.LocalJobRunner:   
  287. 13/01/26 08:58:52 INFO mapred.Task: Task 'attempt_local_0002_m_000000_0' done.  
  288. 13/01/26 08:58:52 INFO mapred.Task:  Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@147358f  
  289. 13/01/26 08:58:52 INFO mapred.MapTask: io.sort.mb = 100  
  290. 13/01/26 08:58:52 INFO mapred.MapTask: data buffer = 79691776/99614720  
  291. 13/01/26 08:58:52 INFO mapred.MapTask: record buffer = 262144/327680  
  292. 0list:2  
  293. 0c:20.6  
  294. 1list:3  
  295. 1c:32.0  
  296. 中心点(3.4285715,3.857143)对应坐标(2,3)  
  297. Mapper输出:(3.4285715,3.857143) (2,3)  
  298. 0list:10  
  299. 0c:20.6  
  300. 1list:30  
  301. 1c:32.0  
  302. 中心点(20.6,32.0)对应坐标(10,30)  
  303. Mapper输出:(20.6,32.0) (10,30)  
  304. 0list:34  
  305. 0c:20.6  
  306. 1list:40  
  307. 1c:32.0  
  308. 中心点(20.6,32.0)对应坐标(34,40)  
  309. Mapper输出:(20.6,32.0) (34,40)  
  310. 0list:1  
  311. 0c:20.6  
  312. 1list:1  
  313. 1c:32.0  
  314. 中心点(3.4285715,3.857143)对应坐标(1,1)  
  315. Mapper输出:(3.4285715,3.857143) (1,1)  
  316. 13/01/26 08:58:52 INFO mapred.MapTask: Starting flush of map output  
  317. 13/01/26 08:58:52 INFO mapred.MapTask: Finished spill 0  
  318. 13/01/26 08:58:52 INFO mapred.Task: Task:attempt_local_0002_m_000001_0 is done. And is in the process of commiting  
  319. 13/01/26 08:58:53 INFO mapred.JobClient:  map 100% reduce 0%  
  320. 13/01/26 08:58:55 INFO mapred.LocalJobRunner:   
  321. 13/01/26 08:58:55 INFO mapred.Task: Task 'attempt_local_0002_m_000001_0' done.  
  322. 13/01/26 08:58:55 INFO mapred.Task:  Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@2798e7  
  323. 13/01/26 08:58:55 INFO mapred.LocalJobRunner:   
  324. 13/01/26 08:58:55 INFO mapred.Merger: Merging 2 sorted segments  
  325. 13/01/26 08:58:55 INFO mapred.Merger: Down to the last merge-pass, with 2 segments left of total size: 317 bytes  
  326. 13/01/26 08:58:55 INFO mapred.LocalJobRunner:   
  327. Reduce过程第一次  
  328. (20.6,32.0)Reduce  
  329. val:(10,30)  
  330. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@13043d2  
  331. temlength:2  
  332. val:(34,40)  
  333. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@13043d2  
  334. temlength:2  
  335. val:(10,30)  
  336. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@13043d2  
  337. temlength:2  
  338. val:(34,40)  
  339. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@13043d2  
  340. temlength:2  
  341. val:(15,20)  
  342. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@13043d2  
  343. temlength:2  
  344. count:5  
  345. outVal:(10,30) (34,40) (10,30) (34,40) (15,20) /outVal  
  346. ave0i103.0  
  347. ave1i160.0  
  348. 写入part:(20.6,32.0) (10,30) (34,40) (10,30) (34,40) (15,20)  (20.6,32.0)  
  349. Reduce过程第一次  
  350. (3.4285715,3.857143)Reduce  
  351. val:(1,1)  
  352. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@13043d2  
  353. temlength:2  
  354. val:(9,9)  
  355. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@13043d2  
  356. temlength:2  
  357. val:(2,3)  
  358. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@13043d2  
  359. temlength:2  
  360. val:(4,4)  
  361. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@13043d2  
  362. temlength:2  
  363. val:(5,6)  
  364. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@13043d2  
  365. temlength:2  
  366. val:(2,3)  
  367. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@13043d2  
  368. temlength:2  
  369. val:(1,1)  
  370. values:org.apache.hadoop.mapreduce.ReduceContext$ValueIterable@13043d2  
  371. temlength:2  
  372. count:7  
  373. outVal:(1,1) (9,9) (2,3) (4,4) (5,6) (2,3) (1,1) /outVal  
  374. ave0i24.0  
  375. ave1i27.0  
  376. 写入part:(3.4285715,3.857143) (1,1) (9,9) (2,3) (4,4) (5,6) (2,3) (1,1)  (3.4285715,3.857143)  
  377. 13/01/26 08:58:55 INFO mapred.Task: Task:attempt_local_0002_r_000000_0 is done. And is in the process of commiting  
  378. 13/01/26 08:58:55 INFO mapred.LocalJobRunner:   
  379. 13/01/26 08:58:55 INFO mapred.Task: Task attempt_local_0002_r_000000_0 is allowed to commit now  
  380. 13/01/26 08:58:55 INFO output.FileOutputCommitter: Saved output of task 'attempt_local_0002_r_000000_0' to hdfs://localhost:9000/home/administrator/hadoop/kmeans/output  
  381. 13/01/26 08:58:58 INFO mapred.LocalJobRunner: reduce > reduce  
  382. 13/01/26 08:58:58 INFO mapred.Task: Task 'attempt_local_0002_r_000000_0' done.  
  383. 13/01/26 08:58:59 INFO mapred.JobClient:  map 100% reduce 100%  
  384. 13/01/26 08:58:59 INFO mapred.JobClient: Job complete: job_local_0002  
  385. 13/01/26 08:58:59 INFO mapred.JobClient: Counters: 22  
  386. 13/01/26 08:58:59 INFO mapred.JobClient:   File Output Format Counters   
  387. 13/01/26 08:58:59 INFO mapred.JobClient:     Bytes Written=148  
  388. 13/01/26 08:58:59 INFO mapred.JobClient:   FileSystemCounters  
  389. 13/01/26 08:58:59 INFO mapred.JobClient:     FILE_BYTES_READ=4442  
  390. 13/01/26 08:58:59 INFO mapred.JobClient:     HDFS_BYTES_READ=1262  
  391. 13/01/26 08:58:59 INFO mapred.JobClient:     FILE_BYTES_WRITTEN=246235  
  392. 13/01/26 08:58:59 INFO mapred.JobClient:     HDFS_BYTES_WRITTEN=676  
  393. 13/01/26 08:58:59 INFO mapred.JobClient:   File Input Format Counters   
  394. 13/01/26 08:58:59 INFO mapred.JobClient:     Bytes Read=82  
  395. 13/01/26 08:58:59 INFO mapred.JobClient:   Map-Reduce Framework  
  396. 13/01/26 08:58:59 INFO mapred.JobClient:     Map output materialized bytes=325  
  397. 13/01/26 08:58:59 INFO mapred.JobClient:     Map input records=2  
  398. 13/01/26 08:58:59 INFO mapred.JobClient:     Reduce shuffle bytes=0  
  399. 13/01/26 08:58:59 INFO mapred.JobClient:     Spilled Records=24  
  400. 13/01/26 08:58:59 INFO mapred.JobClient:     Map output bytes=289  
  401. 13/01/26 08:58:59 INFO mapred.JobClient:     Total committed heap usage (bytes)=667418624  
  402. 13/01/26 08:58:59 INFO mapred.JobClient:     CPU time spent (ms)=0  
  403. 13/01/26 08:58:59 INFO mapred.JobClient:     SPLIT_RAW_BYTES=262  
  404. 13/01/26 08:58:59 INFO mapred.JobClient:     Combine input records=0  
  405. 13/01/26 08:58:59 INFO mapred.JobClient:     Reduce input records=12  
  406. 13/01/26 08:58:59 INFO mapred.JobClient:     Reduce input groups=2  
  407. 13/01/26 08:58:59 INFO mapred.JobClient:     Combine output records=0  
  408. 13/01/26 08:58:59 INFO mapred.JobClient:     Physical memory (bytes) snapshot=0  
  409. 13/01/26 08:58:59 INFO mapred.JobClient:     Reduce output records=2  
  410. 13/01/26 08:58:59 INFO mapred.JobClient:     Virtual memory (bytes) snapshot=0  
  411. 13/01/26 08:58:59 INFO mapred.JobClient:     Map output records=12  
  412. 13/01/26 08:58:59 INFO mapred.JobClient: Running job: job_local_0002  
  413. 13/01/26 08:58:59 INFO mapred.JobClient: Job complete: job_local_0002  
  414. 13/01/26 08:58:59 INFO mapred.JobClient: Counters: 22  
  415. 13/01/26 08:58:59 INFO mapred.JobClient:   File Output Format Counters   
  416. 13/01/26 08:58:59 INFO mapred.JobClient:     Bytes Written=148  
  417. 13/01/26 08:58:59 INFO mapred.JobClient:   FileSystemCounters  
  418. 13/01/26 08:58:59 INFO mapred.JobClient:     FILE_BYTES_READ=4442  
  419. 13/01/26 08:58:59 INFO mapred.JobClient:     HDFS_BYTES_READ=1262  
  420. 13/01/26 08:58:59 INFO mapred.JobClient:     FILE_BYTES_WRITTEN=246235  
  421. 13/01/26 08:58:59 INFO mapred.JobClient:     HDFS_BYTES_WRITTEN=676  
  422. 13/01/26 08:58:59 INFO mapred.JobClient:   File Input Format Counters   
  423. 13/01/26 08:58:59 INFO mapred.JobClient:     Bytes Read=82  
  424. 13/01/26 08:58:59 INFO mapred.JobClient:   Map-Reduce Framework  
  425. 13/01/26 08:58:59 INFO mapred.JobClient:     Map output materialized bytes=325  
  426. 13/01/26 08:58:59 INFO mapred.JobClient:     Map input records=2  
  427. 13/01/26 08:58:59 INFO mapred.JobClient:     Reduce shuffle bytes=0  
  428. 13/01/26 08:58:59 INFO mapred.JobClient:     Spilled Records=24  
  429. 13/01/26 08:58:59 INFO mapred.JobClient:     Map output bytes=289  
  430. 13/01/26 08:58:59 INFO mapred.JobClient:     Total committed heap usage (bytes)=667418624  
  431. 13/01/26 08:58:59 INFO mapred.JobClient:     CPU time spent (ms)=0  
  432. 13/01/26 08:58:59 INFO mapred.JobClient:     SPLIT_RAW_BYTES=262  
  433. 13/01/26 08:58:59 INFO mapred.JobClient:     Combine input records=0  
  434. 13/01/26 08:58:59 INFO mapred.JobClient:     Reduce input records=12  
  435. 13/01/26 08:58:59 INFO mapred.JobClient:     Reduce input groups=2  
  436. 13/01/26 08:58:59 INFO mapred.JobClient:     Combine output records=0  
  437. 13/01/26 08:58:59 INFO mapred.JobClient:     Physical memory (bytes) snapshot=0  
  438. 13/01/26 08:58:59 INFO mapred.JobClient:     Reduce output records=2  
  439. 13/01/26 08:58:59 INFO mapred.JobClient:     Virtual memory (bytes) snapshot=0  
  440. 13/01/26 08:58:59 INFO mapred.JobClient:     Map output records=12  
  441. 上一次MapReduce结果:第一行:(20.6,32.0)  (10,30) (34,40) (10,30) (34,40) (15,20) (20.6,32.0)  
  442. 第二行:(3.4285715,3.857143)    (1,1) (9,9) (2,3) (4,4) (5,6) (2,3) (1,1) (3.4285715,3.857143)  
  443. 。  
  444. 0坐标距离:0.0  
  445. 1坐标距离:0.0  
  446. 新中心点:(20.6,32.0) (3.4285715,3.857143)   
  447. Iterator: 2  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值