MCPcopy Create free account
hub / github.com/apache/fory / CaseMurmurHash3

Method CaseMurmurHash3

csharp/tests/Fory.XlangPeer/Program.cs:329–355  ·  view source on GitHub ↗
(byte[] input)

Source from the content-addressed store, hash-verified

327 }
328
329 private static byte[] CaseMurmurHash3(byte[] input)
330 {
331 if (input.Length == 32)
332 {
333 (ulong h1a, ulong h1b) = MurmurHash3.X64_128([1, 2, 8], 47);
334 (ulong h2a, ulong h2b) = MurmurHash3.X64_128(Encoding.UTF8.GetBytes("01234567890123456789"), 47);
335 ByteWriter writer = new();
336 writer.WriteInt64(unchecked((long)h1a));
337 writer.WriteInt64(unchecked((long)h1b));
338 writer.WriteInt64(unchecked((long)h2a));
339 writer.WriteInt64(unchecked((long)h2b));
340 return writer.ToArray();
341 }
342
343 if (input.Length == 16)
344 {
345 ByteReader reader = new(input);
346 long h1 = reader.ReadInt64();
347 long h2 = reader.ReadInt64();
348 (ulong expected1, ulong expected2) = MurmurHash3.X64_128([1, 2, 8], 47);
349 Ensure(h1 == unchecked((long)expected1), "murmur hash h1 mismatch");
350 Ensure(h2 == unchecked((long)expected2), "murmur hash h2 mismatch");
351 return [];
352 }
353
354 throw new InvalidOperationException($"unexpected murmur hash input length {input.Length}");
355 }
356
357 private static byte[] CaseStringSerializer(byte[] input)
358 {

Callers

nothing calls this directly

Calls 4

X64_128Method · 0.80
ToArrayMethod · 0.80
WriteInt64Method · 0.45
ReadInt64Method · 0.45

Tested by

no test coverage detected