A TermInLangIdsAcquirer
implementation using the database tables wbt_term_in_lang, wbt_text_in_lang, and wbt_text.
More...
|
| mapToTypeIds (array $termsArray) |
| replace root keys containing type names in termsArray with their respective ids in wbt_type table
|
|
| mapToTextIds (array $termsArray, ReplicaPrimaryAwareRecordIdsAcquirer $textIdsAcquirer) |
| replace text at termsArray leaves with their ids in wbt_text table and return resulting array
|
|
| acquireTextIds (array $texts, ReplicaPrimaryAwareRecordIdsAcquirer $textIdsAcquirer) |
| Since the wbx_text column can hold at most 255 bytes, we truncate the the texts to that length before sending them to the acquirer.
|
|
| mapToTextInLangIds (array $termsArray, ReplicaPrimaryAwareRecordIdsAcquirer $textInLangIdsAcquirer) |
| replace ( lang => [ textId, ... ] ) entries with their respective ids in wbt_text_in_lang table and return resulting array
|
|
| acquireTextInLangIds (array $langTextIds, ReplicaPrimaryAwareRecordIdsAcquirer $textInLangIdsAcquirer) |
|
| mapToTermInLangIds (array $termsArray, ReplicaPrimaryAwareRecordIdsAcquirer $termInLangIdsAcquirer, array $idsToRestore=[]) |
| replace root ( type => [ textInLangId, ... ] ) entries with their respective ids in wbt_term_in_lang table and return resulting array
|
|
| acquireTermInLangIdsInner (array $typeTextInLangIds, ReplicaPrimaryAwareRecordIdsAcquirer $termInLangIdsAcquirer, array $idsToRestore=[]) |
|
| restoreCleanedUpIds (array $termsArray, array $termInLangIds=[]) |
|
| mapTermsArrayToTermIds (array $termsArray, array $termInLangIdsToRestore=[], $ignoreReplica=false) |
|
| calcRecordHash (array $record) |
|
| filterUniqueRecords (array $records) |
|
A TermInLangIdsAcquirer
implementation using the database tables wbt_term_in_lang, wbt_text_in_lang, and wbt_text.
Because the wbt_text.wbx_text column can only hold up to 255 bytes, terms longer than that (typically non-Latin descriptions) will be truncated, and different terms that only differ after the first 255 bytes will get the same term in lang ID (and thus same other ids too).
- See also
- Item & Property Terms
- Copyright
- GPL-2.0-or-later
◆ __construct()
Wikibase\Lib\Store\Sql\Terms\DatabaseTermInLangIdsAcquirer::__construct |
( |
RepoDomainDb |
$repoDb, |
|
|
TypeIdsAcquirer |
$typeIdsAcquirer, |
|
|
LoggerInterface |
$logger = null |
|
) |
| |
◆ acquireTermInLangIds()
Wikibase\Lib\Store\Sql\Terms\DatabaseTermInLangIdsAcquirer::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 | $termsArray | array containing terms per type per language. Example: [ 'label' => [ 'en' => 'some label', 'de' => 'another label', ... ], 'alias' => [ 'en' => [ 'alias', 'another alias', ...], 'de' => 'de alias', ... ], ... ] |
callable | null | $callback | Called 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.
◆ acquireTermInLangIdsInner()
Wikibase\Lib\Store\Sql\Terms\DatabaseTermInLangIdsAcquirer::acquireTermInLangIdsInner |
( |
array |
$typeTextInLangIds, |
|
|
ReplicaPrimaryAwareRecordIdsAcquirer |
$termInLangIdsAcquirer, |
|
|
array |
$idsToRestore = [] |
|
) |
| |
|
private |
◆ acquireTextIds()
Since the wbx_text column can hold at most 255 bytes, we truncate the the texts to that length before sending them to the acquirer.
Additional mappings ensure that we can still return a map from full, untruncated texts to text IDs (though multiple texts may share the same ID if they only differ after more than 255 bytes).
- Parameters
-
string[] | $texts | |
ReplicaPrimaryAwareRecordIdsAcquirer | $textIdsAcquirer | |
- Returns
- string[]
◆ acquireTextInLangIds()
◆ calcRecordHash()
Wikibase\Lib\Store\Sql\Terms\DatabaseTermInLangIdsAcquirer::calcRecordHash |
( |
array |
$record | ) |
|
|
private |
◆ filterUniqueRecords()
Wikibase\Lib\Store\Sql\Terms\DatabaseTermInLangIdsAcquirer::filterUniqueRecords |
( |
array |
$records | ) |
|
|
private |
◆ mapTermsArrayToTermIds()
Wikibase\Lib\Store\Sql\Terms\DatabaseTermInLangIdsAcquirer::mapTermsArrayToTermIds |
( |
array |
$termsArray, |
|
|
array |
$termInLangIdsToRestore = [] , |
|
|
|
$ignoreReplica = false |
|
) |
| |
|
private |
◆ mapToTermInLangIds()
Wikibase\Lib\Store\Sql\Terms\DatabaseTermInLangIdsAcquirer::mapToTermInLangIds |
( |
array |
$termsArray, |
|
|
ReplicaPrimaryAwareRecordIdsAcquirer |
$termInLangIdsAcquirer, |
|
|
array |
$idsToRestore = [] |
|
) |
| |
|
private |
replace root ( type => [ textInLangId, ... ] ) entries with their respective ids in wbt_term_in_lang table and return resulting array
- Parameters
-
array | $termsArray | text in lang ids per type [ 'type' => [ <textInLangId1>, <textInLangId2>, ... ], ... ] |
ReplicaPrimaryAwareRecordIdsAcquirer | $termInLangIdsAcquirer | |
array | $idsToRestore | |
- Returns
- array [ <termInLang1>, <termInLang2>, ... ]
◆ mapToTextIds()
replace text at termsArray leaves with their ids in wbt_text table and return resulting array
- Parameters
-
array | $termsArray | terms per type per language: [ 'type' => [ [ 'language' => 'term' | [ 'term1', 'term2', ... ] ], ... ], ... ] |
ReplicaPrimaryAwareRecordIdsAcquirer | $textIdsAcquirer | |
- Returns
- array [ 'type' => [ [ 'language' => [ <textId1>, <textId2>, ... ] ], ... ], ... ]
◆ mapToTextInLangIds()
replace ( lang => [ textId, ... ] ) entries with their respective ids in wbt_text_in_lang table and return resulting array
- Parameters
-
array | $termsArray | text ids per type per language [ 'type' => [ [ 'language' => [ <textId1>, <textId2>, ... ] ], ... ], ... ] |
ReplicaPrimaryAwareRecordIdsAcquirer | $textInLangIdsAcquirer | |
- Returns
- array [ 'type' => [ <textInLangId1>, <textInLangId2>, ... ], ... ]
◆ mapToTypeIds()
Wikibase\Lib\Store\Sql\Terms\DatabaseTermInLangIdsAcquirer::mapToTypeIds |
( |
array |
$termsArray | ) |
|
|
private |
replace root keys containing type names in termsArray with their respective ids in wbt_type table
- Parameters
-
array | $termsArray | terms per type per language: [ 'type1' => [ ... ], 'type2' => [ ... ], ... ] |
- Returns
- array [ <typeId1> => [ ... ], <typeId2> => [ ... ], ... ]
◆ restoreCleanedUpIds()
Wikibase\Lib\Store\Sql\Terms\DatabaseTermInLangIdsAcquirer::restoreCleanedUpIds |
( |
array |
$termsArray, |
|
|
array |
$termInLangIds = [] |
|
) |
| |
|
private |
◆ $logger
Wikibase\Lib\Store\Sql\Terms\DatabaseTermInLangIdsAcquirer::$logger |
|
private |
◆ $repoDb
Wikibase\Lib\Store\Sql\Terms\DatabaseTermInLangIdsAcquirer::$repoDb |
|
private |
◆ $typeIdsAcquirer
Wikibase\Lib\Store\Sql\Terms\DatabaseTermInLangIdsAcquirer::$typeIdsAcquirer |
|
private |
The documentation for this class was generated from the following file: