Lucas_Werkmeister_WMDE added a comment.
I think the interface that `WikibaseRepo` and `WikibaseClient` use the most
is `PrefetchingTermLookup`, which is an intersection of the following two
interfaces:
- `TermLookup`, a straightforward entity→term mapping with the following
functions:
- `getLabel( EntityId $entityId, $languageCode )`
- `getLabels( EntityId $entityId, array $languageCodes )`
- `getDescription( EntityId $entityId, $languageCode )`
- `getDescriptions( EntityId $entityId, array $languageCodes )`
- `TermBuffer`, a more efficient interface for getting terms of several
entities in batch, with the following functions:
- `prefetchTerms( array $entityIds, array $termTypes, array $languageCodes
)`
- `getPrefetchedTerm( EntityId $entityId, $termType, $languageCode )`
(There is also a `TermIndex` interface, but that includes search functions
too, and I don’t think we’re interested in supporting those yet.)
A `TermLookup` would be very straightforward to implement as a wrapper around
a `PropertyTermStore` or `ItemTermStore`, and a simple `TermBuffer` could be
implemented by iterating over the `$entityIds`, but that means two database
queries per entity ID (get term IDs and resolve them), losing the batch aspect.
I think to properly and efficiently implement this, we’ll want an
implementation that’s separate from `PropertyTermStore` and `ItemTermStore`.
And unfortunately, I don’t think that implementation can use the same
`TermIdsResolver` either, at least not in its current form: if we combine the
term IDs of multiple properties/items into one batch and ask the
`TermIdsResolver` to resolve all of them, we won’t be able to tell which term
belongs to which entity. So either we still have one query per entity (and the
only benefit from batching is that we got the term IDs for all the entities in
one query), or we need to refine that interface somehow (or introduce a second
one more suitable for batching), or our implementation just skips over all that
abstraction and knows about the underlying `wbt_term_in_lang` etc. tables (but
that’s super ugly again).
TASK DETAIL
https://phabricator.wikimedia.org/T219303
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: Lucas_Werkmeister_WMDE
Cc: Lucas_Werkmeister_WMDE, Aklapper, alaa_wmde, darthmon_wmde, Premeditated,
Nandana, Lahi, Gq86, GoranSMilovanovic, QZanden, LawExplorer, _jensen,
rosalieper, Wikidata-bugs, aude, Lydia_Pintscher, Mbch331
_______________________________________________
Wikidata-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs