agrim khanna February 2016

The method sipHash24() is undefined for the type Hashing

I was trying to use the sipHash24() hashing function from google guava, and it gave the following error,

The method sipHash24() is undefined for the type Hashing

I have included guava dependency in my pom.xml as

<dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>19.0</version>
</dependency>

I tried to include sipHash24() in the following way -

Hasher metaHash = Hashing.sipHash24().newHasher();

Instead of sipHash24(), other hashes such as murmur3_128() or md5 were allowed, but I want to use sipHash24() only as it is the only 64 bit hash in the given list.

I was able to use sipHash in another project of mine, where i built the project using gradle.

Answers


Konstantinos Chalkias February 2016

You need a value to get its hash output. Thus, each of the methods, such as putLong(long l), putString(String s) .... require an input (the one for which you compute its hash).

Also, you could use the most simplified method, so you reuse the HashFunction and type less code when required.

HashFunction sipHash = com.google.common.hash.Hashing.sipHash24();
String hash = sipHash.hashLong(3213123L).toString();

Just make sure you are using the latest Guava version.


Kurt Alfred Kluever February 2016

Sounds like you have two versions of Guava on your classpath, one with Hashing.sipHash24() (>= Guava 15.0) and one without it (< Guava 14.0).

Post Status

Asked in February 2016
Viewed 2,627 times
Voted 6
Answered 2 times

Search




Leave an answer