/** * @param integer $offset Start to include at number of entries from the start title * @param integer $limit Stop at number of entries after start of inclusion * * @return PropertyId[] */ protected function getResult($offset = 0, $limit = 0) { $propertyInfo = array_slice($this->getPropertyInfo(), $offset, $limit, true); $propertyIds = array(); foreach ($propertyInfo as $numericId => $info) { $propertyIds[] = PropertyId::newFromNumber($numericId); } $this->bufferingTermLookup->prefetchTerms($propertyIds); return $propertyIds; }
public function testGetLabels_buffer() { $termIndex = $this->getRestrictedTermIndex(2, 0); $lookup = new BufferingTermLookup($termIndex, 10); $q116 = new ItemId('Q123'); // This should trigger one call to getTermsOfEntity $expected = array('de' => 'Wien', 'en' => 'Vienna'); $this->assertEquals($expected, $lookup->getLabels($q116, array('de', 'en', 'it'))); // This should trigger no more calls, since the label for 'en' is in the buffer $this->assertEquals('Vienna', $lookup->getLabel($q116, 'en')); // This should trigger no more calls to the TermIndex, since the label for 'it' is in the // buffer as a negative entry. $this->assertEquals(array(), $lookup->getLabels($q116, array('it'))); // This should trigger one call to getTermsOfEntity $this->assertEquals('Vienne', $lookup->getLabel($q116, 'fr')); // This should trigger no more calls to the TermIndex, since all languages are in the buffer // now. $expected = array('de' => 'Wien', 'fr' => 'Vienne'); $this->assertEquals($expected, $lookup->getLabels($q116, array('de', 'fr'))); }
/** * @param EntityId[] $entityIds */ private function preFetchLabelsAndDescriptionsForDisplay(array $entityIds) { $this->bufferingTermLookup->prefetchTerms($entityIds, array(TermIndexEntry::TYPE_LABEL, TermIndexEntry::TYPE_DESCRIPTION), $this->addFallbackLanguageCodes(array($this->displayLanguageCode))); }