Load accounts in parallel when resolving code owners

After reading code owner emails from an OWNERS file they are resolved to
accounts. Resolving an email to an account requires doing multiple
checks and lookups. Doing the lookups for all emails at once is more
efficient than iterating over the emails and doing the lookups once for
each email:

1. Lookup external IDs for emails:
   The external IDs are retrieved from the external ID cache. Each
   access to the external ID cache requires reading the SHA1 of the
   refs/meta/external-ids branch. If external IDs for multiple emails
   are needed it is more efficient to use the
   ExternalIds.byEmails(String...) method instead of the
   ExternalIds.byEmail(String) method as the
   ExternalIds.byEmails(String…) method reads the SHA1 of the
   refs/meta/external-ids branch only once (and not once per email).

2. Lookup accounts:
   Accounts are retrieved from the account cache. Using the
   AccountCache.get(Set<Account.Id>) method loads accounts in parallel
   and hence it is more efficient than calling
   AccountCache.get(Account.Id) once for each account.

Doing the lookups only once for all emails requires rewriting the
CodeOwnerResolver class, as now all checks and transformations need to
be performed on the collection of emails, rather than on a single email.

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Ie7dd6f54a0c24c2c4a9018d32ddb66b8f466d32a
2 files changed
tree: 13e76cf3446521bef03e5a58feade831c1f4959c
  1. java/
  2. javatests/
  3. proto/
  4. resources/
  5. test/
  6. ui/
  7. .eslintrc.json
  8. .gitignore
  9. .gitreview
  10. bower.json
  11. BUILD
  12. LICENSE
  13. package-lock.json
  14. package.json
  15. README.md
README.md

Gerrit Code Review code-owners plugin

This plugin provides support for defining code owners for files in a repository.

If the code-owners plugin is enabled, changes can only be submitted if all touched files are covered by approvals from code owners.

Also see resources/Documentation/about.md.

IMPORTANT: Before installing/enabling the plugin follow the instructions from the setup guide, see resources/Documentation/setup-guide.md.