Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9262883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T13:27:06+00:00 2026-06-18T13:27:06+00:00

In Scala 2.10, MurmurHash for some reason is deprecated, saying I should use MurmurHash3

  • 0

In Scala 2.10, MurmurHash for some reason is deprecated, saying I should use MurmurHash3 now. But the API is different, and there is no useful scaladocs for MurmurHash3 -> fail.

For instance, current code:

trait Foo {
  type Bar
  def id: Int
  def path: Bar

  override def hashCode = {
    import util.MurmurHash._
    var h = startHash(2)
    val c = startMagicA
    val k = startMagicB
    h = extendHash(h, id, c, k)
    h = extendHash(h, path.##, nextMagicA(c), nextMagicB(k))
    finalizeHash(h)
  }
}

How would I do this using MurmurHash3 instead? This needs to be a fast operation, preferably without allocations, so I do not want to construct a Product, Seq, Array[Byte] or whathever MurmurHash3 seems to be offering me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T13:27:07+00:00Added an answer on June 18, 2026 at 1:27 pm

    The MurmurHash3 algorithm was changed, confusingly, from an algorithm that mixed in its own salt, essentially (c and k), to one that just does more bit-mixing. The basic operation is now mix, which you should fold over all your values, after which you should finalizeHash (the Int argument for length is for convenience also, to help with distinguishing collections of different length). If you want to replace your last mix by mixLast, it’s a little faster and removes redundancy with finalizeHash. If it takes you too long to detect what the last mix is, just mix.

    Typically for a collection you’ll want to mix in an extra value to indicate what type of collection it is.

    So minimally you’d have

    override def hashCode = finalizeHash(mixLast(id, path.##), 0)
    

    and “typically” you’d

    // Pick any string or number that suits you, put in companion object
    val fooSeed = MurmurHash3.stringHash("classOf[Foo]")   
    
    // I guess "id" plus "path" is two things?
    override def hashCode = finalizeHash(mixLast( mix(fooSeed,id), path.## ), 2)
    

    Note that the length field is NOT there to give a high-quality hash that mixes in that number. All mixing of important hash values should be done with mix.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scala provides a choice of different testing frameworks, but I wonder if there are
I'm writing a BloomFilter and wanted to use Scala's default MurmurHash3 implementation: scala.util.MurmurHash3. My
Scala includes the continuations plugin now (yay), but must be enabled by passing -P:continuations:enable
In Scala, there is a special type of access modifiers: protected[enclosing_scope]. But as soon
Scala programmer should have known that this sort of writing : class Person{ var
Scala/Play gurus out there. I'm trying to upload a file using AJAX, in Play
(Scala 2.7.7:) I don't get used to 2d-Arrays. Arrays are mutable, but how do
Scala has both a mutable and an immutable Map , but it has only
So Scala is supposed to be as fast as Java. I'm revisiting some Project
Scala has a number of traits that you can use as type classes, for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.