Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Lib\Store\Sql\Terms\InMemoryTermStore Class Reference
+ Inheritance diagram for Wikibase\Lib\Store\Sql\Terms\InMemoryTermStore:
+ Collaboration diagram for Wikibase\Lib\Store\Sql\Terms\InMemoryTermStore:

Public Member Functions

 acquireTermInLangIds (array $termsArray, $callback=null)
 Acquires IDs for the given terms.
 
 resolveTermInLangIds (array $termInLangIds, array $types=null, array $languages=null)
 Resolves terms for the given term in lang IDs.
 
 resolveGroupedTermInLangIds (array $groupedTermInLangIds, array $types=null, array $languages=null)
 Resolves terms for the given groups of term in lang IDs.
 
 cleanTermInLangIds (array $termInLangIds)
 Delete the given term in lang IDs.
 

Private Attributes

 $terms = []
 
 $lastId = 0
 

Detailed Description

Member Function Documentation

◆ acquireTermInLangIds()

Wikibase\Lib\Store\Sql\Terms\InMemoryTermStore::acquireTermInLangIds ( array $termsArray,
$callback = null )

Acquires IDs for the given terms.

The acquirer guarantees that an in-parallel TermStoreCleaner will not result in deleting terms that have been acquired by this acquirer, should these two in-parallel processes happen to overlap on some existing term in lang IDs. The mechanism of achieving this guarantee is complete under the following two conditions:

  • External linking to acquired IDs (e.g. using them as foreign keys in other tables) must happen inside the $callback.
  • The in-parallel cleaner is called with set of IDs based on the absence of any links to those IDs, in the same external places where the callback links to them.
Parameters
array$termsArrayarray containing terms per type per language. Example: [ 'label' => [ 'en' => 'some label', 'de' => 'another label', ... ], 'alias' => [ 'en' => [ 'alias', 'another alias', ...], 'de' => 'de alias', ... ], ... ]
callable | null$callbackCalled with int[] $termInLangIds right before attempting to restore any of those acquired IDs that might have been deleted by another process before acquireTermInLangIds() has returned.
Returns
int[] List of IDs of acquired terms in the store. Due to limitations in the underlying store, in rare cases the same ID might be returned for different terms.

Implements Wikibase\Lib\Store\Sql\Terms\TermInLangIdsAcquirer.

◆ cleanTermInLangIds()

Wikibase\Lib\Store\Sql\Terms\InMemoryTermStore::cleanTermInLangIds ( array $termInLangIds)

Delete the given term in lang IDs.

Ensuring that they are unreferenced is the caller’s responsibility.

Depending on the implementation, this may include further internal cleanups. In that case, the implementation takes care that those cleanups do not affect other (not deleted) term in lang IDs.

Parameters
int[]$termInLangIds

Implements Wikibase\Lib\Store\Sql\Terms\TermStoreCleaner.

◆ resolveGroupedTermInLangIds()

Wikibase\Lib\Store\Sql\Terms\InMemoryTermStore::resolveGroupedTermInLangIds ( array $groupedTermInLangIds,
array $types = null,
array $languages = null )

Resolves terms for the given groups of term in lang IDs.

The input is an array of term in lang ID arrays, with arbitrary keys. The return value is an array of terms structures, with the same keys, where the values belong to the term in lang IDs corresponding to that key. One call to this method is effectively equivalent to multiple calls to resolveTermInLangIds with the individual term in lang ID arrays, but may be more efficient than that, e.g. resolving all the term in lang IDs in one batch and then grouping them correctly afterwards.

Parameters
int[][]$groupedTermInLangIds
null | string[]$typesIf not null, only include results of these types
null | string[]$languagesIf not null, only include results in these languages
Returns
array[]

Implements Wikibase\Lib\Store\Sql\Terms\TermInLangIdsResolver.

◆ resolveTermInLangIds()

Wikibase\Lib\Store\Sql\Terms\InMemoryTermStore::resolveTermInLangIds ( array $termInLangIds,
array $types = null,
array $languages = null )

Resolves terms for the given term in lang IDs.

Note that the information whether the leaf nodes were single strings or arrays of strings is lost: while TermInLangIdsAcquirer::acquireTermInLangIds accepts both, this method always returns arrays of strings.

Parameters
int[]$termInLangIds
null | string[]$typesIf not null, only include results of these types
null | string[]$languagesIf not null, only include results in these languages
Returns
array containing terms per type per language. Example: [ 'label' => [ 'en' => [ 'some label' ], 'de' => [ 'another label' ], ... ], 'alias' => [ 'en' => [ 'alias', 'another alias', ...], 'de' => [ 'de alias' ], ... ], ... ]

Implements Wikibase\Lib\Store\Sql\Terms\TermInLangIdsResolver.

Member Data Documentation

◆ $lastId

Wikibase\Lib\Store\Sql\Terms\InMemoryTermStore::$lastId = 0
private

◆ $terms

Wikibase\Lib\Store\Sql\Terms\InMemoryTermStore::$terms = []
private

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