|
MediaWiki master
|
Ties together the batch update components to provide a composable method of batch updating rows in a database. More...

Public Member Functions | |
| __construct (BatchRowIterator $reader, BatchRowWriter $writer, RowUpdateGenerator $generator) | |
| execute () | |
| Runs the batch update process. | |
| setOutput (callable $output) | |
| Accepts a callable which will receive a single parameter containing string status updates. | |
Protected Member Functions | |
| output ( $text) | |
| Write out a status update. | |
Protected Attributes | |
| RowUpdateGenerator | $generator |
| Generates single row updates based on the rows content. | |
| callable | $output |
| Output callback. | |
| BatchRowIterator | $reader |
| Iterator that returns an array of database rows. | |
| BatchRowWriter | $writer |
| Writer capable of pushing row updates to the database. | |
Ties together the batch update components to provide a composable method of batch updating rows in a database.
To use create a class implementing the RowUpdateGenerator interface and configure the BatchRowIterator and BatchRowWriter for access to the correct table. The components will handle reading, writing, and waiting for replica DBs while the generator implementation handles generating update arrays for singular rows.
Instantiate: $updater = new BatchRowUpdate( new BatchRowIterator( $dbr, 'some_table', 'primary_key_column', 500 ), new BatchRowWriter( $dbw, 'some_table', 'clusterName' ), new MyImplementationOfRowUpdateGenerator );
Run: $updater->execute();
An example maintenance script utilizing the BatchRowUpdate can be located in the Echo extension file maintenance/updateSchema.php
Definition at line 32 of file BatchRowUpdate.php.
| MediaWiki\Utils\BatchRowUpdate::__construct | ( | BatchRowIterator | $reader, |
| BatchRowWriter | $writer, | ||
| RowUpdateGenerator | $generator ) |
| BatchRowIterator | $reader | Iterator that returns an array of database rows |
| BatchRowWriter | $writer | Writer capable of pushing row updates to the database |
| RowUpdateGenerator | $generator | Generates single row updates based on the rows content |
Definition at line 64 of file BatchRowUpdate.php.
References MediaWiki\Utils\BatchRowUpdate\$generator, MediaWiki\Utils\BatchRowUpdate\$reader, MediaWiki\Utils\BatchRowUpdate\$writer, and MediaWiki\Utils\BatchRowUpdate\output().
| MediaWiki\Utils\BatchRowUpdate::execute | ( | ) |
Runs the batch update process.
Definition at line 77 of file BatchRowUpdate.php.
References MediaWiki\Utils\BatchRowUpdate\output().
|
protected |
Write out a status update.
| string | $text | The value to print |
Definition at line 115 of file BatchRowUpdate.php.
References MediaWiki\Utils\BatchRowUpdate\$output.
Referenced by MediaWiki\Utils\BatchRowUpdate\__construct(), MediaWiki\Utils\BatchRowUpdate\execute(), and MediaWiki\Utils\BatchRowUpdate\setOutput().
| MediaWiki\Utils\BatchRowUpdate::setOutput | ( | callable | $output | ) |
Accepts a callable which will receive a single parameter containing string status updates.
| callable | $output | A callback taking a single string parameter to output |
Definition at line 106 of file BatchRowUpdate.php.
References MediaWiki\Utils\BatchRowUpdate\$output, and MediaWiki\Utils\BatchRowUpdate\output().
|
protected |
Generates single row updates based on the rows content.
Definition at line 49 of file BatchRowUpdate.php.
Referenced by MediaWiki\Utils\BatchRowUpdate\__construct().
|
protected |
Output callback.
Definition at line 54 of file BatchRowUpdate.php.
Referenced by MediaWiki\Utils\BatchRowUpdate\output(), and MediaWiki\Utils\BatchRowUpdate\setOutput().
|
protected |
Iterator that returns an array of database rows.
Definition at line 37 of file BatchRowUpdate.php.
Referenced by MediaWiki\Utils\BatchRowUpdate\__construct().
|
protected |
Writer capable of pushing row updates to the database.
Definition at line 43 of file BatchRowUpdate.php.
Referenced by MediaWiki\Utils\BatchRowUpdate\__construct().