Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. /* Set main, map and reduce classes */
  2. job.setJarByClass(Driver.class);
  3. job.setMapperClass(Map.class);
  4. job.setReducerClass(Reduce.class);
  5.  
  6. Scan scan = new Scan();
  7. scan.setCaching(500);
  8. scan.setCacheBlocks(false);
  9.  
  10. /* Initialize the initTableMapperJob */
  11. TableMapReduceUtil.initTableMapperJob(
  12. "dnsr",
  13. scan,
  14. Map.class,
  15. Text.class,
  16. Text.class,
  17. job);
  18.  
  19. /* Set output parameters */
  20. job.setOutputKeyClass(Text.class);
  21. job.setOutputValueClass(Text.class);
  22. job.setOutputFormatClass(TextOutputFormat.class);
  23.  
  24. @Override
  25. public void map(ImmutableBytesWritable row, Result value, Context context)
  26. throws InterruptedException, IOException {
  27. byte[] columnValue = value.getValue("d".getBytes(), "fqdn".getBytes());
  28. if (columnValue == null)
  29. return;
  30.  
  31. byte[] firstSeen = value.getValue("d".getBytes(), "fs".getBytes());
  32. // if (firstSeen == null)
  33. // return;
  34.  
  35. String fqdn = new String(columnValue).toLowerCase();
  36. String fs = (firstSeen == null) ? "empty" : new String(firstSeen);
  37.  
  38. context.write(new Text(fqdn), new Text(fs));
  39. }
  40.  
  41. @Override
  42. public void map(ImmutableBytesWritable row, Result value, Context context)
  43. throws InterruptedException, IOException {
  44. byte[] columnValue = value.getValue(columnFamily, fqdnColumnName);
  45. if (columnValue == null)
  46. return;
  47. String fqdn = new String(columnValue).toLowerCase();
  48.  
  49. /* Getting all the columns */
  50. String[] cns = getColumnsInColumnFamily(value, "d");
  51. StringBuilder sb = new StringBuilder();
  52. for (String s : cns) {
  53. sb.append(s).append(";");
  54. }
  55.  
  56. context.write(new Text(fqdn), new Text(sb.toString()));
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement