Implements bulk updates for the repo's wb_changes_subscription table, based on the client's local wbc_entity_usage table.
More...
|
| processUpdateBatch (array &$continuation=null) |
|
| insertUpdateBatch (array $entities) |
|
| getUpdateBatch (array &$continuation=null) |
|
| makeSubscriptionRows (array $entities) |
| Returns a list of rows for insertion, using DatabaseBase's multi-row insert mechanism.
|
|
| getEntityIdsFromRows (IResultWrapper $res, $entityIdField, array &$continuation=null) |
| Extracts entity id strings from the rows in a query result, and updates $continuation to a position "after" the content of the given query result.
|
|
| processDeletionBatch (array &$continuation=null) |
|
| getDeletionRange (array &$continuation=null) |
| Returns a range of entity IDs to delete, based on this updater's batch size.
|
|
| deleteSubscriptionRange (string $minId, string $maxId) |
| Deletes a range of subscriptions.
|
|
Implements bulk updates for the repo's wb_changes_subscription table, based on the client's local wbc_entity_usage table.
The client wiki will be subscribed to be informed about changes to any entity present in the local wbc_entity_usage table.
- Copyright
- GPL-2.0-or-later
- Author
- Daniel Kinzler
◆ __construct()
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::__construct |
( |
ClientDomainDb | $clientDb, |
|
|
RepoDomainDb | $repoDb, |
|
|
string | $subscriberWikiId, |
|
|
int | $batchSize = 1000 ) |
- Parameters
-
ClientDomainDb | $clientDb | DB manager for DB connections to the local wiki. |
RepoDomainDb | $repoDb | DB manager for DB connections to the repo. |
string | $subscriberWikiId | The local wiki's global ID, to be used as the subscriber ID in the repo's subscription table. |
int | $batchSize | |
- Exceptions
-
◆ deleteSubscriptionRange()
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::deleteSubscriptionRange |
( |
string | $minId, |
|
|
string | $maxId ) |
|
private |
Deletes a range of subscriptions.
- Parameters
-
string | $minId | Entity id string indicating the first element in the deletion range |
string | $maxId | Entity id string indicating the last element in the deletion range |
◆ getDeletionRange()
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::getDeletionRange |
( |
array & | $continuation = null | ) |
|
|
private |
Returns a range of entity IDs to delete, based on this updater's batch size.
- Parameters
-
array | null | &$continuation | |
- Returns
- array|false list( $minId, $maxId, $count ), or false if there is nothing to delete
- Note
- Below, we query and iterate all rows we want to delete in the current batch. That is rather ugly, but appears to be the best solution, because:
- Deletions must be paged to avoid lock retention.
- DELETE does not support LIMIT, so we need to know a range (min/max) of IDs.
- GROUP BY does not support LIMIT, so we cannot use aggregate functions to get the min/max IDs.
Thus, using SELECT ... LIMIT seems to be the only reliable way to get the min/max range needed for batched deletion.
◆ getEntityIdsFromRows()
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::getEntityIdsFromRows |
( |
IResultWrapper | $res, |
|
|
| $entityIdField, |
|
|
array & | $continuation = null ) |
|
private |
Extracts entity id strings from the rows in a query result, and updates $continuation to a position "after" the content of the given query result.
- Parameters
-
IResultWrapper | $res | A result set with the field given by $entityIdField field set for each row. The result is expected to be sorted by entity id, in ascending order. |
string | $entityIdField | The name of the field that contains the entity id. |
array | null | &$continuation | Updated to an array containing the last EntityId in the result. |
- Returns
- string[] A list of entity ids strings.
◆ getUpdateBatch()
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::getUpdateBatch |
( |
array & | $continuation = null | ) |
|
|
private |
- Parameters
-
array | null | &$continuation | |
- Returns
- string[] A list of entity id strings.
◆ insertUpdateBatch()
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::insertUpdateBatch |
( |
array | $entities | ) |
|
|
private |
- Parameters
-
string[] | $entities | Entity-IDs to subscribe to |
- Returns
- int The number of rows inserted.
◆ makeSubscriptionRows()
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::makeSubscriptionRows |
( |
array | $entities | ) |
|
|
private |
Returns a list of rows for insertion, using DatabaseBase's multi-row insert mechanism.
Each row is represented as [ $entityId, $subscriber ].
- Parameters
-
string[] | $entities | entity id strings |
- Returns
- array[] rows
◆ processDeletionBatch()
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::processDeletionBatch |
( |
array & | $continuation = null | ) |
|
|
private |
- Parameters
-
array | null | &$continuation | |
- Returns
- int The number of subscriptions deleted.
◆ processUpdateBatch()
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::processUpdateBatch |
( |
array & | $continuation = null | ) |
|
|
private |
- Parameters
-
array | null | &$continuation | |
- Returns
- int The number of subscriptions inserted.
◆ purgeSubscriptions()
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::purgeSubscriptions |
( |
EntityId | $startEntity = null | ) |
|
Remove subscriptions for entities not present in in wbc_entity_usage.
- Parameters
-
EntityId | null | $startEntity | The entity to start with. |
◆ setProgressReporter()
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::setProgressReporter |
( |
MessageReporter | $progressReporter | ) |
|
◆ updateSubscriptions()
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::updateSubscriptions |
( |
EntityId | $startEntity = null | ) |
|
Insert subscriptions based on entries in wbc_entity_usage.
- Parameters
-
EntityId | null | $startEntity | The entity to start with. |
◆ $batchSize
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::$batchSize |
|
private |
◆ $localConnectionManager
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::$localConnectionManager |
|
private |
◆ $progressReporter
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::$progressReporter |
|
private |
◆ $repoConnectionManager
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::$repoConnectionManager |
|
private |
◆ $repoDb
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::$repoDb |
|
private |
◆ $subscriberWikiId
Wikibase\Client\Store\Sql\BulkSubscriptionUpdater::$subscriberWikiId |
|
private |
The documentation for this class was generated from the following file: