MurmurHash3.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      https://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */

  17. package org.apache.commons.codec.digest;

  18. import org.apache.commons.codec.binary.StringUtils;

  19. /**
  20.  * Implements the MurmurHash3 32-bit and 128-bit hash functions.
  21.  *
  22.  * <p>
  23.  * MurmurHash is a non-cryptographic hash function suitable for general hash-based lookup. The name comes from two basic
  24.  * operations, multiply (MU) and rotate (R), used in its inner loop. Unlike cryptographic hash functions, it is not
  25.  * specifically designed to be difficult to reverse by an adversary, making it unsuitable for cryptographic purposes.
  26.  * </p>
  27.  *
  28.  * <p>
  29.  * This contains a Java port of the 32-bit hash function {@code MurmurHash3_x86_32} and the 128-bit hash function
  30.  * {@code MurmurHash3_x64_128} from Austin Appleby's original {@code c++} code in SMHasher.
  31.  * </p>
  32.  *
  33.  * <p>
  34.  * This is public domain code with no copyrights. From home page of
  35.  * <a href="https://github.com/aappleby/smhasher">SMHasher</a>:
  36.  * </p>
  37.  *
  38.  * <blockquote> "All MurmurHash versions are public domain software, and the author disclaims all copyright to their
  39.  * code." </blockquote>
  40.  *
  41.  * <p>
  42.  * Original adaption from Apache Hive. That adaption contains a {@code hash64} method that is not part of the original
  43.  * MurmurHash3 code. It is not recommended to use these methods. They will be removed in a future release. To obtain a
  44.  * 64-bit hash use half of the bits from the {@code hash128x64} methods using the input data converted to bytes.
  45.  * </p>
  46.  *
  47.  * @see <a href="https://en.wikipedia.org/wiki/MurmurHash">MurmurHash</a>
  48.  * @see <a href="https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp"> Original MurmurHash3 c++
  49.  *      code</a>
  50.  * @see <a href=
  51.  *      "https://github.com/apache/hive/blob/master/storage-api/src/java/org/apache/hive/common/util/Murmur3.java">
  52.  *      Apache Hive Murmer3</a>
  53.  * @since 1.13
  54.  */
  55. public final class MurmurHash3 {

  56.     /**
  57.      * Generates 32-bit hash from input bytes. Bytes can be added incrementally and the new
  58.      * hash computed.
  59.      *
  60.      * <p>This is an implementation of the 32-bit hash function {@code MurmurHash3_x86_32}
  61.      * from Austin Appleby's original MurmurHash3 {@code c++} code in SMHasher.</p>
  62.      *
  63.      * <p>This implementation contains a sign-extension bug in the finalization step of
  64.      * any bytes left over from dividing the length by 4. This manifests if any of these
  65.      * bytes are negative.</p>
  66.      *
  67.      * @deprecated Use IncrementalHash32x86. This corrects the processing of trailing bytes.
  68.      */
  69.     @Deprecated
  70.     public static class IncrementalHash32 extends IncrementalHash32x86 {

  71.         /**
  72.          * Constructs a new instance.
  73.          */
  74.         public IncrementalHash32() {
  75.             // empty
  76.         }

  77.         /**
  78.          * {@inheritDoc}
  79.          *
  80.          * <p>This implementation contains a sign-extension bug in the finalization step of
  81.          * any bytes left over from dividing the length by 4. This manifests if any of these
  82.          * bytes are negative.<p>
  83.          *
  84.          * @deprecated Use IncrementalHash32x86. This corrects the processing of trailing bytes.
  85.          */
  86.         @Override
  87.         @Deprecated
  88.         int finalise(final int hash, final int unprocessedLength, final byte[] unprocessed, final int totalLen) {
  89.             int result = hash;
  90.             // ************
  91.             // Note: This fails to apply masking using 0xff to the 3 remaining bytes.
  92.             // ************
  93.             int k1 = 0;
  94.             switch (unprocessedLength) {
  95.             case 3:
  96.                 k1 ^= unprocessed[2] << 16;
  97.             case 2:
  98.                 k1 ^= unprocessed[1] << 8;
  99.             case 1:
  100.                 k1 ^= unprocessed[0];

  101.                 // mix functions
  102.                 k1 *= C1_32;
  103.                 k1 = Integer.rotateLeft(k1, R1_32);
  104.                 k1 *= C2_32;
  105.                 result ^= k1;
  106.             }

  107.             // finalization
  108.             result ^= totalLen;
  109.             return fmix32(result);
  110.         }
  111.     }

  112.     /**
  113.      * Generates 32-bit hash from input bytes. Bytes can be added incrementally and the new
  114.      * hash computed.
  115.      *
  116.      * <p>This is an implementation of the 32-bit hash function {@code MurmurHash3_x86_32}
  117.      * from Austin Appleby's original MurmurHash3 {@code c++} code in SMHasher.</p>
  118.      *
  119.      * @since 1.14
  120.      */
  121.     public static class IncrementalHash32x86 {

  122.         /** The size of byte blocks that are processed together. */
  123.         private static final int BLOCK_SIZE = 4;

  124.         /**
  125.          * Combines the bytes using an Or operation ({@code | } in a little-endian representation
  126.          * of a 32-bit integer; byte 1 will be the least significant byte, byte 4 the most
  127.          * significant.
  128.          *
  129.          * @param b1 The first byte
  130.          * @param b2 The second byte
  131.          * @param b3 The third byte
  132.          * @param b4 The fourth byte
  133.          * @return The 32-bit integer
  134.          */
  135.         private static int orBytes(final byte b1, final byte b2, final byte b3, final byte b4) {
  136.             return b1 & 0xff | (b2 & 0xff) << 8 | (b3 & 0xff) << 16 | (b4 & 0xff) << 24;
  137.         }

  138.         /** Up to 3 unprocessed bytes from input data. */
  139.         private final byte[] unprocessed = new byte[3];

  140.         /** The number of unprocessed bytes in the tail data. */
  141.         private int unprocessedLength;

  142.         /** The total number of input bytes added since the start. */
  143.         private int totalLen;

  144.         /**
  145.          * The current running hash.
  146.          * This must be finalised to generate the 32-bit hash value.
  147.          */
  148.         private int hash;

  149.         /**
  150.          * Constructs a new instance.
  151.          */
  152.         public IncrementalHash32x86() {
  153.             // empty
  154.         }

  155.         /**
  156.          * Adds the byte array to the current incremental hash.
  157.          *
  158.          * @param data The input byte array
  159.          * @param offset The offset of data
  160.          * @param length The length of array
  161.          */
  162.         public final void add(final byte[] data, final int offset, final int length) {
  163.             if (length <= 0) {
  164.                 // Nothing to add
  165.                 return;
  166.             }
  167.             totalLen += length;

  168.             // Process the bytes in blocks of 4.
  169.             // New bytes must be added to any current unprocessed bytes,
  170.             // then processed in blocks of 4 and the remaining bytes saved:
  171.             //
  172.             //    |--|---------------------------|--|
  173.             // unprocessed
  174.             //                main block
  175.             //                                remaining

  176.             // Check if the unprocessed bytes and new bytes can fill a block of 4.
  177.             // Make this overflow safe in the event that length is Integer.MAX_VALUE.
  178.             // Equivalent to: (unprocessedLength + length < BLOCK_SIZE)
  179.             if (unprocessedLength + length - BLOCK_SIZE < 0) {
  180.                 // Not enough so add to the unprocessed bytes
  181.                 System.arraycopy(data, offset, unprocessed, unprocessedLength, length);
  182.                 unprocessedLength += length;
  183.                 return;
  184.             }

  185.             // Combine unprocessed bytes with new bytes.
  186.             final int newOffset;
  187.             final int newLength;
  188.             if (unprocessedLength > 0) {
  189.                 int k = -1;
  190.                 switch (unprocessedLength) {
  191.                 case 1:
  192.                     k = orBytes(unprocessed[0], data[offset], data[offset + 1], data[offset + 2]);
  193.                     break;
  194.                 case 2:
  195.                     k = orBytes(unprocessed[0], unprocessed[1], data[offset], data[offset + 1]);
  196.                     break;
  197.                 case 3:
  198.                     k = orBytes(unprocessed[0], unprocessed[1], unprocessed[2], data[offset]);
  199.                     break;
  200.                 default:
  201.                     throw new IllegalStateException("Unprocessed length should be 1, 2, or 3: " + unprocessedLength);
  202.                 }
  203.                 hash = mix32(k, hash);
  204.                 // Update the offset and length
  205.                 final int consumed = BLOCK_SIZE - unprocessedLength;
  206.                 newOffset = offset + consumed;
  207.                 newLength = length - consumed;
  208.             } else {
  209.                 newOffset = offset;
  210.                 newLength = length;
  211.             }

  212.             // Main processing of blocks of 4 bytes
  213.             final int nblocks = newLength >> 2;

  214.             for (int i = 0; i < nblocks; i++) {
  215.                 final int index = newOffset + (i << 2);
  216.                 final int k = getLittleEndianInt(data, index);
  217.                 hash = mix32(k, hash);
  218.             }

  219.             // Save left-over unprocessed bytes
  220.             final int consumed = nblocks << 2;
  221.             unprocessedLength = newLength - consumed;
  222.             if (unprocessedLength != 0) {
  223.                 System.arraycopy(data, newOffset + consumed, unprocessed, 0, unprocessedLength);
  224.             }
  225.         }

  226.         /**
  227.          * Generates the 32-bit hash value. Repeat calls to this method with no additional data
  228.          * will generate the same hash value.
  229.          *
  230.          * @return The 32-bit hash
  231.          */
  232.         public final int end() {
  233.             // Allow calling end() again after adding no data to return the same result.
  234.             return finalise(hash, unprocessedLength, unprocessed, totalLen);
  235.         }

  236.         /**
  237.          * Finalizes the running hash to the output 32-bit hash by processing remaining bytes
  238.          * and performing final mixing.
  239.          *
  240.          * @param hash The running hash
  241.          * @param unprocessedLength The number of unprocessed bytes in the tail data.
  242.          * @param unprocessed Up to 3 unprocessed bytes from input data.
  243.          * @param totalLen The total number of input bytes added since the start.
  244.          * @return The 32-bit hash
  245.          */
  246.         int finalise(final int hash, final int unprocessedLength, final byte[] unprocessed, final int totalLen) {
  247.             int result = hash;
  248.             int k1 = 0;
  249.             switch (unprocessedLength) {
  250.             case 3:
  251.                 k1 ^= (unprocessed[2] & 0xff) << 16;
  252.             case 2:
  253.                 k1 ^= (unprocessed[1] & 0xff) << 8;
  254.             case 1:
  255.                 k1 ^= unprocessed[0] & 0xff;

  256.                 // mix functions
  257.                 k1 *= C1_32;
  258.                 k1 = Integer.rotateLeft(k1, R1_32);
  259.                 k1 *= C2_32;
  260.                 result ^= k1;
  261.             }

  262.             // finalization
  263.             result ^= totalLen;
  264.             return fmix32(result);
  265.         }

  266.         /**
  267.          * Starts a new incremental hash.
  268.          *
  269.          * @param seed The initial seed value
  270.          */
  271.         public final void start(final int seed) {
  272.             // Reset
  273.             unprocessedLength = totalLen = 0;
  274.             this.hash = seed;
  275.         }
  276.     }

  277.     /**
  278.      * A random number to use for a hash code.
  279.      *
  280.      * @deprecated This is not used internally and will be removed in a future release.
  281.      */
  282.     @Deprecated
  283.     public static final long NULL_HASHCODE = 2862933555777941757L;
  284.     /**
  285.      * A default seed to use for the murmur hash algorithm.
  286.      * Has the value {@code 104729}.
  287.      */
  288.     public static final int DEFAULT_SEED = 104729;
  289.     // Constants for 32-bit variant
  290.     private static final int C1_32 = 0xcc9e2d51;
  291.     private static final int C2_32 = 0x1b873593;
  292.     private static final int R1_32 = 15;
  293.     private static final int R2_32 = 13;

  294.     private static final int M_32 = 5;
  295.     private static final int N_32 = 0xe6546b64;
  296.     // Constants for 128-bit variant
  297.     private static final long C1 = 0x87c37b91114253d5L;
  298.     private static final long C2 = 0x4cf5ad432745937fL;
  299.     private static final int R1 = 31;
  300.     private static final int R2 = 27;
  301.     private static final int R3 = 33;
  302.     private static final int M = 5;

  303.     private static final int N1 = 0x52dce729;

  304.     private static final int N2 = 0x38495ab5;

  305.     /**
  306.      * Performs the final avalanche mix step of the 32-bit hash function {@code MurmurHash3_x86_32}.
  307.      *
  308.      * @param hash The current hash
  309.      * @return The final hash
  310.      */
  311.     private static int fmix32(int hash) {
  312.         hash ^= hash >>> 16;
  313.         hash *= 0x85ebca6b;
  314.         hash ^= hash >>> 13;
  315.         hash *= 0xc2b2ae35;
  316.         hash ^= hash >>> 16;
  317.         return hash;
  318.     }

  319.     /**
  320.      * Performs the final avalanche mix step of the 64-bit hash function {@code MurmurHash3_x64_128}.
  321.      *
  322.      * @param hash The current hash
  323.      * @return The final hash
  324.      */
  325.     private static long fmix64(long hash) {
  326.         hash ^= hash >>> 33;
  327.         hash *= 0xff51afd7ed558ccdL;
  328.         hash ^= hash >>> 33;
  329.         hash *= 0xc4ceb9fe1a85ec53L;
  330.         hash ^= hash >>> 33;
  331.         return hash;
  332.     }

  333.     /**
  334.      * Gets the little-endian int from 4 bytes starting at the specified index.
  335.      *
  336.      * @param data The data
  337.      * @param index The index
  338.      * @return The little-endian int
  339.      */
  340.     private static int getLittleEndianInt(final byte[] data, final int index) {
  341.         return data[index    ] & 0xff |
  342.                (data[index + 1] & 0xff) <<  8 |
  343.                (data[index + 2] & 0xff) << 16 |
  344.                (data[index + 3] & 0xff) << 24;
  345.     }

  346.     /**
  347.      * Gets the little-endian long from 8 bytes starting at the specified index.
  348.      *
  349.      * @param data The data
  350.      * @param index The index
  351.      * @return The little-endian long
  352.      */
  353.     private static long getLittleEndianLong(final byte[] data, final int index) {
  354.         return (long) data[index    ] & 0xff |
  355.                ((long) data[index + 1] & 0xff) <<  8 |
  356.                ((long) data[index + 2] & 0xff) << 16 |
  357.                ((long) data[index + 3] & 0xff) << 24 |
  358.                ((long) data[index + 4] & 0xff) << 32 |
  359.                ((long) data[index + 5] & 0xff) << 40 |
  360.                ((long) data[index + 6] & 0xff) << 48 |
  361.                ((long) data[index + 7] & 0xff) << 56;
  362.     }

  363.     /**
  364.      * Generates 128-bit hash from the byte array with a default seed.
  365.      * This is a helper method that will produce the same result as:
  366.      *
  367.      * <pre>
  368.      * int offset = 0;
  369.      * int seed = 104729;
  370.      * int hash = MurmurHash3.hash128(data, offset, data.length, seed);
  371.      * </pre>
  372.      *
  373.      * <p>Note: The sign extension bug in {@link #hash128(byte[], int, int, int)} does not effect
  374.      * this result as the default seed is positive.</p>
  375.      *
  376.      * @param data The input byte array
  377.      * @return The 128-bit hash (2 longs)
  378.      * @see #hash128(byte[], int, int, int)
  379.      */
  380.     public static long[] hash128(final byte[] data) {
  381.         return hash128(data, 0, data.length, DEFAULT_SEED);
  382.     }

  383.     /**
  384.      * Generates 128-bit hash from the byte array with the given offset, length and seed.
  385.      *
  386.      * <p>This is an implementation of the 128-bit hash function {@code MurmurHash3_x64_128}
  387.      * from Austin Appleby's original MurmurHash3 {@code c++} code in SMHasher.</p>
  388.      *
  389.      * <p>This implementation contains a sign-extension bug in the seed initialization.
  390.      * This manifests if the seed is negative.</p>
  391.      *
  392.      * @param data The input byte array
  393.      * @param offset The first element of array
  394.      * @param length The length of array
  395.      * @param seed The initial seed value
  396.      * @return The 128-bit hash (2 longs)
  397.      * @deprecated Use {@link #hash128x64(byte[], int, int, int)}. This corrects the seed initialization.
  398.      */
  399.     @Deprecated
  400.     public static long[] hash128(final byte[] data, final int offset, final int length, final int seed) {
  401.         // ************
  402.         // Note: This deliberately fails to apply masking using 0xffffffffL to the seed
  403.         // to maintain behavioral compatibility with the original version.
  404.         // The implicit conversion to a long will extend a negative sign
  405.         // bit through the upper 32-bits of the long seed. These should be zero.
  406.         // ************
  407.         return hash128x64Internal(data, offset, length, seed);
  408.     }

  409.     /**
  410.      * Generates 128-bit hash from a string with a default seed.
  411.      * <p>
  412.      * Before 1.14 the string was converted using default encoding.
  413.      * Since 1.14 the string is converted to bytes using UTF-8 encoding.
  414.      * </p>
  415.      * <p>
  416.      * This is a helper method that will produce the same result as:
  417.      * </p>
  418.      *
  419.      * <pre>
  420.      * int offset = 0;
  421.      * int seed = 104729;
  422.      * byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
  423.      * int hash = MurmurHash3.hash128(bytes, offset, bytes.length, seed);
  424.      * </pre>
  425.      *
  426.      * <p>Note: The sign extension bug in {@link #hash128(byte[], int, int, int)} does not effect
  427.      * this result as the default seed is positive.</p>
  428.      *
  429.      * @param data The input String
  430.      * @return The 128-bit hash (2 longs)
  431.      * @see #hash128(byte[], int, int, int)
  432.      * @deprecated Use {@link #hash128x64(byte[])} using the bytes returned from
  433.      * {@link String#getBytes(java.nio.charset.Charset)}.
  434.      */
  435.     @Deprecated
  436.     public static long[] hash128(final String data) {
  437.         final byte[] bytes = StringUtils.getBytesUtf8(data);
  438.         return hash128(bytes, 0, bytes.length, DEFAULT_SEED);
  439.     }

  440.     /**
  441.      * Generates 128-bit hash from the byte array with a seed of zero.
  442.      * This is a helper method that will produce the same result as:
  443.      *
  444.      * <pre>
  445.      * int offset = 0;
  446.      * int seed = 0;
  447.      * int hash = MurmurHash3.hash128x64(data, offset, data.length, seed);
  448.      * </pre>
  449.      *
  450.      * @param data The input byte array
  451.      * @return The 128-bit hash (2 longs)
  452.      * @see #hash128x64(byte[], int, int, int)
  453.      * @since 1.14
  454.      */
  455.     public static long[] hash128x64(final byte[] data) {
  456.         return hash128x64(data, 0, data.length, 0);
  457.     }

  458.     /**
  459.      * Generates 128-bit hash from the byte array with the given offset, length and seed.
  460.      *
  461.      * <p>This is an implementation of the 128-bit hash function {@code MurmurHash3_x64_128}
  462.      * from Austin Appleby's original MurmurHash3 {@code c++} code in SMHasher.</p>
  463.      *
  464.      * @param data The input byte array
  465.      * @param offset The first element of array
  466.      * @param length The length of array
  467.      * @param seed The initial seed value
  468.      * @return The 128-bit hash (2 longs)
  469.      * @since 1.14
  470.      */
  471.     public static long[] hash128x64(final byte[] data, final int offset, final int length, final int seed) {
  472.         // Use an unsigned 32-bit integer as the seed
  473.         return hash128x64Internal(data, offset, length, seed & 0xffffffffL);
  474.     }

  475.     /**
  476.      * Generates 128-bit hash from the byte array with the given offset, length and seed.
  477.      *
  478.      * <p>This is an implementation of the 128-bit hash function {@code MurmurHash3_x64_128}
  479.      * from Austin Appleby's original MurmurHash3 {@code c++} code in SMHasher.</p>
  480.      *
  481.      * @param data The input byte array
  482.      * @param offset The first element of array
  483.      * @param length The length of array
  484.      * @param seed The initial seed value
  485.      * @return The 128-bit hash (2 longs)
  486.      */
  487.     private static long[] hash128x64Internal(final byte[] data, final int offset, final int length, final long seed) {
  488.         long h1 = seed;
  489.         long h2 = seed;
  490.         final int nblocks = length >> 4;

  491.         // body
  492.         for (int i = 0; i < nblocks; i++) {
  493.             final int index = offset + (i << 4);
  494.             long k1 = getLittleEndianLong(data, index);
  495.             long k2 = getLittleEndianLong(data, index + 8);

  496.             // mix functions for k1
  497.             k1 *= C1;
  498.             k1 = Long.rotateLeft(k1, R1);
  499.             k1 *= C2;
  500.             h1 ^= k1;
  501.             h1 = Long.rotateLeft(h1, R2);
  502.             h1 += h2;
  503.             h1 = h1 * M + N1;

  504.             // mix functions for k2
  505.             k2 *= C2;
  506.             k2 = Long.rotateLeft(k2, R3);
  507.             k2 *= C1;
  508.             h2 ^= k2;
  509.             h2 = Long.rotateLeft(h2, R1);
  510.             h2 += h1;
  511.             h2 = h2 * M + N2;
  512.         }

  513.         // tail
  514.         long k1 = 0;
  515.         long k2 = 0;
  516.         final int index = offset + (nblocks << 4);
  517.         switch (offset + length - index) {
  518.         case 15:
  519.             k2 ^= ((long) data[index + 14] & 0xff) << 48;
  520.         case 14:
  521.             k2 ^= ((long) data[index + 13] & 0xff) << 40;
  522.         case 13:
  523.             k2 ^= ((long) data[index + 12] & 0xff) << 32;
  524.         case 12:
  525.             k2 ^= ((long) data[index + 11] & 0xff) << 24;
  526.         case 11:
  527.             k2 ^= ((long) data[index + 10] & 0xff) << 16;
  528.         case 10:
  529.             k2 ^= ((long) data[index + 9] & 0xff) << 8;
  530.         case 9:
  531.             k2 ^= data[index + 8] & 0xff;
  532.             k2 *= C2;
  533.             k2 = Long.rotateLeft(k2, R3);
  534.             k2 *= C1;
  535.             h2 ^= k2;

  536.         case 8:
  537.             k1 ^= ((long) data[index + 7] & 0xff) << 56;
  538.         case 7:
  539.             k1 ^= ((long) data[index + 6] & 0xff) << 48;
  540.         case 6:
  541.             k1 ^= ((long) data[index + 5] & 0xff) << 40;
  542.         case 5:
  543.             k1 ^= ((long) data[index + 4] & 0xff) << 32;
  544.         case 4:
  545.             k1 ^= ((long) data[index + 3] & 0xff) << 24;
  546.         case 3:
  547.             k1 ^= ((long) data[index + 2] & 0xff) << 16;
  548.         case 2:
  549.             k1 ^= ((long) data[index + 1] & 0xff) << 8;
  550.         case 1:
  551.             k1 ^= data[index] & 0xff;
  552.             k1 *= C1;
  553.             k1 = Long.rotateLeft(k1, R1);
  554.             k1 *= C2;
  555.             h1 ^= k1;
  556.         }

  557.         // finalization
  558.         h1 ^= length;
  559.         h2 ^= length;

  560.         h1 += h2;
  561.         h2 += h1;

  562.         h1 = fmix64(h1);
  563.         h2 = fmix64(h2);

  564.         h1 += h2;
  565.         h2 += h1;

  566.         return new long[] { h1, h2 };
  567.     }

  568.     /**
  569.      * Generates 32-bit hash from the byte array with a default seed.
  570.      * This is a helper method that will produce the same result as:
  571.      *
  572.      * <pre>
  573.      * int offset = 0;
  574.      * int seed = 104729;
  575.      * int hash = MurmurHash3.hash32(data, offset, data.length, seed);
  576.      * </pre>
  577.      *
  578.      * <p>This implementation contains a sign-extension bug in the finalization step of
  579.      * any bytes left over from dividing the length by 4. This manifests if any of these
  580.      * bytes are negative.</p>
  581.      *
  582.      * @param data The input byte array
  583.      * @return The 32-bit hash
  584.      * @see #hash32(byte[], int, int, int)
  585.      * @deprecated Use {@link #hash32x86(byte[], int, int, int)}. This corrects the processing of trailing bytes.
  586.      */
  587.     @Deprecated
  588.     public static int hash32(final byte[] data) {
  589.         return hash32(data, 0, data.length, DEFAULT_SEED);
  590.     }

  591.     /**
  592.      * Generates 32-bit hash from the byte array with the given length and a default seed.
  593.      * This is a helper method that will produce the same result as:
  594.      *
  595.      * <pre>
  596.      * int offset = 0;
  597.      * int seed = 104729;
  598.      * int hash = MurmurHash3.hash32(data, offset, length, seed);
  599.      * </pre>
  600.      *
  601.      * <p>This implementation contains a sign-extension bug in the finalization step of
  602.      * any bytes left over from dividing the length by 4. This manifests if any of these
  603.      * bytes are negative.</p>
  604.      *
  605.      * @param data The input byte array
  606.      * @param length The length of array
  607.      * @return The 32-bit hash
  608.      * @see #hash32(byte[], int, int, int)
  609.      * @deprecated Use {@link #hash32x86(byte[], int, int, int)}. This corrects the processing of trailing bytes.
  610.      */
  611.     @Deprecated
  612.     public static int hash32(final byte[] data, final int length) {
  613.         return hash32(data, length, DEFAULT_SEED);
  614.     }

  615.     /**
  616.      * Generates 32-bit hash from the byte array with the given length and seed. This is a
  617.      * helper method that will produce the same result as:
  618.      *
  619.      * <pre>
  620.      * int offset = 0;
  621.      * int hash = MurmurHash3.hash32(data, offset, length, seed);
  622.      * </pre>
  623.      *
  624.      * <p>This implementation contains a sign-extension bug in the finalization step of
  625.      * any bytes left over from dividing the length by 4. This manifests if any of these
  626.      * bytes are negative.</p>
  627.      *
  628.      * @param data The input byte array
  629.      * @param length The length of array
  630.      * @param seed The initial seed value
  631.      * @return The 32-bit hash
  632.      * @see #hash32(byte[], int, int, int)
  633.      * @deprecated Use {@link #hash32x86(byte[], int, int, int)}. This corrects the processing of trailing bytes.
  634.      */
  635.     @Deprecated
  636.     public static int hash32(final byte[] data, final int length, final int seed) {
  637.         return hash32(data, 0, length, seed);
  638.     }

  639.     /**
  640.      * Generates 32-bit hash from the byte array with the given offset, length and seed.
  641.      *
  642.      * <p>This is an implementation of the 32-bit hash function {@code MurmurHash3_x86_32}
  643.      * from Austin Appleby's original MurmurHash3 {@code c++} code in SMHasher.</p>
  644.      *
  645.      * <p>This implementation contains a sign-extension bug in the finalization step of
  646.      * any bytes left over from dividing the length by 4. This manifests if any of these
  647.      * bytes are negative.</p>
  648.      *
  649.      * @param data The input byte array
  650.      * @param offset The offset of data
  651.      * @param length The length of array
  652.      * @param seed The initial seed value
  653.      * @return The 32-bit hash
  654.      * @deprecated Use {@link #hash32x86(byte[], int, int, int)}. This corrects the processing of trailing bytes.
  655.      */
  656.     @Deprecated
  657.     public static int hash32(final byte[] data, final int offset, final int length, final int seed) {
  658.         int hash = seed;
  659.         final int nblocks = length >> 2;

  660.         // body
  661.         for (int i = 0; i < nblocks; i++) {
  662.             final int index = offset + (i << 2);
  663.             final int k = getLittleEndianInt(data, index);
  664.             hash = mix32(k, hash);
  665.         }

  666.         // tail
  667.         // ************
  668.         // Note: This fails to apply masking using 0xff to the 3 remaining bytes.
  669.         // ************
  670.         final int index = offset + (nblocks << 2);
  671.         int k1 = 0;
  672.         switch (offset + length - index) {
  673.         case 3:
  674.             k1 ^= data[index + 2] << 16;
  675.         case 2:
  676.             k1 ^= data[index + 1] << 8;
  677.         case 1:
  678.             k1 ^= data[index];

  679.             // mix functions
  680.             k1 *= C1_32;
  681.             k1 = Integer.rotateLeft(k1, R1_32);
  682.             k1 *= C2_32;
  683.             hash ^= k1;
  684.         }

  685.         hash ^= length;
  686.         return fmix32(hash);
  687.     }

  688.     /**
  689.      * Generates 32-bit hash from a long with a default seed value.
  690.      * This is a helper method that will produce the same result as:
  691.      *
  692.      * <pre>
  693.      * int offset = 0;
  694.      * int seed = 104729;
  695.      * int hash = MurmurHash3.hash32x86(ByteBuffer.allocate(8)
  696.      *                                            .putLong(data)
  697.      *                                            .array(), offset, 8, seed);
  698.      * </pre>
  699.      *
  700.      * @param data The long to hash
  701.      * @return The 32-bit hash
  702.      * @see #hash32x86(byte[], int, int, int)
  703.      */
  704.     public static int hash32(final long data) {
  705.         return hash32(data, DEFAULT_SEED);
  706.     }

  707.     /**
  708.      * Generates 32-bit hash from a long with the given seed.
  709.      * This is a helper method that will produce the same result as:
  710.      *
  711.      * <pre>
  712.      * int offset = 0;
  713.      * int hash = MurmurHash3.hash32x86(ByteBuffer.allocate(8)
  714.      *                                            .putLong(data)
  715.      *                                            .array(), offset, 8, seed);
  716.      * </pre>
  717.      *
  718.      * @param data The long to hash
  719.      * @param seed The initial seed value
  720.      * @return The 32-bit hash
  721.      * @see #hash32x86(byte[], int, int, int)
  722.      */
  723.     public static int hash32(final long data, final int seed) {
  724.         int hash = seed;
  725.         final long r0 = Long.reverseBytes(data);

  726.         hash = mix32((int) r0, hash);
  727.         hash = mix32((int) (r0 >>> 32), hash);

  728.         hash ^= Long.BYTES;
  729.         return fmix32(hash);
  730.     }

  731.     /**
  732.      * Generates 32-bit hash from two longs with a default seed value.
  733.      * This is a helper method that will produce the same result as:
  734.      *
  735.      * <pre>
  736.      * int offset = 0;
  737.      * int seed = 104729;
  738.      * int hash = MurmurHash3.hash32x86(ByteBuffer.allocate(16)
  739.      *                                            .putLong(data1)
  740.      *                                            .putLong(data2)
  741.      *                                            .array(), offset, 16, seed);
  742.      * </pre>
  743.      *
  744.      * @param data1 The first long to hash
  745.      * @param data2 The second long to hash
  746.      * @return The 32-bit hash
  747.      * @see #hash32x86(byte[], int, int, int)
  748.      */
  749.     public static int hash32(final long data1, final long data2) {
  750.         return hash32(data1, data2, DEFAULT_SEED);
  751.     }

  752.     /**
  753.      * Generates 32-bit hash from two longs with the given seed.
  754.      * This is a helper method that will produce the same result as:
  755.      *
  756.      * <pre>
  757.      * int offset = 0;
  758.      * int hash = MurmurHash3.hash32x86(ByteBuffer.allocate(16)
  759.      *                                            .putLong(data1)
  760.      *                                            .putLong(data2)
  761.      *                                            .array(), offset, 16, seed);
  762.      * </pre>
  763.      *
  764.      * @param data1 The first long to hash
  765.      * @param data2 The second long to hash
  766.      * @param seed The initial seed value
  767.      * @return The 32-bit hash
  768.      * @see #hash32x86(byte[], int, int, int)
  769.      */
  770.     public static int hash32(final long data1, final long data2, final int seed) {
  771.         int hash = seed;
  772.         final long r0 = Long.reverseBytes(data1);
  773.         final long r1 = Long.reverseBytes(data2);

  774.         hash = mix32((int) r0, hash);
  775.         hash = mix32((int) (r0 >>> 32), hash);
  776.         hash = mix32((int) r1, hash);
  777.         hash = mix32((int) (r1 >>> 32), hash);

  778.         hash ^= Long.BYTES * 2;
  779.         return fmix32(hash);
  780.     }

  781.     /**
  782.      * Generates 32-bit hash from a string with a default seed.
  783.      * <p>
  784.      * Before 1.14 the string was converted using default encoding.
  785.      * Since 1.14 the string is converted to bytes using UTF-8 encoding.
  786.      * </p>
  787.      * This is a helper method that will produce the same result as:
  788.      *
  789.      * <pre>
  790.      * int offset = 0;
  791.      * int seed = 104729;
  792.      * byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
  793.      * int hash = MurmurHash3.hash32(bytes, offset, bytes.length, seed);
  794.      * </pre>
  795.      *
  796.      * <p>This implementation contains a sign-extension bug in the finalization step of
  797.      * any bytes left over from dividing the length by 4. This manifests if any of these
  798.      * bytes are negative.</p>
  799.      *
  800.      * @param data The input string
  801.      * @return The 32-bit hash
  802.      * @see #hash32(byte[], int, int, int)
  803.      * @deprecated Use {@link #hash32x86(byte[], int, int, int)} with the bytes returned from
  804.      * {@link String#getBytes(java.nio.charset.Charset)}. This corrects the processing of trailing bytes.
  805.      */
  806.     @Deprecated
  807.     public static int hash32(final String data) {
  808.         final byte[] bytes = StringUtils.getBytesUtf8(data);
  809.         return hash32(bytes, 0, bytes.length, DEFAULT_SEED);
  810.     }

  811.     /**
  812.      * Generates 32-bit hash from the byte array with a seed of zero.
  813.      * This is a helper method that will produce the same result as:
  814.      *
  815.      * <pre>
  816.      * int offset = 0;
  817.      * int seed = 0;
  818.      * int hash = MurmurHash3.hash32x86(data, offset, data.length, seed);
  819.      * </pre>
  820.      *
  821.      * @param data The input byte array
  822.      * @return The 32-bit hash
  823.      * @see #hash32x86(byte[], int, int, int)
  824.      * @since 1.14
  825.      */
  826.     public static int hash32x86(final byte[] data) {
  827.         return hash32x86(data, 0, data.length, 0);
  828.     }

  829.     /**
  830.      * Generates 32-bit hash from the byte array with the given offset, length and seed.
  831.      *
  832.      * <p>This is an implementation of the 32-bit hash function {@code MurmurHash3_x86_32}
  833.      * from Austin Appleby's original MurmurHash3 {@code c++} code in SMHasher.</p>
  834.      *
  835.      * @param data The input byte array
  836.      * @param offset The offset of data
  837.      * @param length The length of array
  838.      * @param seed The initial seed value
  839.      * @return The 32-bit hash
  840.      * @since 1.14
  841.      */
  842.     public static int hash32x86(final byte[] data, final int offset, final int length, final int seed) {
  843.         int hash = seed;
  844.         final int nblocks = length >> 2;

  845.         // body
  846.         for (int i = 0; i < nblocks; i++) {
  847.             final int index = offset + (i << 2);
  848.             final int k = getLittleEndianInt(data, index);
  849.             hash = mix32(k, hash);
  850.         }

  851.         // tail
  852.         final int index = offset + (nblocks << 2);
  853.         int k1 = 0;
  854.         switch (offset + length - index) {
  855.         case 3:
  856.             k1 ^= (data[index + 2] & 0xff) << 16;
  857.         case 2:
  858.             k1 ^= (data[index + 1] & 0xff) << 8;
  859.         case 1:
  860.             k1 ^= data[index] & 0xff;

  861.             // mix functions
  862.             k1 *= C1_32;
  863.             k1 = Integer.rotateLeft(k1, R1_32);
  864.             k1 *= C2_32;
  865.             hash ^= k1;
  866.         }

  867.         hash ^= length;
  868.         return fmix32(hash);
  869.     }

  870.     /**
  871.      * Generates 64-bit hash from a byte array with a default seed.
  872.      *
  873.      * <p><strong>This is not part of the original MurmurHash3 {@code c++} implementation.</strong></p>
  874.      *
  875.      * <p>This is a Murmur3-like 64-bit variant.
  876.      * The method does not produce the same result as either half of the hash bytes from
  877.      * {@linkplain #hash128x64(byte[])} with the same byte data.
  878.      * This method will be removed in a future release.</p>
  879.      *
  880.      * <p>Note: The sign extension bug in {@link #hash64(byte[], int, int, int)} does not effect
  881.      * this result as the default seed is positive.</p>
  882.      *
  883.      * <p>This is a helper method that will produce the same result as:</p>
  884.      *
  885.      * <pre>
  886.      * int offset = 0;
  887.      * int seed = 104729;
  888.      * long hash = MurmurHash3.hash64(data, offset, data.length, seed);
  889.      * </pre>
  890.      *
  891.      * @param data The input byte array
  892.      * @return The 64-bit hash
  893.      * @see #hash64(byte[], int, int, int)
  894.      * @deprecated Not part of the MurmurHash3 implementation.
  895.      * Use half of the hash bytes from {@link #hash128x64(byte[])}.
  896.      */
  897.     @Deprecated
  898.     public static long hash64(final byte[] data) {
  899.         return hash64(data, 0, data.length, DEFAULT_SEED);
  900.     }

  901.     /**
  902.      * Generates 64-bit hash from a byte array with the given offset and length and a default seed.
  903.      *
  904.      * <p><strong>This is not part of the original MurmurHash3 {@code c++} implementation.</strong></p>
  905.      *
  906.      * <p>This is a Murmur3-like 64-bit variant.
  907.      * The method does not produce the same result as either half of the hash bytes from
  908.      * {@linkplain #hash128x64(byte[])} with the same byte data.
  909.      * This method will be removed in a future release.</p>
  910.      *
  911.      * <p>Note: The sign extension bug in {@link #hash64(byte[], int, int, int)} does not effect
  912.      * this result as the default seed is positive.</p>
  913.      *
  914.      * <p>This is a helper method that will produce the same result as:</p>
  915.      *
  916.      * <pre>
  917.      * int seed = 104729;
  918.      * long hash = MurmurHash3.hash64(data, offset, length, seed);
  919.      * </pre>
  920.      *
  921.      * @param data The input byte array
  922.      * @param offset The offset of data
  923.      * @param length The length of array
  924.      * @return The 64-bit hash
  925.      * @see #hash64(byte[], int, int, int)
  926.      * @deprecated Not part of the MurmurHash3 implementation.
  927.      * Use half of the hash bytes from {@link #hash128x64(byte[], int, int, int)}.
  928.      */
  929.     @Deprecated
  930.     public static long hash64(final byte[] data, final int offset, final int length) {
  931.         return hash64(data, offset, length, DEFAULT_SEED);
  932.     }

  933.     /**
  934.      * Generates 64-bit hash from a byte array with the given offset, length and seed.
  935.      *
  936.      * <p><strong>This is not part of the original MurmurHash3 {@code c++} implementation.</strong></p>
  937.      *
  938.      * <p>This is a Murmur3-like 64-bit variant.
  939.      * This method will be removed in a future release.</p>
  940.      *
  941.      * <p>This implementation contains a sign-extension bug in the seed initialization.
  942.      * This manifests if the seed is negative.</p>
  943.      *
  944.      * <p>This algorithm processes 8 bytes chunks of data in a manner similar to the 16 byte chunks
  945.      * of data processed in the MurmurHash3 {@code MurmurHash3_x64_128} method. However the hash
  946.      * is not mixed with a hash chunk from the next 8 bytes of data. The method will not return
  947.      * the same value as the first or second 64-bits of the function
  948.      * {@link #hash128(byte[], int, int, int)}.</p>
  949.      *
  950.      * <p>Use of this method is not advised. Use the first long returned from
  951.      * {@link #hash128x64(byte[], int, int, int)}.</p>
  952.      *
  953.      * @param data The input byte array
  954.      * @param offset The offset of data
  955.      * @param length The length of array
  956.      * @param seed The initial seed value
  957.      * @return The 64-bit hash
  958.      * @deprecated Not part of the MurmurHash3 implementation.
  959.      * Use half of the hash bytes from {@link #hash128x64(byte[], int, int, int)}.
  960.      */
  961.     @Deprecated
  962.     public static long hash64(final byte[] data, final int offset, final int length, final int seed) {
  963.         //
  964.         // Note: This fails to apply masking using 0xffffffffL to the seed.
  965.         //
  966.         long hash = seed;
  967.         final int nblocks = length >> 3;

  968.         // body
  969.         for (int i = 0; i < nblocks; i++) {
  970.             final int index = offset + (i << 3);
  971.             long k = getLittleEndianLong(data, index);

  972.             // mix functions
  973.             k *= C1;
  974.             k = Long.rotateLeft(k, R1);
  975.             k *= C2;
  976.             hash ^= k;
  977.             hash = Long.rotateLeft(hash, R2) * M + N1;
  978.         }

  979.         // tail
  980.         long k1 = 0;
  981.         final int index = offset + (nblocks << 3);
  982.         switch (offset + length - index) {
  983.         case 7:
  984.             k1 ^= ((long) data[index + 6] & 0xff) << 48;
  985.         case 6:
  986.             k1 ^= ((long) data[index + 5] & 0xff) << 40;
  987.         case 5:
  988.             k1 ^= ((long) data[index + 4] & 0xff) << 32;
  989.         case 4:
  990.             k1 ^= ((long) data[index + 3] & 0xff) << 24;
  991.         case 3:
  992.             k1 ^= ((long) data[index + 2] & 0xff) << 16;
  993.         case 2:
  994.             k1 ^= ((long) data[index + 1] & 0xff) << 8;
  995.         case 1:
  996.             k1 ^= (long) data[index] & 0xff;
  997.             k1 *= C1;
  998.             k1 = Long.rotateLeft(k1, R1);
  999.             k1 *= C2;
  1000.             hash ^= k1;
  1001.         }

  1002.         // finalization
  1003.         hash ^= length;
  1004.         return fmix64(hash);
  1005.     }

  1006.     /**
  1007.      * Generates 64-bit hash from an int with a default seed.
  1008.      *
  1009.      * <p><strong>This is not part of the original MurmurHash3 {@code c++} implementation.</strong></p>
  1010.      *
  1011.      * <p>This is a Murmur3-like 64-bit variant.
  1012.      * The method does not produce the same result as either half of the hash bytes from
  1013.      * {@linkplain #hash128x64(byte[])} with the same byte data from the {@code int}.
  1014.      * This method will be removed in a future release.</p>
  1015.      *
  1016.      * <p>Note: The sign extension bug in {@link #hash64(byte[], int, int, int)} does not effect
  1017.      * this result as the default seed is positive.</p>
  1018.      *
  1019.      * <p>This is a helper method that will produce the same result as:</p>
  1020.      *
  1021.      * <pre>
  1022.      * int offset = 0;
  1023.      * int seed = 104729;
  1024.      * long hash = MurmurHash3.hash64(ByteBuffer.allocate(4)
  1025.      *                                          .putInt(data)
  1026.      *                                          .array(), offset, 4, seed);
  1027.      * </pre>
  1028.      *
  1029.      * @param data The int to hash
  1030.      * @return The 64-bit hash
  1031.      * @see #hash64(byte[], int, int, int)
  1032.      * @deprecated Not part of the MurmurHash3 implementation.
  1033.      * Use half of the hash bytes from {@link #hash128x64(byte[])} with the bytes from the {@code int}.
  1034.      */
  1035.     @Deprecated
  1036.     public static long hash64(final int data) {
  1037.         long k1 = Integer.reverseBytes(data) & -1L >>> 32;
  1038.         long hash = DEFAULT_SEED;
  1039.         k1 *= C1;
  1040.         k1 = Long.rotateLeft(k1, R1);
  1041.         k1 *= C2;
  1042.         hash ^= k1;
  1043.         // finalization
  1044.         hash ^= Integer.BYTES;
  1045.         return fmix64(hash);
  1046.     }

  1047.     /**
  1048.      * Generates 64-bit hash from a long with a default seed.
  1049.      *
  1050.      * <p><strong>This is not part of the original MurmurHash3 {@code c++} implementation.</strong></p>
  1051.      *
  1052.      * <p>This is a Murmur3-like 64-bit variant.
  1053.      * The method does not produce the same result as either half of the hash bytes from
  1054.      * {@linkplain #hash128x64(byte[])} with the same byte data from the {@code long}.
  1055.      * This method will be removed in a future release.</p>
  1056.      *
  1057.      * <p>Note: The sign extension bug in {@link #hash64(byte[], int, int, int)} does not effect
  1058.      * this result as the default seed is positive.</p>
  1059.      *
  1060.      * <p>This is a helper method that will produce the same result as:</p>
  1061.      *
  1062.      * <pre>
  1063.      * int offset = 0;
  1064.      * int seed = 104729;
  1065.      * long hash = MurmurHash3.hash64(ByteBuffer.allocate(8)
  1066.      *                                          .putLong(data)
  1067.      *                                          .array(), offset, 8, seed);
  1068.      * </pre>
  1069.      *
  1070.      * @param data The long to hash
  1071.      * @return The 64-bit hash
  1072.      * @see #hash64(byte[], int, int, int)
  1073.      * @deprecated Not part of the MurmurHash3 implementation.
  1074.      * Use half of the hash bytes from {@link #hash128x64(byte[])} with the bytes from the {@code long}.
  1075.      */
  1076.     @Deprecated
  1077.     public static long hash64(final long data) {
  1078.         long hash = DEFAULT_SEED;
  1079.         long k = Long.reverseBytes(data);
  1080.         // mix functions
  1081.         k *= C1;
  1082.         k = Long.rotateLeft(k, R1);
  1083.         k *= C2;
  1084.         hash ^= k;
  1085.         hash = Long.rotateLeft(hash, R2) * M + N1;
  1086.         // finalization
  1087.         hash ^= Long.BYTES;
  1088.         return fmix64(hash);
  1089.     }

  1090.     /**
  1091.      * Generates 64-bit hash from a short with a default seed.
  1092.      *
  1093.      * <p><strong>This is not part of the original MurmurHash3 {@code c++} implementation.</strong></p>
  1094.      *
  1095.      * <p>This is a Murmur3-like 64-bit variant.
  1096.      * The method does not produce the same result as either half of the hash bytes from
  1097.      * {@linkplain #hash128x64(byte[])} with the same byte data from the {@code short}.
  1098.      * This method will be removed in a future release.</p>
  1099.      *
  1100.      * <p>Note: The sign extension bug in {@link #hash64(byte[], int, int, int)} does not effect
  1101.      * this result as the default seed is positive.</p>
  1102.      *
  1103.      * <p>This is a helper method that will produce the same result as:</p>
  1104.      *
  1105.      * <pre>
  1106.      * int offset = 0;
  1107.      * int seed = 104729;
  1108.      * long hash = MurmurHash3.hash64(ByteBuffer.allocate(2)
  1109.      *                                          .putShort(data)
  1110.      *                                          .array(), offset, 2, seed);
  1111.      * </pre>
  1112.      *
  1113.      * @param data The short to hash
  1114.      * @return The 64-bit hash
  1115.      * @see #hash64(byte[], int, int, int)
  1116.      * @deprecated Not part of the MurmurHash3 implementation.
  1117.      * Use half of the hash bytes from {@link #hash128x64(byte[])} with the bytes from the {@code short}.
  1118.      */
  1119.     @Deprecated
  1120.     public static long hash64(final short data) {
  1121.         long hash = DEFAULT_SEED;
  1122.         long k1 = 0;
  1123.         k1 ^= ((long) data & 0xff) << 8;
  1124.         k1 ^= (long) ((data & 0xFF00) >> 8) & 0xff;
  1125.         k1 *= C1;
  1126.         k1 = Long.rotateLeft(k1, R1);
  1127.         k1 *= C2;
  1128.         hash ^= k1;

  1129.         // finalization
  1130.         hash ^= Short.BYTES;
  1131.         return fmix64(hash);
  1132.     }

  1133.     /**
  1134.      * Performs the intermediate mix step of the 32-bit hash function {@code MurmurHash3_x86_32}.
  1135.      *
  1136.      * @param k The data to add to the hash
  1137.      * @param hash The current hash
  1138.      * @return The new hash
  1139.      */
  1140.     private static int mix32(int k, int hash) {
  1141.         k *= C1_32;
  1142.         k = Integer.rotateLeft(k, R1_32);
  1143.         k *= C2_32;
  1144.         hash ^= k;
  1145.         return Integer.rotateLeft(hash, R2_32) * M_32 + N_32;
  1146.     }

  1147.     /** No instance methods. */
  1148.     private MurmurHash3() {
  1149.     }
  1150. }