hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hair...@apache.org
Subject svn commit: r1028427 - in /hadoop/common/trunk: CHANGES.txt src/java/org/apache/hadoop/io/MD5Hash.java
Date Thu, 28 Oct 2010 18:49:40 GMT
Author: hairong
Date: Thu Oct 28 18:49:39 2010
New Revision: 1028427

URL: http://svn.apache.org/viewvc?rev=1028427&view=rev
Log:
HADOOP-7009. MD5Hash provides a public factory method that creates an instance of MessageDigest.
Contributed by Hairong Kuang.


Modified:
    hadoop/common/trunk/CHANGES.txt
    hadoop/common/trunk/src/java/org/apache/hadoop/io/MD5Hash.java

Modified: hadoop/common/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/CHANGES.txt?rev=1028427&r1=1028426&r2=1028427&view=diff
==============================================================================
--- hadoop/common/trunk/CHANGES.txt (original)
+++ hadoop/common/trunk/CHANGES.txt Thu Oct 28 18:49:39 2010
@@ -152,6 +152,9 @@ Trunk (unreleased changes)
 
     HADOOP-7010. Typo in FileSystem.java. (Jingguo Yao via eli)
 
+    HADOOP-7009. MD5Hash provides a public factory method that creates an
+    instance of thread local MessageDigest. (hairong)
+
   OPTIMIZATIONS
 
     HADOOP-6884. Add LOG.isDebugEnabled() guard for each LOG.debug(..).

Modified: hadoop/common/trunk/src/java/org/apache/hadoop/io/MD5Hash.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/src/java/org/apache/hadoop/io/MD5Hash.java?rev=1028427&r1=1028426&r2=1028427&view=diff
==============================================================================
--- hadoop/common/trunk/src/java/org/apache/hadoop/io/MD5Hash.java (original)
+++ hadoop/common/trunk/src/java/org/apache/hadoop/io/MD5Hash.java Thu Oct 28 18:49:39 2010
@@ -94,11 +94,18 @@ public class MD5Hash implements Writable
     return digest(data, 0, data.length);
   }
 
+  /**
+   * Create a thread local MD5 digester
+   */
+  public static MessageDigest getDigester() {
+    return DIGESTER_FACTORY.get();
+  }
+
   /** Construct a hash value for the content from the InputStream. */
   public static MD5Hash digest(InputStream in) throws IOException {
     final byte[] buffer = new byte[4*1024]; 
 
-    final MessageDigest digester = DIGESTER_FACTORY.get();
+    final MessageDigest digester = getDigester();
     for(int n; (n = in.read(buffer)) != -1; ) {
       digester.update(buffer, 0, n);
     }
@@ -109,7 +116,7 @@ public class MD5Hash implements Writable
   /** Construct a hash value for a byte array. */
   public static MD5Hash digest(byte[] data, int start, int len) {
     byte[] digest;
-    MessageDigest digester = DIGESTER_FACTORY.get();
+    MessageDigest digester = getDigester();
     digester.update(data, start, len);
     digest = digester.digest();
     return new MD5Hash(digest);



Mime
View raw message