Aude has uploaded a new change for review. https://gerrit.wikimedia.org/r/182660
Change subject: Batch page id lookups for addLinks to ParserOutput ...................................................................... Batch page id lookups for addLinks to ParserOutput This uses LinkBatch which takes care of batching the queries to get page data, including page id. Then, ParserOutput::addLink accepts page_id as the second parameter and then skips database lookup (one-by-one) there. For my large test item, this change saves about a second of parsing time. Change-Id: Ie58704b167d3778445980e1ccfd338a917c75397 --- M repo/includes/EntityParserOutputGenerator.php 1 file changed, 17 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/60/182660/1 diff --git a/repo/includes/EntityParserOutputGenerator.php b/repo/includes/EntityParserOutputGenerator.php index 958a529..38b85ee 100644 --- a/repo/includes/EntityParserOutputGenerator.php +++ b/repo/includes/EntityParserOutputGenerator.php @@ -2,7 +2,9 @@ namespace Wikibase; +use LinkBatch; use ParserOutput; +use Title; use Wikibase\DataModel\Entity\EntityDocument; use Wikibase\DataModel\Entity\EntityId; use Wikibase\DataModel\Entity\Item; @@ -175,8 +177,21 @@ * @param EntityId[] $entityIds */ private function addEntityLinksToParserOutput( ParserOutput $parserOutput, array $entityIds ) { - foreach ( $entityIds as $entityId ) { - $parserOutput->addLink( $this->entityTitleLookup->getTitleForId( $entityId ) ); + $linkBatch = new LinkBatch(); + + foreach( $entityIds as $entityId ) { + $linkBatch->addObj( $this->entityTitleLookup->getTitleForId( $entityId ) ); + } + + $pages = $linkBatch->doQuery(); + + if ( $pages === false ) { + return; + } + + foreach( $pages as $page ) { + $title = Title::makeTitle( $page->page_namespace, $page->page_title ); + $parserOutput->addLink( $title, $page->page_id ); } } -- To view, visit https://gerrit.wikimedia.org/r/182660 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie58704b167d3778445980e1ccfd338a917c75397 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Aude <aude.w...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits