Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Lib\Store\BufferingTermIndexTermLookup Class Reference

Prefetches from TermIndex(DB) and stores them in MapCacheLRU (current process only). More...

+ Inheritance diagram for Wikibase\Lib\Store\BufferingTermIndexTermLookup:
+ Collaboration diagram for Wikibase\Lib\Store\BufferingTermIndexTermLookup:

Public Member Functions

 __construct (TermIndex $termIndex, $bufferSize=1000)
 
 prefetchTerms (array $entityIds, array $termTypes, array $languageCodes)
 Loads a set of terms into the buffer.
 
 getPrefetchedTerm (EntityId $entityId, $termType, $languageCode)
 Returns a term that was previously loaded by prefetchTerms.
 
 getPrefetchedAliases (EntityId $entityId, $languageCode)
 Returns terms that were previously loaded by prefetchTerms.
Parameters
EntityId$entityId
string$languageCode
Returns
string[]|false|null The aliases, or false of that entity has no aliases, or null if the term was not yet requested via prefetchTerms().

 
- Public Member Functions inherited from Wikibase\Lib\Store\EntityTermLookupBase
 getLabel (EntityId $entityId, $languageCode)
 
 getLabels (EntityId $entityId, array $languageCodes)
 
 getDescription (EntityId $entityId, $languageCode)
 
 getDescriptions (EntityId $entityId, array $languageCodes)
 

Protected Member Functions

 getTermsOfType (EntityId $entityId, $termType, array $languageCodes)
 Get terms from the TermBuffer but falls back to TermIndex if languages are requested that have no previously been fetched.
 
- Protected Member Functions inherited from Wikibase\Lib\Store\EntityTermLookupBase
 convertTermsToMap (array $wikibaseTerms)
 

Private Member Functions

 getBufferKey (EntityId $entityId, string $termType, string $languageCode)
 
 getBufferKeyWithEntityIdString (string $entityIdSerialization, string $termType, string $languageCode)
 
 getBufferKeys (array $entityIds, array $termTypes, array $languageCodes)
 Sets they keys for the given combinations of entity, type and language to false if they are not currently in the buffer (and not in $skipKeys).
 
 getIncompletelyPrefetchedEntityIds (array $entityIds, array $termTypes, array $languageCodes)
 Get a list of EntityIds for which we don't have all the needed data prefetched for.
 
 isIncompletelyPrefetched (EntityId $entityId, array $termTypes, array $languageCodes)
 Has the term type and language code combination from the given entity already been prefeteched?
 
 getBufferedTerms (EntityId $entityId, $termType, array $languageCodes)
 
 setBufferedTermObjects (array $terms)
 
 setBufferedTermObject (string $key, string $type, array $termsOfLanguage)
 
 setUndefinedTerms (array $entityIds, array $termTypes, array $languageCodes, array $skipKeys)
 Sets they keys for the given combinations of entity, type and language to false if they are not currently in the buffer (and not in $skipKeys).
 
 stripUndefinedTerms (array $terms)
 Remove all non-string entries from an array.
 
 groupEntityIds (array $entityIds)
 

Private Attributes

 $buffer
 
 $termIndex
 

Detailed Description

Prefetches from TermIndex(DB) and stores them in MapCacheLRU (current process only).

Looks up terms from MapCacheLRU, but also falls back to TermIndex(DB) in the case that requested languages have not already been fetched.

This extra fetch fallback behaviour is not the norm in currently PrefetchingTermLookup implementations. Per the stats call that has been added, it doesnt appear to happen in Wikidata production. This odd extra logic will be removed along with this class when wb_terms is finally killed.

Author
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\Store\BufferingTermIndexTermLookup::__construct ( TermIndex  $termIndex,
  $bufferSize = 1000 
)
Parameters
TermIndex$termIndex
int$bufferSize

Member Function Documentation

◆ getBufferedTerms()

Wikibase\Lib\Store\BufferingTermIndexTermLookup::getBufferedTerms ( EntityId  $entityId,
  $termType,
array  $languageCodes 
)
private
Parameters
EntityId$entityId
string$termType
string[]$languageCodesThe language codes to try
Returns
string[] The terms found in the buffer, keyed by language code. Note that this may include negative cache values, that is, some language codes may may to false. Use stripUndefinedTerms() to remove these.

◆ getBufferKey()

Wikibase\Lib\Store\BufferingTermIndexTermLookup::getBufferKey ( EntityId  $entityId,
string  $termType,
string  $languageCode 
)
private

◆ getBufferKeys()

Wikibase\Lib\Store\BufferingTermIndexTermLookup::getBufferKeys ( array  $entityIds,
array  $termTypes,
array  $languageCodes 
)
private

Sets they keys for the given combinations of entity, type and language to false if they are not currently in the buffer (and not in $skipKeys).

Parameters
EntityId[]$entityIds
string[]$termTypes
string[]$languageCodes
Returns
string[] the buffer keys

