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

做~自己de王妃 提交于 2019-12-05 18:16:08
Paolo Falabella

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

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>

The following works for me:

import scala.util.hashing.MurmurHash3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!