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

Method getAll

corpus/java/training/guava/cache/LocalCache.java:4082–4125  ·  view source on GitHub ↗
(Iterable<? extends K> keys)

Source from the content-addressed store, hash-verified

4080 }
4081
4082 ImmutableMap<K, V> getAll(Iterable<? extends K> keys) throws ExecutionException {
4083 int hits = 0;
4084 int misses = 0;
4085
4086 Map<K, V> result = Maps.newLinkedHashMap();
4087 Set<K> keysToLoad = Sets.newLinkedHashSet();
4088 for (K key : keys) {
4089 V value = get(key);
4090 if (!result.containsKey(key)) {
4091 result.put(key, value);
4092 if (value == null) {
4093 misses++;
4094 keysToLoad.add(key);
4095 } else {
4096 hits++;
4097 }
4098 }
4099 }
4100
4101 try {
4102 if (!keysToLoad.isEmpty()) {
4103 try {
4104 Map<K, V> newEntries = loadAll(keysToLoad, defaultLoader);
4105 for (K key : keysToLoad) {
4106 V value = newEntries.get(key);
4107 if (value == null) {
4108 throw new InvalidCacheLoadException("loadAll failed to return a value for " + key);
4109 }
4110 result.put(key, value);
4111 }
4112 } catch (UnsupportedLoadingOperationException e) {
4113 // loadAll not implemented, fallback to load
4114 for (K key : keysToLoad) {
4115 misses--; // get will count this miss
4116 result.put(key, get(key, defaultLoader));
4117 }
4118 }
4119 }
4120 return ImmutableMap.copyOf(result);
4121 } finally {
4122 globalStatsCounter.recordHits(hits);
4123 globalStatsCounter.recordMisses(misses);
4124 }
4125 }
4126
4127 /**
4128 * 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