Java Murmur Hash murmurRehash(final int hash)

Here you can find the source of murmurRehash(final int hash)

Description

re-hashes a 4-byte sequence (Java int) using murmur3 hash algorithm.

License

Apache License

Parameter

Parameter Description
hash bad quality hash

Return

good general purpose hash

Declaration

public static int murmurRehash(final int hash) 

Method Source Code

//package com.java2s;
/**/*  w w w .  jav a  2s.  co m*/
 * Copyright (C) 2011-2012 Andrey Borisov <aandrey.borisov@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    /**
     * re-hashes a 4-byte sequence (Java int) using murmur3 hash algorithm.</p>
     * 
     * @param hash
     *            bad quality hash
     * @return good general purpose hash
     */
    public static int murmurRehash(final int hash) {
        int k = hash;

        k ^= k >>> 16;
        k *= 0x85ebca6b;
        k ^= k >>> 13;
        k *= 0xc2b2ae35;
        k ^= k >>> 16;

        return k;
    }
}

Related

  1. murmurHash3(int x)
  2. murmurHash3(int x)
  3. MurmurHash3_fmix(int k)
  4. murmurhash3x8632(byte[] data, int offset, int len, int seed)
  5. murmurMix(long h)