◆ getBufferKeyWithEntityIdString()

Wikibase\Lib\Store\BufferingTermIndexTermLookup::getBufferKeyWithEntityIdString ( string  $entityIdSerialization,
string  $termType,
string  $languageCode 
)
private

◆ getIncompletelyPrefetchedEntityIds()

Wikibase\Lib\Store\BufferingTermIndexTermLookup::getIncompletelyPrefetchedEntityIds ( array  $entityIds,
array  $termTypes,
array  $languageCodes 
)
private

Get a list of EntityIds for which we don't have all the needed data prefetched for.

Parameters
EntityId[]$entityIds
string[]$termTypes
string[]$languageCodes
Returns
EntityId[]

◆ getPrefetchedAliases()

Wikibase\Lib\Store\BufferingTermIndexTermLookup::getPrefetchedAliases ( EntityId  $entityId,
  $languageCode 
)

Returns terms that were previously loaded by prefetchTerms.

Parameters
EntityId$entityId
string$languageCode
Returns
string[]|false|null The aliases, or false of that entity has no aliases, or null if the term was not yet requested via prefetchTerms().

Implements Wikibase\DataAccess\AliasTermBuffer.

◆ getPrefetchedTerm()

Wikibase\Lib\Store\BufferingTermIndexTermLookup::getPrefetchedTerm ( EntityId  $entityId,
  $termType,
  $languageCode 
)

Returns a term that was previously loaded by prefetchTerms.

Parameters
EntityId$entityId
string$termType
string$languageCode
Returns
string|false|null The term, or false if that term is known to not exist, or null if the term was not yet requested via prefetchTerms().

◆ getTermsOfType()

Wikibase\Lib\Store\BufferingTermIndexTermLookup::getTermsOfType ( EntityId  $entityId,
  $termType,
array  $languageCodes 
)
protected

Get terms from the TermBuffer but falls back to TermIndex if languages are requested that have no previously been fetched.

Parameters
EntityId$entityId
string$termType
string[]$languageCodesThe languages to get terms for
Returns
string[]

Reimplemented from Wikibase\Lib\Store\EntityTermLookupBase.

◆ groupEntityIds()

Wikibase\Lib\Store\BufferingTermIndexTermLookup::groupEntityIds ( array  $entityIds)
private
Parameters
EntityId[]$entityIds
Returns
array[]

◆ isIncompletelyPrefetched()

Wikibase\Lib\Store\BufferingTermIndexTermLookup::isIncompletelyPrefetched ( EntityId  $entityId,
array  $termTypes,
array  $languageCodes 
)
private

Has the term type and language code combination from the given entity already been prefeteched?

Parameters
EntityId$entityId
string[]$termTypes
string[]$languageCodes
Returns
bool

◆ prefetchTerms()

Wikibase\Lib\Store\BufferingTermIndexTermLookup::prefetchTerms ( array  $entityIds,
array  $termTypes,
array  $languageCodes 
)

Loads a set of terms into the buffer.

The source from which to fetch would typically be supplied to the buffer's constructor.

Parameters
EntityId[]$entityIds
string[] | null$termTypes
string[] | null$languageCodes
Exceptions
StorageException

◆ setBufferedTermObject()

Wikibase\Lib\Store\BufferingTermIndexTermLookup::setBufferedTermObject ( string  $key,
string  $type,
array  $termsOfLanguage 
)
private
Parameters
string$key
string$type
TermIndexEntry[]$termsOfLanguage

◆ setBufferedTermObjects()

Wikibase\Lib\Store\BufferingTermIndexTermLookup::setBufferedTermObjects ( array  $terms)
private
Parameters
TermIndexEntry[]$terms
Returns
string[] The buffer keys to which the terms were assigned.

◆ setUndefinedTerms()

Wikibase\Lib\Store\BufferingTermIndexTermLookup::setUndefinedTerms ( array  $entityIds,
array  $termTypes,
array  $languageCodes,
array  $skipKeys 
)
private

Sets they keys for the given combinations of entity, type and language to false if they are not currently in the buffer (and not in $skipKeys).

Parameters
EntityId[]$entityIds
string[]$termTypes
string[]$languageCodes
string[]$skipKeysKeys known to refer to existing terms.

◆ stripUndefinedTerms()

Wikibase\Lib\Store\BufferingTermIndexTermLookup::stripUndefinedTerms ( array  $terms)
private

Remove all non-string entries from an array.

Useful for getting rid of negative cache entries. Still allows arrays to be stored for aliases.

Parameters
string[]$terms
Returns
string[]

Member Data Documentation

◆ $buffer

Wikibase\Lib\Store\BufferingTermIndexTermLookup::$buffer
private

◆ $termIndex

Wikibase\Lib\Store\BufferingTermIndexTermLookup::$termIndex
private

The documentation for this class was generated from the following file: