jimu-decompiled/sources/com/google/common/hash/Murmur3_128HashFunction.java
2025-05-13 19:24:51 +02:00

268 lines
11 KiB
Java

package com.google.common.hash;
import com.google.common.hash.AbstractStreamingHashFunction;
import com.google.common.primitives.UnsignedBytes;
import java.io.Serializable;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/* loaded from: classes.dex */
final class Murmur3_128HashFunction extends AbstractStreamingHashFunction implements Serializable {
private final int a;
Murmur3_128HashFunction(int i) {
this.a = i;
}
@Override // com.google.common.hash.HashFunction
public Hasher a() {
return new Murmur3_128Hasher(this.a);
}
public boolean equals(Object obj) {
return (obj instanceof Murmur3_128HashFunction) && this.a == ((Murmur3_128HashFunction) obj).a;
}
public int hashCode() {
return Murmur3_128HashFunction.class.hashCode() ^ this.a;
}
public String toString() {
return "Hashing.murmur3_128(" + this.a + ")";
}
private static final class Murmur3_128Hasher extends AbstractStreamingHashFunction.AbstractStreamingHasher {
private long c;
private long d;
private int e;
Murmur3_128Hasher(int i) {
super(16);
long j = i;
this.c = j;
this.d = j;
this.e = 0;
}
private static long a(long j) {
long j2 = (j ^ (j >>> 33)) * (-49064778989728563L);
long j3 = (j2 ^ (j2 >>> 33)) * (-4265267296055464877L);
return j3 ^ (j3 >>> 33);
}
private static long c(long j) {
return Long.rotateLeft(j * 5545529020109919103L, 33) * (-8663945395140668459L);
}
@Override // com.google.common.hash.AbstractStreamingHashFunction.AbstractStreamingHasher
protected void a(ByteBuffer byteBuffer) {
a(byteBuffer.getLong(), byteBuffer.getLong());
this.e += 16;
}
@Override // com.google.common.hash.AbstractStreamingHashFunction.AbstractStreamingHasher
protected void b(ByteBuffer byteBuffer) {
long j;
long j2;
long j3;
long j4;
long j5;
long j6;
long a;
long j7;
long j8;
long j9;
long j10;
long j11;
long j12;
long j13;
this.e += byteBuffer.remaining();
switch (byteBuffer.remaining()) {
case 1:
j = 0;
a = UnsignedBytes.a(byteBuffer.get(0)) ^ j;
j7 = 0;
this.c = b(a) ^ this.c;
this.d = c(j7) ^ this.d;
return;
case 2:
j2 = 0;
j = j2 ^ (UnsignedBytes.a(byteBuffer.get(1)) << 8);
a = UnsignedBytes.a(byteBuffer.get(0)) ^ j;
j7 = 0;
this.c = b(a) ^ this.c;
this.d = c(j7) ^ this.d;
return;
case 3:
j3 = 0;
j2 = j3 ^ (UnsignedBytes.a(byteBuffer.get(2)) << 16);
j = j2 ^ (UnsignedBytes.a(byteBuffer.get(1)) << 8);
a = UnsignedBytes.a(byteBuffer.get(0)) ^ j;
j7 = 0;
this.c = b(a) ^ this.c;
this.d = c(j7) ^ this.d;
return;
case 4:
j4 = 0;
j3 = j4 ^ (UnsignedBytes.a(byteBuffer.get(3)) << 24);
j2 = j3 ^ (UnsignedBytes.a(byteBuffer.get(2)) << 16);
j = j2 ^ (UnsignedBytes.a(byteBuffer.get(1)) << 8);
a = UnsignedBytes.a(byteBuffer.get(0)) ^ j;
j7 = 0;
this.c = b(a) ^ this.c;
this.d = c(j7) ^ this.d;
return;
case 5:
j5 = 0;
j4 = j5 ^ (UnsignedBytes.a(byteBuffer.get(4)) << 32);
j3 = j4 ^ (UnsignedBytes.a(byteBuffer.get(3)) << 24);
j2 = j3 ^ (UnsignedBytes.a(byteBuffer.get(2)) << 16);
j = j2 ^ (UnsignedBytes.a(byteBuffer.get(1)) << 8);
a = UnsignedBytes.a(byteBuffer.get(0)) ^ j;
j7 = 0;
this.c = b(a) ^ this.c;
this.d = c(j7) ^ this.d;
return;
case 6:
j6 = 0;
j5 = j6 ^ (UnsignedBytes.a(byteBuffer.get(5)) << 40);
j4 = j5 ^ (UnsignedBytes.a(byteBuffer.get(4)) << 32);
j3 = j4 ^ (UnsignedBytes.a(byteBuffer.get(3)) << 24);
j2 = j3 ^ (UnsignedBytes.a(byteBuffer.get(2)) << 16);
j = j2 ^ (UnsignedBytes.a(byteBuffer.get(1)) << 8);
a = UnsignedBytes.a(byteBuffer.get(0)) ^ j;
j7 = 0;
this.c = b(a) ^ this.c;
this.d = c(j7) ^ this.d;
return;
case 7:
j6 = (UnsignedBytes.a(byteBuffer.get(6)) << 48) ^ 0;
j5 = j6 ^ (UnsignedBytes.a(byteBuffer.get(5)) << 40);
j4 = j5 ^ (UnsignedBytes.a(byteBuffer.get(4)) << 32);
j3 = j4 ^ (UnsignedBytes.a(byteBuffer.get(3)) << 24);
j2 = j3 ^ (UnsignedBytes.a(byteBuffer.get(2)) << 16);
j = j2 ^ (UnsignedBytes.a(byteBuffer.get(1)) << 8);
a = UnsignedBytes.a(byteBuffer.get(0)) ^ j;
j7 = 0;
this.c = b(a) ^ this.c;
this.d = c(j7) ^ this.d;
return;
case 8:
j7 = 0;
a = byteBuffer.getLong() ^ 0;
this.c = b(a) ^ this.c;
this.d = c(j7) ^ this.d;
return;
case 9:
j8 = 0;
j7 = j8 ^ UnsignedBytes.a(byteBuffer.get(8));
a = byteBuffer.getLong() ^ 0;
this.c = b(a) ^ this.c;
this.d = c(j7) ^ this.d;
return;
case 10:
j9 = 0;
j8 = j9 ^ (UnsignedBytes.a(byteBuffer.get(9)) << 8);
j7 = j8 ^ UnsignedBytes.a(byteBuffer.get(8));
a = byteBuffer.getLong() ^ 0;
this.c = b(a) ^ this.c;
this.d = c(j7) ^ this.d;
return;
case 11:
j10 = 0;
j9 = j10 ^ (UnsignedBytes.a(byteBuffer.get(10)) << 16);
j8 = j9 ^ (UnsignedBytes.a(byteBuffer.get(9)) << 8);
j7 = j8 ^ UnsignedBytes.a(byteBuffer.get(8));
a = byteBuffer.getLong() ^ 0;
this.c = b(a) ^ this.c;
this.d = c(j7) ^ this.d;
return;
case 12:
j11 = 0;
j10 = j11 ^ (UnsignedBytes.a(byteBuffer.get(11)) << 24);
j9 = j10 ^ (UnsignedBytes.a(byteBuffer.get(10)) << 16);
j8 = j9 ^ (UnsignedBytes.a(byteBuffer.get(9)) << 8);
j7 = j8 ^ UnsignedBytes.a(byteBuffer.get(8));
a = byteBuffer.getLong() ^ 0;
this.c = b(a) ^ this.c;
this.d = c(j7) ^ this.d;
return;
case 13:
j12 = 0;
j11 = j12 ^ (UnsignedBytes.a(byteBuffer.get(12)) << 32);
j10 = j11 ^ (UnsignedBytes.a(byteBuffer.get(11)) << 24);
j9 = j10 ^ (UnsignedBytes.a(byteBuffer.get(10)) << 16);
j8 = j9 ^ (UnsignedBytes.a(byteBuffer.get(9)) << 8);
j7 = j8 ^ UnsignedBytes.a(byteBuffer.get(8));
a = byteBuffer.getLong() ^ 0;
this.c = b(a) ^ this.c;
this.d = c(j7) ^ this.d;
return;
case 14:
j13 = 0;
j12 = j13 ^ (UnsignedBytes.a(byteBuffer.get(13)) << 40);
j11 = j12 ^ (UnsignedBytes.a(byteBuffer.get(12)) << 32);
j10 = j11 ^ (UnsignedBytes.a(byteBuffer.get(11)) << 24);
j9 = j10 ^ (UnsignedBytes.a(byteBuffer.get(10)) << 16);
j8 = j9 ^ (UnsignedBytes.a(byteBuffer.get(9)) << 8);
j7 = j8 ^ UnsignedBytes.a(byteBuffer.get(8));
a = byteBuffer.getLong() ^ 0;
this.c = b(a) ^ this.c;
this.d = c(j7) ^ this.d;
return;
case 15:
j13 = (UnsignedBytes.a(byteBuffer.get(14)) << 48) ^ 0;
j12 = j13 ^ (UnsignedBytes.a(byteBuffer.get(13)) << 40);
j11 = j12 ^ (UnsignedBytes.a(byteBuffer.get(12)) << 32);
j10 = j11 ^ (UnsignedBytes.a(byteBuffer.get(11)) << 24);
j9 = j10 ^ (UnsignedBytes.a(byteBuffer.get(10)) << 16);
j8 = j9 ^ (UnsignedBytes.a(byteBuffer.get(9)) << 8);
j7 = j8 ^ UnsignedBytes.a(byteBuffer.get(8));
a = byteBuffer.getLong() ^ 0;
this.c = b(a) ^ this.c;
this.d = c(j7) ^ this.d;
return;
default:
throw new AssertionError("Should never get here.");
}
}
private void a(long j, long j2) {
this.c = b(j) ^ this.c;
this.c = Long.rotateLeft(this.c, 27);
long j3 = this.c;
long j4 = this.d;
this.c = j3 + j4;
this.c = (this.c * 5) + 1390208809;
this.d = c(j2) ^ j4;
this.d = Long.rotateLeft(this.d, 31);
this.d += this.c;
this.d = (this.d * 5) + 944331445;
}
@Override // com.google.common.hash.AbstractStreamingHashFunction.AbstractStreamingHasher
public HashCode b() {
long j = this.c;
int i = this.e;
this.c = j ^ i;
this.d ^= i;
long j2 = this.c;
long j3 = this.d;
this.c = j2 + j3;
long j4 = this.c;
this.d = j3 + j4;
this.c = a(j4);
this.d = a(this.d);
long j5 = this.c;
long j6 = this.d;
this.c = j5 + j6;
this.d = j6 + this.c;
return HashCode.a(ByteBuffer.wrap(new byte[16]).order(ByteOrder.LITTLE_ENDIAN).putLong(this.c).putLong(this.d).array());
}
private static long b(long j) {
return Long.rotateLeft(j * (-8663945395140668459L), 31) * 5545529020109919103L;
}
}
}