public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { CompositeKey temp = new CompositeKey(); String url = value.toString().split("\\*\\*\\^\\*\\*")[0]; String users = value.toString().split("\\*\\*\\^\\*\\*")[3]; String tagweightpair = value.toString().split("\\*\\*\\^\\*\\*")[4]; String tag = ""; String weight = ""; StringTokenizer pair = new StringTokenizer(tagweightpair); while (pair.hasMoreTokens()) { String token = pair.nextToken(); tag = token.toString().split("==")[0]; System.out.println(tag); weight = token.toString().split("==")[1]; char c; c = tag.toString().charAt(0); if ((c >= 'a' && c <= 'z') || (c >= 'A' || c <= 'Z')) { temp.settag(tag + "\t" + url); System.out.println("temp:" + temp.gettag()); temp.setweight(Double.parseDouble(weight) * Double.parseDouble(users)); context.write(temp, new Text("LAX")); } } }
public void reduce(CompositeKey key, Iterable<Text> values, Context context) throws IOException, InterruptedException { int count = 0; for (Text val : values) { context.write(new Text(key.gettag() + "," + key.getweight()), new Text("")); count++; } }