Page MenuHomePhabricator

Introduce way to bulk-lookup terms in normalized schema
Closed, ResolvedPublic

Description

The current TermIdsResolver can only be used to resolve the terms of a single entity, otherwise you don’t know which terms in the return value belong to which entity. We want to introduce some other service with input and output like the following:

[ 'Q123' => [ 0, 1, 2 ], 'Q456' => [ 7, 8 ] ]

[
  'Q123' => [
    'label' => [ 'en' => [ 'some label' ] ],
    'alias' => [ 'en' => [ 'some alias' ], 'de' => [ 'noch ein Alias' ] ],
  ],
  'Q456' => [
    'label' => [ 'en' => [ 'a label' ], 'de' => [ 'eine Beschriftung' ] ],
  ],
]

It doesn’t need to know what the keys mean, it just preserves the association between the keys and the terms / term IDs – while ideally still retrieving all the terms, for all the keys, in bulk. (Though a simple implementation can of course iterate over the top-level array and call TermIdsResolver::resolveTermIds separately each time.)

Could be part of TermIdsResolver (either as an additional method or even replacing the current resolveTermIds) or a separate interface; in either case, though, the database implementation should be in DatabaseTermIdsResolver, not some other class.


Patch-For-Review (added to TermIdsResolver interface):

Event Timeline

Change 514358 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Add TermIdsResolver::resolveTermIdsBatches() method

https://gerrit.wikimedia.org/r/514358

Change 514359 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Efficiently implement DatabaseTermIdsResolver::resolveTermIdsBatches()

https://gerrit.wikimedia.org/r/514359

Looks good to me! will wait on merging until tomorrow evening for @hoo review

Change 514358 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Add TermIdsResolver::resolveGroupedTermIds() method

https://gerrit.wikimedia.org/r/514358

Change 514359 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Efficiently implement DatabaseTermIdsResolver::resolveGroupedTermIds()

https://gerrit.wikimedia.org/r/514359

alaa_wmde closed this task as Resolved.Jun 6 2019, 11:13 AM

All patches have been merged and scope of this task has been covered by them

Well, the third patch is still waiting for gate-and-submit to finish…