List of usage examples for org.apache.hadoop.io MD5Hash digest
null digest
To view the source code for org.apache.hadoop.io MD5Hash digest.
Click Source Link
From source file:org.freeeed.services.Util.java
License:Apache License
public static MD5Hash createKeyHash(File file, Metadata metadata) throws IOException { String extension = Util.getExtension(file.getName()); if ("eml".equalsIgnoreCase(extension)) { assert (metadata != null); String hashNames = EmailProperties.getInstance().getProperty(EmailProperties.EMAIL_HASH_NAMES); String[] hashNamesArr = hashNames.split(","); StringBuilder data = new StringBuilder(); for (String hashName : hashNamesArr) { String value = metadata.get(hashName); if (value != null) { data.append(value);// ww w . j ava 2 s . c o m data.append(" "); } } return MD5Hash.digest(data.toString()); } else { MD5Hash key; try ( //use MD5 of the input file as Hadoop key FileInputStream fileInputStream = new FileInputStream(file)) { key = MD5Hash.digest(fileInputStream); } return key; } }