private void makeHashFunc()

in datafu-pig/src/main/java/datafu/pig/hash/Hasher.java [137:155]


  private void makeHashFunc(String algorithm) throws IllegalArgumentException, RuntimeException
  {
    if (hash_func != null) { throw new RuntimeException("The hash function should only be set once per instance"); }

    if (algorithm.startsWith("good-")) {
      int bits = Integer.parseInt(algorithm.substring(5));
      hash_func = Hashing.goodFastHash(bits);
    }
    else if (algorithm.equals("murmur3-32")) { hash_func = Hashing.murmur3_32();  }
    else if (algorithm.equals("murmur3-128")){ hash_func = Hashing.murmur3_128(); }
    else if (algorithm.equals("sip24"))      { hash_func = Hashing.sipHash24();   }
    else if (algorithm.equals("sha1"))       { hash_func = Hashing.sha1();        }
    else if (algorithm.equals("sha256"))     { hash_func = Hashing.sha256();      }
    else if (algorithm.equals("sha512"))     { hash_func = Hashing.sha512();      }
    else if (algorithm.equals("md5"))        { hash_func = Hashing.md5();         }
    else if (algorithm.equals("adler32"))    { hash_func = Hashing.adler32();     }
    else if (algorithm.equals("crc32"))      { hash_func = Hashing.crc32();       }
    else { throw new IllegalArgumentException("No hash function found for algorithm "+algorithm+". Allowed values include "+HASH_NAMES); }
  }