scala,guava,consistent-hashing,murmurhash
It looks to me like Scala's hashString converts pairs of UTF-16 chars to ints differently than Guava's hashUnencodedChars (hashString with no Charset was renamed to that). Scala: val data = (str.charAt(i) << 16) + str.charAt(i + 1) Guava: int k1 = input.charAt(i - 1) | (input.charAt(i) << 16); In Guava,...
I have a murmurhash3 implementation in my FastDefaults unit at https://github.com/JBontes/FastCode Here's the sourcecode for Murmurhash3: {$pointermath on} function MurmurHash3(const [ref] HashData; Len: integer; Seed: integer = 0): integer; const c1 = $CC9E2D51; c2 = $1B873593; r1 = 15; r2 = 13; m = 5; n = $E6546B64; f1 =...
There are two problems I can see. First, C++ is using uint32_t, and giving you a value of 3,297,211,900. This number is larger than can fit in a signed 32-bit int, and Java uses only signed integers. However, -1,868,221,715 is not equal to 3,297,211,900, even accounting for the difference between...
algorithm,hash,cassandra,murmurhash
Thanks for giving me more details about the algorithm. I wrote a sample code in order to share the solution. byte[] keyBytes; try(ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(bos)) { String[] keys = new String[] {"key1", "key2"}; for(String key : keys) { byte[] arr = key.getBytes("UTF-8"); out.writeShort(arr.length);...
Here's how to get the same result from both: byte[] mm3_le = Hashing.murmur3_128().hashString("abc", UTF_8).asBytes(); byte[] mm3_be = Bytes.toArray(Lists.reverse(Bytes.asList(mm3_le))); assertEquals("79267961763742113019008347020647561319", new BigInteger(mm3_be).toString()); The hash code's bytes need to be treated as little endian but BigInteger interprets bytes as big endian. You were presumably using new BigInteger(hex, 16) to create the BigInteger,...
scala,sbt,cross-compiling,murmurhash
You can append to unmanagedSourceDirectories: lazy val commonSettings = Seq( scalaVersion := "2.10.4", unmanagedSourceDirectories in Compile += (sourceDirectory in Compile).value / ("scala_" + (scalaBinaryVersion.value match { case v if v startsWith "2.9." => "2.9" case v => v })) ) lazy val root = (project in file(".")). aggregate(app). settings(commonSettings: _*)...