Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. public void map(LongWritable key, Text value, Context context)
  2. throws IOException, InterruptedException {
  3. String line = value.toString();
  4. String[] lineSplit = line.split(" ");
  5. if (Double.parseDouble(lineSplit[2]) < dcThreshold) {
  6. IntWritable one = new IntWritable(
  7. Integer.parseInt(lineSplit[0]));
  8. IntWritable two = new IntWritable(
  9. Integer.parseInt(lineSplit[1]));
  10. context.write(one, two);
  11. }
  12. }
  13.  
  14. public void reduce(IntWritable key, IntWritable values, Context context)
  15. throws IOException, InterruptedException {
  16. int[] indexs = new int[2];
  17. indexs[0] = Integer.parseInt(key.toString());
  18. indexs[1] = Integer.parseInt(values.toString());
  19. for (int i = 0; i < indexs.length; i++) {
  20. densityCountMap.put(indexs[i],
  21. densityCountMap.get(indexs[i]) + 1);
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement