Initial commit
This commit is contained in:
7
sources/com/google/common/hash/AbstractHasher.java
Normal file
7
sources/com/google/common/hash/AbstractHasher.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.google.common.hash;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class AbstractHasher implements Hasher {
|
||||
AbstractHasher() {
|
||||
}
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
package com.google.common.hash;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class AbstractStreamingHashFunction implements HashFunction {
|
||||
|
||||
protected static abstract class AbstractStreamingHasher extends AbstractHasher {
|
||||
private final ByteBuffer a;
|
||||
private final int b;
|
||||
|
||||
protected AbstractStreamingHasher(int i) {
|
||||
this(i, i);
|
||||
}
|
||||
|
||||
private void c() {
|
||||
this.a.flip();
|
||||
while (this.a.remaining() >= this.b) {
|
||||
a(this.a);
|
||||
}
|
||||
this.a.compact();
|
||||
}
|
||||
|
||||
@Override // com.google.common.hash.Hasher
|
||||
public final <T> Hasher a(T t, Funnel<? super T> funnel) {
|
||||
funnel.funnel(t, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
protected abstract void a(ByteBuffer byteBuffer);
|
||||
|
||||
abstract HashCode b();
|
||||
|
||||
protected abstract void b(ByteBuffer byteBuffer);
|
||||
|
||||
protected AbstractStreamingHasher(int i, int i2) {
|
||||
Preconditions.a(i2 % i == 0);
|
||||
this.a = ByteBuffer.allocate(i2 + 7).order(ByteOrder.LITTLE_ENDIAN);
|
||||
this.b = i;
|
||||
}
|
||||
|
||||
@Override // com.google.common.hash.Hasher
|
||||
public final HashCode a() {
|
||||
c();
|
||||
this.a.flip();
|
||||
if (this.a.remaining() > 0) {
|
||||
b(this.a);
|
||||
}
|
||||
return b();
|
||||
}
|
||||
}
|
||||
|
||||
AbstractStreamingHashFunction() {
|
||||
}
|
||||
|
||||
@Override // com.google.common.hash.HashFunction
|
||||
public <T> HashCode a(T t, Funnel<? super T> funnel) {
|
||||
Hasher a = a();
|
||||
a.a(t, funnel);
|
||||
return a.a();
|
||||
}
|
||||
}
|
217
sources/com/google/common/hash/BloomFilter.java
Normal file
217
sources/com/google/common/hash/BloomFilter.java
Normal file
@@ -0,0 +1,217 @@
|
||||
package com.google.common.hash;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.hash.BloomFilterStrategies;
|
||||
import com.google.common.math.DoubleMath;
|
||||
import com.google.common.primitives.SignedBytes;
|
||||
import com.google.common.primitives.UnsignedBytes;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class BloomFilter<T> implements Predicate<T>, Serializable {
|
||||
private final BloomFilterStrategies.BitArray bits;
|
||||
private final Funnel<? super T> funnel;
|
||||
private final int numHashFunctions;
|
||||
private final Strategy strategy;
|
||||
|
||||
private static class SerialForm<T> implements Serializable {
|
||||
final long[] a;
|
||||
final int b;
|
||||
final Funnel<? super T> c;
|
||||
final Strategy d;
|
||||
|
||||
SerialForm(BloomFilter<T> bloomFilter) {
|
||||
this.a = ((BloomFilter) bloomFilter).bits.a;
|
||||
this.b = ((BloomFilter) bloomFilter).numHashFunctions;
|
||||
this.c = ((BloomFilter) bloomFilter).funnel;
|
||||
this.d = ((BloomFilter) bloomFilter).strategy;
|
||||
}
|
||||
|
||||
Object readResolve() {
|
||||
return new BloomFilter(new BloomFilterStrategies.BitArray(this.a), this.b, this.c, this.d);
|
||||
}
|
||||
}
|
||||
|
||||
interface Strategy extends Serializable {
|
||||
<T> boolean a(T t, Funnel<? super T> funnel, int i, BloomFilterStrategies.BitArray bitArray);
|
||||
|
||||
<T> boolean b(T t, Funnel<? super T> funnel, int i, BloomFilterStrategies.BitArray bitArray);
|
||||
|
||||
int ordinal();
|
||||
}
|
||||
|
||||
public static <T> BloomFilter<T> create(Funnel<? super T> funnel, int i, double d) {
|
||||
return create(funnel, i, d);
|
||||
}
|
||||
|
||||
static long optimalNumOfBits(long j, double d) {
|
||||
if (d == 0.0d) {
|
||||
d = Double.MIN_VALUE;
|
||||
}
|
||||
return (long) (((-j) * Math.log(d)) / (Math.log(2.0d) * Math.log(2.0d)));
|
||||
}
|
||||
|
||||
static int optimalNumOfHashFunctions(long j, long j2) {
|
||||
return Math.max(1, (int) Math.round((j2 / j) * Math.log(2.0d)));
|
||||
}
|
||||
|
||||
public static <T> BloomFilter<T> readFrom(InputStream inputStream, Funnel<? super T> funnel) throws IOException {
|
||||
byte b;
|
||||
int i;
|
||||
DataInputStream dataInputStream;
|
||||
Preconditions.a(inputStream, "InputStream");
|
||||
Preconditions.a(funnel, "Funnel");
|
||||
int i2 = -1;
|
||||
try {
|
||||
dataInputStream = new DataInputStream(inputStream);
|
||||
b = dataInputStream.readByte();
|
||||
} catch (RuntimeException e) {
|
||||
e = e;
|
||||
b = -1;
|
||||
}
|
||||
try {
|
||||
i = UnsignedBytes.a(dataInputStream.readByte());
|
||||
try {
|
||||
i2 = dataInputStream.readInt();
|
||||
BloomFilterStrategies bloomFilterStrategies = BloomFilterStrategies.values()[b];
|
||||
long[] jArr = new long[i2];
|
||||
for (int i3 = 0; i3 < jArr.length; i3++) {
|
||||
jArr[i3] = dataInputStream.readLong();
|
||||
}
|
||||
return new BloomFilter<>(new BloomFilterStrategies.BitArray(jArr), i, funnel, bloomFilterStrategies);
|
||||
} catch (RuntimeException e2) {
|
||||
e = e2;
|
||||
throw new IOException("Unable to deserialize BloomFilter from InputStream. strategyOrdinal: " + ((int) b) + " numHashFunctions: " + i + " dataLength: " + i2, e);
|
||||
}
|
||||
} catch (RuntimeException e3) {
|
||||
e = e3;
|
||||
i = -1;
|
||||
throw new IOException("Unable to deserialize BloomFilter from InputStream. strategyOrdinal: " + ((int) b) + " numHashFunctions: " + i + " dataLength: " + i2, e);
|
||||
}
|
||||
}
|
||||
|
||||
private Object writeReplace() {
|
||||
return new SerialForm(this);
|
||||
}
|
||||
|
||||
@Override // com.google.common.base.Predicate
|
||||
@Deprecated
|
||||
public boolean apply(T t) {
|
||||
return mightContain(t);
|
||||
}
|
||||
|
||||
public long approximateElementCount() {
|
||||
double b = this.bits.b();
|
||||
return DoubleMath.b(((-Math.log1p(-(this.bits.a() / b))) * b) / this.numHashFunctions, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
long bitSize() {
|
||||
return this.bits.b();
|
||||
}
|
||||
|
||||
public BloomFilter<T> copy() {
|
||||
return new BloomFilter<>(this.bits.c(), this.numHashFunctions, this.funnel, this.strategy);
|
||||
}
|
||||
|
||||
@Override // com.google.common.base.Predicate
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof BloomFilter)) {
|
||||
return false;
|
||||
}
|
||||
BloomFilter bloomFilter = (BloomFilter) obj;
|
||||
return this.numHashFunctions == bloomFilter.numHashFunctions && this.funnel.equals(bloomFilter.funnel) && this.bits.equals(bloomFilter.bits) && this.strategy.equals(bloomFilter.strategy);
|
||||
}
|
||||
|
||||
public double expectedFpp() {
|
||||
return Math.pow(this.bits.a() / bitSize(), this.numHashFunctions);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Objects.a(Integer.valueOf(this.numHashFunctions), this.funnel, this.strategy, this.bits);
|
||||
}
|
||||
|
||||
public boolean isCompatible(BloomFilter<T> bloomFilter) {
|
||||
Preconditions.a(bloomFilter);
|
||||
return this != bloomFilter && this.numHashFunctions == bloomFilter.numHashFunctions && bitSize() == bloomFilter.bitSize() && this.strategy.equals(bloomFilter.strategy) && this.funnel.equals(bloomFilter.funnel);
|
||||
}
|
||||
|
||||
public boolean mightContain(T t) {
|
||||
return this.strategy.b(t, this.funnel, this.numHashFunctions, this.bits);
|
||||
}
|
||||
|
||||
public boolean put(T t) {
|
||||
return this.strategy.a(t, this.funnel, this.numHashFunctions, this.bits);
|
||||
}
|
||||
|
||||
public void putAll(BloomFilter<T> bloomFilter) {
|
||||
Preconditions.a(bloomFilter);
|
||||
Preconditions.a(this != bloomFilter, "Cannot combine a BloomFilter with itself.");
|
||||
Preconditions.a(this.numHashFunctions == bloomFilter.numHashFunctions, "BloomFilters must have the same number of hash functions (%s != %s)", this.numHashFunctions, bloomFilter.numHashFunctions);
|
||||
Preconditions.a(bitSize() == bloomFilter.bitSize(), "BloomFilters must have the same size underlying bit arrays (%s != %s)", bitSize(), bloomFilter.bitSize());
|
||||
Preconditions.a(this.strategy.equals(bloomFilter.strategy), "BloomFilters must have equal strategies (%s != %s)", this.strategy, bloomFilter.strategy);
|
||||
Preconditions.a(this.funnel.equals(bloomFilter.funnel), "BloomFilters must have equal funnels (%s != %s)", this.funnel, bloomFilter.funnel);
|
||||
this.bits.a(bloomFilter.bits);
|
||||
}
|
||||
|
||||
public void writeTo(OutputStream outputStream) throws IOException {
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(outputStream);
|
||||
dataOutputStream.writeByte(SignedBytes.a(this.strategy.ordinal()));
|
||||
dataOutputStream.writeByte(UnsignedBytes.a(this.numHashFunctions));
|
||||
dataOutputStream.writeInt(this.bits.a.length);
|
||||
for (long j : this.bits.a) {
|
||||
dataOutputStream.writeLong(j);
|
||||
}
|
||||
}
|
||||
|
||||
private BloomFilter(BloomFilterStrategies.BitArray bitArray, int i, Funnel<? super T> funnel, Strategy strategy) {
|
||||
Preconditions.a(i > 0, "numHashFunctions (%s) must be > 0", i);
|
||||
Preconditions.a(i <= 255, "numHashFunctions (%s) must be <= 255", i);
|
||||
Preconditions.a(bitArray);
|
||||
this.bits = bitArray;
|
||||
this.numHashFunctions = i;
|
||||
Preconditions.a(funnel);
|
||||
this.funnel = funnel;
|
||||
Preconditions.a(strategy);
|
||||
this.strategy = strategy;
|
||||
}
|
||||
|
||||
public static <T> BloomFilter<T> create(Funnel<? super T> funnel, long j, double d) {
|
||||
return create(funnel, j, d, BloomFilterStrategies.MURMUR128_MITZ_64);
|
||||
}
|
||||
|
||||
static <T> BloomFilter<T> create(Funnel<? super T> funnel, long j, double d, Strategy strategy) {
|
||||
Preconditions.a(funnel);
|
||||
Preconditions.a(j >= 0, "Expected insertions (%s) must be >= 0", j);
|
||||
Preconditions.a(d > 0.0d, "False positive probability (%s) must be > 0.0", Double.valueOf(d));
|
||||
Preconditions.a(d < 1.0d, "False positive probability (%s) must be < 1.0", Double.valueOf(d));
|
||||
Preconditions.a(strategy);
|
||||
if (j == 0) {
|
||||
j = 1;
|
||||
}
|
||||
long optimalNumOfBits = optimalNumOfBits(j, d);
|
||||
try {
|
||||
return new BloomFilter<>(new BloomFilterStrategies.BitArray(optimalNumOfBits), optimalNumOfHashFunctions(j, optimalNumOfBits), funnel, strategy);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IllegalArgumentException("Could not create BloomFilter of " + optimalNumOfBits + " bits", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> BloomFilter<T> create(Funnel<? super T> funnel, int i) {
|
||||
return create(funnel, i);
|
||||
}
|
||||
|
||||
public static <T> BloomFilter<T> create(Funnel<? super T> funnel, long j) {
|
||||
return create(funnel, j, 0.03d);
|
||||
}
|
||||
}
|
161
sources/com/google/common/hash/BloomFilterStrategies.java
Normal file
161
sources/com/google/common/hash/BloomFilterStrategies.java
Normal file
@@ -0,0 +1,161 @@
|
||||
package com.google.common.hash;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.hash.BloomFilter;
|
||||
import com.google.common.math.LongMath;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.google.common.primitives.Longs;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Arrays;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
enum BloomFilterStrategies implements BloomFilter.Strategy {
|
||||
MURMUR128_MITZ_32 { // from class: com.google.common.hash.BloomFilterStrategies.1
|
||||
@Override // com.google.common.hash.BloomFilter.Strategy
|
||||
public <T> boolean a(T t, Funnel<? super T> funnel, int i, BitArray bitArray) {
|
||||
long b = bitArray.b();
|
||||
long c = Hashing.b().a(t, funnel).c();
|
||||
int i2 = (int) c;
|
||||
int i3 = (int) (c >>> 32);
|
||||
boolean z = false;
|
||||
for (int i4 = 1; i4 <= i; i4++) {
|
||||
int i5 = (i4 * i3) + i2;
|
||||
if (i5 < 0) {
|
||||
i5 = ~i5;
|
||||
}
|
||||
z |= bitArray.b(i5 % b);
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override // com.google.common.hash.BloomFilter.Strategy
|
||||
public <T> boolean b(T t, Funnel<? super T> funnel, int i, BitArray bitArray) {
|
||||
long b = bitArray.b();
|
||||
long c = Hashing.b().a(t, funnel).c();
|
||||
int i2 = (int) c;
|
||||
int i3 = (int) (c >>> 32);
|
||||
for (int i4 = 1; i4 <= i; i4++) {
|
||||
int i5 = (i4 * i3) + i2;
|
||||
if (i5 < 0) {
|
||||
i5 = ~i5;
|
||||
}
|
||||
if (!bitArray.a(i5 % b)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
MURMUR128_MITZ_64 { // from class: com.google.common.hash.BloomFilterStrategies.2
|
||||
@Override // com.google.common.hash.BloomFilter.Strategy
|
||||
public <T> boolean a(T t, Funnel<? super T> funnel, int i, BitArray bitArray) {
|
||||
long b = bitArray.b();
|
||||
byte[] e = Hashing.b().a(t, funnel).e();
|
||||
long a = a(e);
|
||||
long b2 = b(e);
|
||||
long j = a;
|
||||
boolean z = false;
|
||||
for (int i2 = 0; i2 < i; i2++) {
|
||||
z |= bitArray.b((Long.MAX_VALUE & j) % b);
|
||||
j += b2;
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override // com.google.common.hash.BloomFilter.Strategy
|
||||
public <T> boolean b(T t, Funnel<? super T> funnel, int i, BitArray bitArray) {
|
||||
long b = bitArray.b();
|
||||
byte[] e = Hashing.b().a(t, funnel).e();
|
||||
long a = a(e);
|
||||
long b2 = b(e);
|
||||
long j = a;
|
||||
for (int i2 = 0; i2 < i; i2++) {
|
||||
if (!bitArray.a((Long.MAX_VALUE & j) % b)) {
|
||||
return false;
|
||||
}
|
||||
j += b2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private long a(byte[] bArr) {
|
||||
return Longs.a(bArr[7], bArr[6], bArr[5], bArr[4], bArr[3], bArr[2], bArr[1], bArr[0]);
|
||||
}
|
||||
|
||||
private long b(byte[] bArr) {
|
||||
return Longs.a(bArr[15], bArr[14], bArr[13], bArr[12], bArr[11], bArr[10], bArr[9], bArr[8]);
|
||||
}
|
||||
};
|
||||
|
||||
static final class BitArray {
|
||||
final long[] a;
|
||||
long b;
|
||||
|
||||
BitArray(long j) {
|
||||
this(new long[Ints.a(LongMath.a(j, 64L, RoundingMode.CEILING))]);
|
||||
}
|
||||
|
||||
boolean a(long j) {
|
||||
return ((1 << ((int) j)) & this.a[(int) (j >>> 6)]) != 0;
|
||||
}
|
||||
|
||||
boolean b(long j) {
|
||||
if (a(j)) {
|
||||
return false;
|
||||
}
|
||||
long[] jArr = this.a;
|
||||
int i = (int) (j >>> 6);
|
||||
jArr[i] = (1 << ((int) j)) | jArr[i];
|
||||
this.b++;
|
||||
return true;
|
||||
}
|
||||
|
||||
BitArray c() {
|
||||
return new BitArray((long[]) this.a.clone());
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof BitArray) {
|
||||
return Arrays.equals(this.a, ((BitArray) obj).a);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(this.a);
|
||||
}
|
||||
|
||||
BitArray(long[] jArr) {
|
||||
Preconditions.a(jArr.length > 0, "data length is zero!");
|
||||
this.a = jArr;
|
||||
long j = 0;
|
||||
for (long j2 : jArr) {
|
||||
j += Long.bitCount(j2);
|
||||
}
|
||||
this.b = j;
|
||||
}
|
||||
|
||||
long a() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
void a(BitArray bitArray) {
|
||||
int i = 0;
|
||||
Preconditions.a(this.a.length == bitArray.a.length, "BitArrays must be of equal length (%s != %s)", this.a.length, bitArray.a.length);
|
||||
this.b = 0L;
|
||||
while (true) {
|
||||
long[] jArr = this.a;
|
||||
if (i >= jArr.length) {
|
||||
return;
|
||||
}
|
||||
jArr[i] = jArr[i] | bitArray.a[i];
|
||||
this.b += Long.bitCount(jArr[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
long b() {
|
||||
return this.a.length * 64;
|
||||
}
|
||||
}
|
||||
}
|
8
sources/com/google/common/hash/Funnel.java
Normal file
8
sources/com/google/common/hash/Funnel.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.google.common.hash;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface Funnel<T> extends Serializable {
|
||||
void funnel(T t, PrimitiveSink primitiveSink);
|
||||
}
|
122
sources/com/google/common/hash/HashCode.java
Normal file
122
sources/com/google/common/hash/HashCode.java
Normal file
@@ -0,0 +1,122 @@
|
||||
package com.google.common.hash;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.io.Serializable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class HashCode {
|
||||
private static final char[] a = "0123456789abcdef".toCharArray();
|
||||
|
||||
private static final class BytesHashCode extends HashCode implements Serializable {
|
||||
final byte[] b;
|
||||
|
||||
BytesHashCode(byte[] bArr) {
|
||||
Preconditions.a(bArr);
|
||||
this.b = bArr;
|
||||
}
|
||||
|
||||
@Override // com.google.common.hash.HashCode
|
||||
public byte[] a() {
|
||||
return (byte[]) this.b.clone();
|
||||
}
|
||||
|
||||
@Override // com.google.common.hash.HashCode
|
||||
public int b() {
|
||||
Preconditions.b(this.b.length >= 4, "HashCode#asInt() requires >= 4 bytes (it only has %s bytes).", this.b.length);
|
||||
byte[] bArr = this.b;
|
||||
return ((bArr[3] & 255) << 24) | ((bArr[1] & 255) << 8) | (bArr[0] & 255) | ((bArr[2] & 255) << 16);
|
||||
}
|
||||
|
||||
@Override // com.google.common.hash.HashCode
|
||||
public long c() {
|
||||
Preconditions.b(this.b.length >= 8, "HashCode#asLong() requires >= 8 bytes (it only has %s bytes).", this.b.length);
|
||||
return f();
|
||||
}
|
||||
|
||||
@Override // com.google.common.hash.HashCode
|
||||
public int d() {
|
||||
return this.b.length * 8;
|
||||
}
|
||||
|
||||
@Override // com.google.common.hash.HashCode
|
||||
byte[] e() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public long f() {
|
||||
long j = this.b[0] & 255;
|
||||
for (int i = 1; i < Math.min(this.b.length, 8); i++) {
|
||||
j |= (this.b[i] & 255) << (i * 8);
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
@Override // com.google.common.hash.HashCode
|
||||
boolean a(HashCode hashCode) {
|
||||
if (this.b.length != hashCode.e().length) {
|
||||
return false;
|
||||
}
|
||||
int i = 0;
|
||||
boolean z = true;
|
||||
while (true) {
|
||||
byte[] bArr = this.b;
|
||||
if (i >= bArr.length) {
|
||||
return z;
|
||||
}
|
||||
z &= bArr[i] == hashCode.e()[i];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashCode() {
|
||||
}
|
||||
|
||||
static HashCode a(byte[] bArr) {
|
||||
return new BytesHashCode(bArr);
|
||||
}
|
||||
|
||||
abstract boolean a(HashCode hashCode);
|
||||
|
||||
public abstract byte[] a();
|
||||
|
||||
public abstract int b();
|
||||
|
||||
public abstract long c();
|
||||
|
||||
public abstract int d();
|
||||
|
||||
byte[] e() {
|
||||
return a();
|
||||
}
|
||||
|
||||
public final boolean equals(Object obj) {
|
||||
if (!(obj instanceof HashCode)) {
|
||||
return false;
|
||||
}
|
||||
HashCode hashCode = (HashCode) obj;
|
||||
return d() == hashCode.d() && a(hashCode);
|
||||
}
|
||||
|
||||
public final int hashCode() {
|
||||
if (d() >= 32) {
|
||||
return b();
|
||||
}
|
||||
byte[] e = e();
|
||||
int i = e[0] & 255;
|
||||
for (int i2 = 1; i2 < e.length; i2++) {
|
||||
i |= (e[i2] & 255) << (i2 * 8);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
byte[] e = e();
|
||||
StringBuilder sb = new StringBuilder(e.length * 2);
|
||||
for (byte b : e) {
|
||||
sb.append(a[(b >> 4) & 15]);
|
||||
sb.append(a[b & 15]);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
8
sources/com/google/common/hash/HashFunction.java
Normal file
8
sources/com/google/common/hash/HashFunction.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.google.common.hash;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface HashFunction {
|
||||
<T> HashCode a(T t, Funnel<? super T> funnel);
|
||||
|
||||
Hasher a();
|
||||
}
|
8
sources/com/google/common/hash/Hasher.java
Normal file
8
sources/com/google/common/hash/Hasher.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.google.common.hash;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface Hasher extends PrimitiveSink {
|
||||
HashCode a();
|
||||
|
||||
<T> Hasher a(T t, Funnel<? super T> funnel);
|
||||
}
|
22
sources/com/google/common/hash/Hashing.java
Normal file
22
sources/com/google/common/hash/Hashing.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.google.common.hash;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class Hashing {
|
||||
private static final int a = (int) System.currentTimeMillis();
|
||||
|
||||
private static class Murmur3_128Holder {
|
||||
static final HashFunction a = new Murmur3_128HashFunction(0);
|
||||
|
||||
static {
|
||||
Hashing.a(Hashing.a);
|
||||
}
|
||||
}
|
||||
|
||||
public static HashFunction b() {
|
||||
return Murmur3_128Holder.a;
|
||||
}
|
||||
|
||||
public static HashFunction a(int i) {
|
||||
return new Murmur3_128HashFunction(i);
|
||||
}
|
||||
}
|
267
sources/com/google/common/hash/Murmur3_128HashFunction.java
Normal file
267
sources/com/google/common/hash/Murmur3_128HashFunction.java
Normal file
@@ -0,0 +1,267 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
5
sources/com/google/common/hash/PrimitiveSink.java
Normal file
5
sources/com/google/common/hash/PrimitiveSink.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package com.google.common.hash;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface PrimitiveSink {
|
||||
}
|
Reference in New Issue
Block a user