MCPcopy Create free account
hub / github.com/antlr/codebuff / getAll

Method getAll

output/java_guava/1.4.13/LocalCache.java:4029–4070  ·  view source on GitHub ↗
(Iterable<? extends K> keys)

Source from the content-addressed store, hash-verified

4027 }
4028
4029 ImmutableMap<K, V> getAll(Iterable<? extends K> keys) throws ExecutionException {
4030 int hits = 0;
4031 int misses = 0;
4032 Map<K, V> result = Maps.newLinkedHashMap();
4033 Set<K> keysToLoad = Sets.newLinkedHashSet();
4034 for (K key : keys) {
4035 V value = get(key);
4036 if (!result.containsKey(key)) {
4037 result.put(key, value);
4038 if (value == null) {
4039 misses++;
4040 keysToLoad.add(key);
4041 } else {
4042 hits++;
4043 }
4044 }
4045 }
4046 try {
4047 if (!keysToLoad.isEmpty()) {
4048 try {
4049 Map<K, V> newEntries = loadAll(keysToLoad, defaultLoader);
4050 for (K key : keysToLoad) {
4051 V value = newEntries.get(key);
4052 if (value == null) {
4053 throw new InvalidCacheLoadException("loadAll failed to return a value for " + key);
4054 }
4055 result.put(key, value);
4056 }
4057 } catch (UnsupportedLoadingOperationException e) {
4058 // loadAll not implemented, fallback to load
4059 for (K key : keysToLoad) {
4060 misses--; // get will count this miss
4061 result.put(key, get(key, defaultLoader));
4062 }
4063 }
4064 }
4065 return ImmutableMap.copyOf(result);
4066 } finally {
4067 globalStatsCounter.recordHits(hits);
4068 globalStatsCounter.recordMisses(misses);
4069 }
4070 }
4071
4072 /**
4073 * Returns the result of calling {@link CacheLoader#loadAll}, or null if {@code loader} doesn't

Callers

nothing calls this directly

Calls 11

newLinkedHashMapMethod · 0.95
newLinkedHashSetMethod · 0.95
copyOfMethod · 0.95
getMethod · 0.65
containsKeyMethod · 0.65
putMethod · 0.65
addMethod · 0.65
isEmptyMethod · 0.65
recordHitsMethod · 0.65
recordMissesMethod · 0.65
loadAllMethod · 0.45

Tested by

no test coverage detected