This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git

commit fc9a12fcca1e80adfe12280a944adcb864ae1f78
Author: aherbert <aherb...@apache.org>
AuthorDate: Tue Dec 3 11:34:07 2019 +0000

    Update hash32 primitive helper methods to refer to hash32x86.
    
    Since the sign extension bug in hash32 is not relevant the javadoc can
    point to the hash32x86 implementation which does not have the bug.
    
    The result is the same. The unit tests have been updated to show this.
---
 .../apache/commons/codec/digest/MurmurHash3.java   | 48 ++++++++--------------
 .../commons/codec/digest/MurmurHash3Test.java      |  8 ++--
 2 files changed, 22 insertions(+), 34 deletions(-)

diff --git a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java 
b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
index f4b9cca..11d2aa4 100644
--- a/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
+++ b/src/main/java/org/apache/commons/codec/digest/MurmurHash3.java
@@ -104,19 +104,16 @@ public final class MurmurHash3 {
      * <pre>
      * int offset = 0;
      * int seed = 104729;
-     * int hash = MurmurHash3.hash32(ByteBuffer.allocate(16)
-     *                                         .putLong(data1)
-     *                                         .putLong(data2)
-     *                                         .array(), offset, 16, seed);
+     * int hash = MurmurHash3.hash32x86(ByteBuffer.allocate(16)
+     *                                            .putLong(data1)
+     *                                            .putLong(data2)
+     *                                            .array(), offset, 16, seed);
      * </pre>
      *
-     * <p>Note: The sign extension bug in {@link #hash32(byte[], int, int, 
int)} does not affect
-     * this result as there are no bytes left over from dividing the length by 
4.<p>
-     *
      * @param data1 The first long to hash
      * @param data2 The second long to hash
      * @return The 32-bit hash
-     * @see #hash32(byte[], int, int, int)
+     * @see #hash32x86(byte[], int, int, int)
      */
     public static int hash32(final long data1, final long data2) {
         return hash32(data1, data2, DEFAULT_SEED);
@@ -128,20 +125,17 @@ public final class MurmurHash3 {
      *
      * <pre>
      * int offset = 0;
-     * int hash = MurmurHash3.hash32(ByteBuffer.allocate(16)
-     *                                         .putLong(data1)
-     *                                         .putLong(data2)
-     *                                         .array(), offset, 16, seed);
+     * int hash = MurmurHash3.hash32x86(ByteBuffer.allocate(16)
+     *                                            .putLong(data1)
+     *                                            .putLong(data2)
+     *                                            .array(), offset, 16, seed);
      * </pre>
      *
-     * <p>Note: The sign extension bug in {@link #hash32(byte[], int, int, 
int)} does not affect
-     * this result as there are no bytes left over from dividing the length by 
4.<p>
-     *
      * @param data1 The first long to hash
      * @param data2 The second long to hash
      * @param seed The initial seed value
      * @return The 32-bit hash
-     * @see #hash32(byte[], int, int, int)
+     * @see #hash32x86(byte[], int, int, int)
      */
     public static int hash32(final long data1, final long data2, final int 
seed) {
         int hash = seed;
@@ -164,17 +158,14 @@ public final class MurmurHash3 {
      * <pre>
      * int offset = 0;
      * int seed = 104729;
-     * int hash = MurmurHash3.hash32(ByteBuffer.allocate(8)
-     *                                         .putLong(data)
-     *                                         .array(), offset, 8, seed);
+     * int hash = MurmurHash3.hash32x86(ByteBuffer.allocate(8)
+     *                                            .putLong(data)
+     *                                            .array(), offset, 8, seed);
      * </pre>
      *
-     * <p>Note: The sign extension bug in {@link #hash32(byte[], int, int, 
int)} does not affect
-     * this result as there are no bytes left over from dividing the length by 
4.<p>
-     *
      * @param data The long to hash
      * @return The 32-bit hash
-     * @see #hash32(byte[], int, int, int)
+     * @see #hash32x86(byte[], int, int, int)
      */
     public static int hash32(final long data) {
         return hash32(data, DEFAULT_SEED);
@@ -186,18 +177,15 @@ public final class MurmurHash3 {
      *
      * <pre>
      * int offset = 0;
-     * int hash = MurmurHash3.hash32(ByteBuffer.allocate(8)
-     *                                         .putLong(data)
-     *                                         .array(), offset, 8, seed);
+     * int hash = MurmurHash3.hash32x86(ByteBuffer.allocate(8)
+     *                                            .putLong(data)
+     *                                            .array(), offset, 8, seed);
      * </pre>
      *
-     * <p>Note: The sign extension bug in {@link #hash32(byte[], int, int, 
int)} does not affect
-     * this result as there are no bytes left over from dividing the length by 
4.<p>
-     *
      * @param data The long to hash
      * @param seed The initial seed value
      * @return The 32-bit hash
-     * @see #hash32(byte[], int, int, int)
+     * @see #hash32x86(byte[], int, int, int)
      */
     public static int hash32(final long data, final int seed) {
         int hash = seed;
diff --git a/src/test/java/org/apache/commons/codec/digest/MurmurHash3Test.java 
b/src/test/java/org/apache/commons/codec/digest/MurmurHash3Test.java
index 1a902ef..4ba16cf 100644
--- a/src/test/java/org/apache/commons/codec/digest/MurmurHash3Test.java
+++ b/src/test/java/org/apache/commons/codec/digest/MurmurHash3Test.java
@@ -105,7 +105,7 @@ public class MurmurHash3Test {
             for (final long j : data) {
                 buffer.putLong(0, i);
                 buffer.putLong(MurmurHash3.LONG_BYTES, j);
-                Assert.assertEquals(MurmurHash3.hash32(bytes, offset, length, 
seed), MurmurHash3.hash32(i, j));
+                Assert.assertEquals(MurmurHash3.hash32x86(bytes, offset, 
length, seed), MurmurHash3.hash32(i, j));
             }
         }
     }
@@ -127,7 +127,7 @@ public class MurmurHash3Test {
             for (final long j : data) {
                 buffer.putLong(0, i);
                 buffer.putLong(MurmurHash3.LONG_BYTES, j);
-                Assert.assertEquals(MurmurHash3.hash32(bytes, offset, length, 
seed), MurmurHash3.hash32(i, j, seed));
+                Assert.assertEquals(MurmurHash3.hash32x86(bytes, offset, 
length, seed), MurmurHash3.hash32(i, j, seed));
             }
         }
     }
@@ -147,7 +147,7 @@ public class MurmurHash3Test {
         final long[] data = createLongTestData();
         for (final long i : data) {
             buffer.putLong(0, i);
-            Assert.assertEquals(MurmurHash3.hash32(bytes, offset, length, 
seed), MurmurHash3.hash32(i));
+            Assert.assertEquals(MurmurHash3.hash32x86(bytes, offset, length, 
seed), MurmurHash3.hash32(i));
         }
     }
 
@@ -166,7 +166,7 @@ public class MurmurHash3Test {
         final long[] data = createLongTestData();
         for (final long i : data) {
             buffer.putLong(0, i);
-            Assert.assertEquals(MurmurHash3.hash32(bytes, offset, length, 
seed), MurmurHash3.hash32(i, seed));
+            Assert.assertEquals(MurmurHash3.hash32x86(bytes, offset, length, 
seed), MurmurHash3.hash32(i, seed));
         }
     }
 

Reply via email to