mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-27 17:42:33 -06:00
155 lines
5.3 KiB
Java
155 lines
5.3 KiB
Java
package com.google.common.cache;
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
import com.google.common.collect.Maps;
|
|
import java.util.Iterator;
|
|
import java.util.LinkedHashMap;
|
|
import java.util.Map;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.ConcurrentMap;
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
@ElementTypesAreNonnullByDefault
|
|
/* loaded from: classes2.dex */
|
|
public abstract class AbstractCache<K, V> implements Cache<K, V> {
|
|
|
|
/* loaded from: classes2.dex */
|
|
public interface StatsCounter {
|
|
void recordEviction();
|
|
|
|
void recordHits(int i);
|
|
|
|
void recordLoadException(long j);
|
|
|
|
void recordLoadSuccess(long j);
|
|
|
|
void recordMisses(int i);
|
|
|
|
CacheStats snapshot();
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public void cleanUp() {
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public V get(K k, Callable<? extends V> callable) throws ExecutionException {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public ImmutableMap<K, V> getAllPresent(Iterable<? extends Object> iterable) {
|
|
V ifPresent;
|
|
LinkedHashMap newLinkedHashMap = Maps.newLinkedHashMap();
|
|
for (Object obj : iterable) {
|
|
if (!newLinkedHashMap.containsKey(obj) && (ifPresent = getIfPresent(obj)) != null) {
|
|
newLinkedHashMap.put(obj, ifPresent);
|
|
}
|
|
}
|
|
return ImmutableMap.copyOf((Map) newLinkedHashMap);
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public void put(K k, V v) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public void putAll(Map<? extends K, ? extends V> map) {
|
|
for (Map.Entry<? extends K, ? extends V> entry : map.entrySet()) {
|
|
put(entry.getKey(), entry.getValue());
|
|
}
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public long size() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public void invalidate(Object obj) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public void invalidateAll(Iterable<? extends Object> iterable) {
|
|
Iterator<? extends Object> it = iterable.iterator();
|
|
while (it.hasNext()) {
|
|
invalidate(it.next());
|
|
}
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public void invalidateAll() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public CacheStats stats() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
@Override // com.google.common.cache.Cache
|
|
public ConcurrentMap<K, V> asMap() {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
/* loaded from: classes2.dex */
|
|
public static final class SimpleStatsCounter implements StatsCounter {
|
|
private final LongAddable hitCount = LongAddables.create();
|
|
private final LongAddable missCount = LongAddables.create();
|
|
private final LongAddable loadSuccessCount = LongAddables.create();
|
|
private final LongAddable loadExceptionCount = LongAddables.create();
|
|
private final LongAddable totalLoadTime = LongAddables.create();
|
|
private final LongAddable evictionCount = LongAddables.create();
|
|
|
|
private static long negativeToMaxValue(long j) {
|
|
if (j >= 0) {
|
|
return j;
|
|
}
|
|
return Long.MAX_VALUE;
|
|
}
|
|
|
|
@Override // com.google.common.cache.AbstractCache.StatsCounter
|
|
public void recordHits(int i) {
|
|
this.hitCount.add(i);
|
|
}
|
|
|
|
@Override // com.google.common.cache.AbstractCache.StatsCounter
|
|
public void recordMisses(int i) {
|
|
this.missCount.add(i);
|
|
}
|
|
|
|
@Override // com.google.common.cache.AbstractCache.StatsCounter
|
|
public void recordLoadSuccess(long j) {
|
|
this.loadSuccessCount.increment();
|
|
this.totalLoadTime.add(j);
|
|
}
|
|
|
|
@Override // com.google.common.cache.AbstractCache.StatsCounter
|
|
public void recordLoadException(long j) {
|
|
this.loadExceptionCount.increment();
|
|
this.totalLoadTime.add(j);
|
|
}
|
|
|
|
@Override // com.google.common.cache.AbstractCache.StatsCounter
|
|
public void recordEviction() {
|
|
this.evictionCount.increment();
|
|
}
|
|
|
|
@Override // com.google.common.cache.AbstractCache.StatsCounter
|
|
public CacheStats snapshot() {
|
|
return new CacheStats(negativeToMaxValue(this.hitCount.sum()), negativeToMaxValue(this.missCount.sum()), negativeToMaxValue(this.loadSuccessCount.sum()), negativeToMaxValue(this.loadExceptionCount.sum()), negativeToMaxValue(this.totalLoadTime.sum()), negativeToMaxValue(this.evictionCount.sum()));
|
|
}
|
|
|
|
public void incrementBy(StatsCounter statsCounter) {
|
|
CacheStats snapshot = statsCounter.snapshot();
|
|
this.hitCount.add(snapshot.hitCount());
|
|
this.missCount.add(snapshot.missCount());
|
|
this.loadSuccessCount.add(snapshot.loadSuccessCount());
|
|
this.loadExceptionCount.add(snapshot.loadExceptionCount());
|
|
this.totalLoadTime.add(snapshot.totalLoadTime());
|
|
this.evictionCount.add(snapshot.evictionCount());
|
|
}
|
|
}
|
|
}
|