@Override public void map(ImmutableHexWritable key, FsEntry value, Context context) throws IOException, InterruptedException { if (Extensions.contains(value.extension())) { FullPath.set(value.fullPath()); Ext.set(value.extension()); encodeHex(Sha, value, "sha1"); encodeHex(Md5, value, "md5"); if (value.isContentHDFS()) { Vid.setSize(0); HdfsPath.set(value.getContentHdfsPath()); } else { final byte[] buf = value.getContentBuffer(); if (buf == null) { LOG.warn(value.fullPath() + " didn't have a content buffer, skipping."); return; } Vid.set(buf, 0, buf.length); HdfsPath.set(""); } byte[] keybytes = key.get(); OutKey.set(keybytes, 0, keybytes.length); context.write(OutKey, Fields); } }
void encodeHex(Text val, FsEntry entry, String field) { Object o = entry.get(field); if (o != null && o instanceof byte[]) { byte[] b = (byte[]) o; val.set(new String(Hex.encodeHex(b))); } else { LOG.warn(entry.fullPath() + " didn't have a hash for " + field); val.set(""); } }