In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In order to solve this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
The first is map.
Public static class KMmap extends Mapper {/ / Central set / / the cluster set here is the self-set centersPath, that is, the path where the collection is stored in hdfs ArrayList centers = null; / / with k centers int k = 0 / / read protected void setup (Context context) throws IOException, InterruptedException {/ / getCentersFromHDFS method is to pass a Path to get an ArrayList collection centers = Utils.getCentersFromHDFS (context.getConfiguration (). Get ("centersPath"), false); k = centers.size ();} / * 1. Read one entry to be classified at a time and compare it with the center and classify it to the corresponding center * 2. The center ID is the key, and the record contained in the center is the value output (for example: 10.2). 1 the ID,0.2 that is the cluster center is a value near the cluster center) * / @ Override protected void map (LongWritable key, Text value,Context context) throws IOException, InterruptedException {ArrayList fileds = Utils.textToArray (value); / / the textToArray method converts the row value entered by map into the set int sizeOfFileds = fileds.size () of ArrayList after segmentation. Double minDistance = 99999999; int centerIndex = 0; / / take out the k center points and the currently read records in turn to calculate for (int iS0uti
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 276
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.