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

Method loadAll

corpus/java/training/guava/cache/LocalCache.java:4131–4189  ·  view source on GitHub ↗

Returns the result of calling CacheLoader#loadAll, or null if loader doesn't implement loadAll.

(Set<? extends K> keys, CacheLoader<? super K, V> loader)

Source from the content-addressed store, hash-verified

4129 * implement {@code loadAll}.
4130 */
4131 @Nullable
4132 Map<K, V> loadAll(Set<? extends K> keys, CacheLoader<? super K, V> loader)
4133 throws ExecutionException {
4134 checkNotNull(loader);
4135 checkNotNull(keys);
4136 Stopwatch stopwatch = Stopwatch.createStarted();
4137 Map<K, V> result;
4138 boolean success = false;
4139 try {
4140 @SuppressWarnings("unchecked") // safe since all keys extend K
4141 Map<K, V> map = (Map<K, V>) loader.loadAll(keys);
4142 result = map;
4143 success = true;
4144 } catch (UnsupportedLoadingOperationException e) {
4145 success = true;
4146 throw e;
4147 } catch (InterruptedException e) {
4148 Thread.currentThread().interrupt();
4149 throw new ExecutionException(e);
4150 } catch (RuntimeException e) {
4151 throw new UncheckedExecutionException(e);
4152 } catch (Exception e) {
4153 throw new ExecutionException(e);
4154 } catch (Error e) {
4155 throw new ExecutionError(e);
4156 } finally {
4157 if (!success) {
4158 globalStatsCounter.recordLoadException(stopwatch.elapsed(NANOSECONDS));
4159 }
4160 }
4161
4162 if (result == null) {
4163 globalStatsCounter.recordLoadException(stopwatch.elapsed(NANOSECONDS));
4164 throw new InvalidCacheLoadException(loader + " returned null map from loadAll");
4165 }
4166
4167 stopwatch.stop();
4168 // TODO(fry): batch by segment
4169 boolean nullsPresent = false;
4170 for (Map.Entry<K, V> entry : result.entrySet()) {
4171 K key = entry.getKey();
4172 V value = entry.getValue();
4173 if (key == null || value == null) {
4174 // delay failure until non-null entries are stored
4175 nullsPresent = true;
4176 } else {
4177 put(key, value);
4178 }
4179 }
4180
4181 if (nullsPresent) {
4182 globalStatsCounter.recordLoadException(stopwatch.elapsed(NANOSECONDS));
4183 throw new InvalidCacheLoadException(loader + " returned null keys or values from loadAll");
4184 }
4185
4186 // TODO(fry): record count of loaded entries
4187 globalStatsCounter.recordLoadSuccess(stopwatch.elapsed(NANOSECONDS));
4188 return result;

Callers 1

getAllMethod · 0.95

Calls 10

createStartedMethod · 0.95
elapsedMethod · 0.95
stopMethod · 0.95
putMethod · 0.95
recordLoadExceptionMethod · 0.65
entrySetMethod · 0.65
getKeyMethod · 0.65
getValueMethod · 0.65
recordLoadSuccessMethod · 0.65
checkNotNullMethod · 0.45

Tested by

no test coverage detected