Merge "Use LoadingCache#getAll in AccountCacheImpl"
This commit is contained in:
		| @@ -19,6 +19,7 @@ import static com.google.gerrit.server.account.externalids.ExternalId.SCHEME_USE | |||||||
| import com.google.common.cache.CacheLoader; | import com.google.common.cache.CacheLoader; | ||||||
| import com.google.common.cache.LoadingCache; | import com.google.common.cache.LoadingCache; | ||||||
| import com.google.common.collect.ImmutableMap; | import com.google.common.collect.ImmutableMap; | ||||||
|  | import com.google.common.collect.Sets; | ||||||
| import com.google.common.flogger.FluentLogger; | import com.google.common.flogger.FluentLogger; | ||||||
| import com.google.gerrit.entities.Account; | import com.google.gerrit.entities.Account; | ||||||
| import com.google.gerrit.entities.RefNames; | import com.google.gerrit.entities.RefNames; | ||||||
| @@ -113,20 +114,21 @@ public class AccountCacheImpl implements AccountCache { | |||||||
|                 ? defaultPreferenceCache.get(ref.getObjectId()) |                 ? defaultPreferenceCache.get(ref.getObjectId()) | ||||||
|                 : DefaultPreferencesCache.EMPTY; |                 : DefaultPreferencesCache.EMPTY; | ||||||
|  |  | ||||||
|         ImmutableMap.Builder<Account.Id, AccountState> result = ImmutableMap.builder(); |         Set<CachedAccountDetails.Key> keys = | ||||||
|  |             Sets.newLinkedHashSetWithExpectedSize(accountIds.size()); | ||||||
|         for (Account.Id id : accountIds) { |         for (Account.Id id : accountIds) { | ||||||
|           Ref userRef = allUsers.exactRef(RefNames.refsUsers(id)); |           Ref userRef = allUsers.exactRef(RefNames.refsUsers(id)); | ||||||
|           if (userRef == null) { |           if (userRef == null) { | ||||||
|             continue; |             continue; | ||||||
|           } |           } | ||||||
|  |           keys.add(CachedAccountDetails.Key.create(id, userRef.getObjectId())); | ||||||
|  |         } | ||||||
|  |         ImmutableMap.Builder<Account.Id, AccountState> result = ImmutableMap.builder(); | ||||||
|  |         for (Map.Entry<CachedAccountDetails.Key, CachedAccountDetails> account : | ||||||
|  |             accountDetailsCache.getAll(keys).entrySet()) { | ||||||
|           result.put( |           result.put( | ||||||
|               id, |               account.getKey().accountId(), | ||||||
|               AccountState.forCachedAccount( |               AccountState.forCachedAccount(account.getValue(), defaultPreferences, externalIds)); | ||||||
|                   accountDetailsCache.get( |  | ||||||
|                       CachedAccountDetails.Key.create(id, userRef.getObjectId())), |  | ||||||
|                   defaultPreferences, |  | ||||||
|                   externalIds)); |  | ||||||
|         } |         } | ||||||
|         return result.build(); |         return result.build(); | ||||||
|       } |       } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Alice Kober-Sotzek
					Alice Kober-Sotzek