MCPcopy Index your code
hub / github.com/antlr/codebuff / getAll

Method getAll

output/java_guava/1.4.19/LocalCache.java:4046–4087  ·  view source on GitHub ↗
(Iterable<? extends K> keys)

Source from the content-addressed store, hash-verified

4044 }
4045
4046 ImmutableMap<K, V> getAll(Iterable<? extends K> keys) throws ExecutionException {
4047 int hits = 0;
4048 int misses = 0;
4049 Map<K, V> result = Maps.newLinkedHashMap();
4050 Set<K> keysToLoad = Sets.newLinkedHashSet();
4051 for (K key : keys) {
4052 V value = get(key);
4053 if (!result.containsKey(key)) {
4054 result.put(key, value);
4055 if (value == null) {
4056 misses++;
4057 keysToLoad.add(key);
4058 } else {
4059 hits++;
4060 }
4061 }
4062 }
4063 try {
4064 if (!keysToLoad.isEmpty()) {
4065 try {
4066 Map<K, V> newEntries = loadAll(keysToLoad, defaultLoader);
4067 for (K key : keysToLoad) {
4068 V value = newEntries.get(key);
4069 if (value == null) {
4070 throw new InvalidCacheLoadException("loadAll failed to return a value for " + key);
4071 }
4072 result.put(key, value);
4073 }
4074 } catch (UnsupportedLoadingOperationException e) {
4075 // loadAll not implemented, fallback to load
4076 for (K key : keysToLoad) {
4077 misses--; // get will count this miss
4078 result.put(key, get(key, defaultLoader));
4079 }
4080 }
4081 }
4082 return ImmutableMap.copyOf(result);
4083 } finally {
4084 globalStatsCounter.recordHits(hits);
4085 globalStatsCounter.recordMisses(misses);
4086 }
4087 }
4088
4089 /**
4090 * Returns the result of calling {@link CacheLoader#loadAll}, or null if {@code loader} doesn't

Callers

nothing calls this directly

Calls 12

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

Tested by

no test coverage detected