问题
I'm writing a BloomFilter and wanted to use Scala's default MurmurHash3 implementation: scala.util.MurmurHash3. My compile is failing however with the following compile error:
[error] /mnt/hgfs/dr/sandbox/dr-commons/src/main/scala/dr/commons/collection/BloomFilter.scala:214: MurmurHash3 is not a member of scala.util
[error] import scala.util.{MurmurHash3 => MH}
I'm using Scala 2.9.1 and sbt 0.11.2.
Is the MurmurHash3 class not in the 2.9.1 library by default? I assume it is since it's used a lot in the library. The class isn't package private as far as I see.
回答1:
It's called just scala.util.MurmurHash without the 3. But it's indeed the Murmurhash 3 algorithm (see the comments in the source)
EDIT I've just seen that Rex Kerr is the author of scala.util.MurmurHash. I would advise you not to accept this answer (assuming it's the correct one); since Rex Kerr is on StackOverflow he may chime in and give you a much better one...
回答2:
I am using scala 2.11 and spark apache 1.6.2 . Its working fine. With these versions I am not getting any error
import scala.util.hashing.{ MurmurHash3 => MH3 }
val data="I am SANTHOSH"
val sample = MH3.stringHash(data, MH3.stringSeed)
println(":Hash Value: "+sample)
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-mllib_2.11</artifactId>
<version>1.6.2</version>
</dependency>
回答3:
The following works for me:
import scala.util.hashing.MurmurHash3
来源:https://stackoverflow.com/questions/10048257/how-can-i-use-scalas-murmurhash-implementation-scala-util-murmurhash3