How can I use Scala's MurmurHash implementation: scala.util.MurmurHash3?
Asked Answered
S

3

5

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.

Sekofski answered 6/4, 2012 at 19:24 Comment(0)
S
4

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...

Stere answered 6/4, 2012 at 19:43 Comment(2)
Thanks. What's the scala.util.MurmurHash3 class, then?Sekofski
it seems to be the new version in scala 2.10Stere
F
4

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>
Figurate answered 2/2, 2017 at 5:10 Comment(1)
Actually I missed to add the version I use. I used the scala 2.11.8 and apache 1.6.2Figurate
S
1

The following works for me:

import scala.util.hashing.MurmurHash3

Syne answered 18/2, 2016 at 17:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.