Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Set main, map and reduce classes */
- job.setJarByClass(Driver.class);
- job.setMapperClass(Map.class);
- job.setReducerClass(Reduce.class);
- Scan scan = new Scan();
- scan.setCaching(500);
- scan.setCacheBlocks(false);
- /* Initialize the initTableMapperJob */
- TableMapReduceUtil.initTableMapperJob(
- "dnsr",
- scan,
- Map.class,
- Text.class,
- Text.class,
- job);
- /* Set output parameters */
- job.setOutputKeyClass(Text.class);
- job.setOutputValueClass(Text.class);
- job.setOutputFormatClass(TextOutputFormat.class);
- @Override
- public void map(ImmutableBytesWritable row, Result value, Context context)
- throws InterruptedException, IOException {
- byte[] columnValue = value.getValue("d".getBytes(), "fqdn".getBytes());
- if (columnValue == null)
- return;
- byte[] firstSeen = value.getValue("d".getBytes(), "fs".getBytes());
- // if (firstSeen == null)
- // return;
- String fqdn = new String(columnValue).toLowerCase();
- String fs = (firstSeen == null) ? "empty" : new String(firstSeen);
- context.write(new Text(fqdn), new Text(fs));
- }
- @Override
- public void map(ImmutableBytesWritable row, Result value, Context context)
- throws InterruptedException, IOException {
- byte[] columnValue = value.getValue(columnFamily, fqdnColumnName);
- if (columnValue == null)
- return;
- String fqdn = new String(columnValue).toLowerCase();
- /* Getting all the columns */
- String[] cns = getColumnsInColumnFamily(value, "d");
- StringBuilder sb = new StringBuilder();
- for (String s : cns) {
- sb.append(s).append(";");
- }
- context.write(new Text(fqdn), new Text(sb.toString()));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement