MediaWiki master
MediaWiki\Utils\BatchRowUpdate Class Reference

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

Collaboration diagram for MediaWiki\Utils\BatchRowUpdate:

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Utils\BatchRowUpdate::__construct ( BatchRowIterator $reader,
BatchRowWriter $writer,
RowUpdateGenerator $generator )
Parameters
BatchRowIterator$readerIterator that returns an array of database rows
BatchRowWriter$writerWriter capable of pushing row updates to the database
RowUpdateGenerator$generatorGenerates 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().

Member Function Documentation

◆ execute()

MediaWiki\Utils\BatchRowUpdate::execute ( )

Runs the batch update process.

Definition at line 77 of file BatchRowUpdate.php.

References MediaWiki\Utils\BatchRowUpdate\output().

◆ output()

MediaWiki\Utils\BatchRowUpdate::output ( $text)
protected

Write out a status update.

Parameters
string$textThe 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().

◆ setOutput()

MediaWiki\Utils\BatchRowUpdate::setOutput ( callable $output)

Accepts a callable which will receive a single parameter containing string status updates.

Parameters
callable$outputA 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().

Member Data Documentation

◆ $generator

RowUpdateGenerator MediaWiki\Utils\BatchRowUpdate::$generator
protected

Generates single row updates based on the rows content.

Definition at line 49 of file BatchRowUpdate.php.

Referenced by MediaWiki\Utils\BatchRowUpdate\__construct().

◆ $output

callable MediaWiki\Utils\BatchRowUpdate::$output
protected

Output callback.

Definition at line 54 of file BatchRowUpdate.php.

Referenced by MediaWiki\Utils\BatchRowUpdate\output(), and MediaWiki\Utils\BatchRowUpdate\setOutput().

◆ $reader

BatchRowIterator MediaWiki\Utils\BatchRowUpdate::$reader
protected

Iterator that returns an array of database rows.

Definition at line 37 of file BatchRowUpdate.php.

Referenced by MediaWiki\Utils\BatchRowUpdate\__construct().

◆ $writer

BatchRowWriter MediaWiki\Utils\BatchRowUpdate::$writer
protected

Writer capable of pushing row updates to the database.

Definition at line 43 of file BatchRowUpdate.php.

Referenced by MediaWiki\Utils\BatchRowUpdate\__construct().


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