Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Repo\Dumpers\DumpGenerator Class Reference

DumpGenerator generates a dump of a given set of entities, excluding redirects. More...

+ Inheritance diagram for Wikibase\Repo\Dumpers\DumpGenerator:
+ Collaboration diagram for Wikibase\Repo\Dumpers\DumpGenerator:

Public Member Functions

 __construct ( $out, EntityPrefetcher $entityPrefetcher)
 
 setLimit (int $limit)
 Set maximum number of entities produced.
 
 setBatchSize (int $batchSize)
 Sets the batch size for processing.
 
 setProgressReporter (MessageReporter $progressReporter)
 
 setExceptionHandler (ExceptionHandler $exceptionHandler)
 
 setShardingFilter ( $shardingFactor, $shard)
 Set the sharding factor and desired shard.
 
 setEntityTypesFilter (?array $types)
 Set the entity types to be included in the output.
 
 setBatchCallback (callable $callback)
 Set a callback that is called once per batch, at the beginning of each batch.
 
 generateDump (EntityIdPager $idPager)
 Generates a dump, writing to the file handle provided to the constructor.
 

Protected Member Functions

 writeToDump (string $data)
 Writers the given string to the output provided to the constructor.
 
 preDump ()
 Do something before dumping data.
 
 postDump ()
 Do something after dumping data.
 
 preBatchDump (array $entities)
 Do something before dumping a batch of entities.
 
 preEntityDump (int $dumpCount)
 Do something before dumping entity.
 
 postEntityDump (int $dumpCount)
 Do something after dumping entity.
 
 generateDumpForEntityId (EntityId $entityId)
 Produce dump data for specific entity.
 

Protected Attributes

int $batchSize = 100
 
 $out
 
int $shardingFactor = 1
 
int $shard = 0
 
MessageReporter $progressReporter
 
ExceptionHandler $exceptionHandler
 
EntityPrefetcher $entityPrefetcher
 
array $entityTypes = null
 
int $limit = 0
 Entity count limit - dump will generate this many.
 

Private Member Functions

 idMatchesFilters (EntityId $entityId)
 
 idMatchesShard (EntityId $entityId)
 
 idMatchesType (EntityId $entityId)
 
 dumpEntities (array $entityIds, int &$dumpCount)
 Dump list of entities.
 

Private Attributes

 $batchCallback
 

Detailed Description

DumpGenerator generates a dump of a given set of entities, excluding redirects.

Author
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\Dumpers\DumpGenerator::__construct ( $out,
EntityPrefetcher $entityPrefetcher )
Parameters
resource$out
EntityPrefetcher$entityPrefetcher
Exceptions
InvalidArgumentException

Member Function Documentation

◆ dumpEntities()

Wikibase\Repo\Dumpers\DumpGenerator::dumpEntities ( array $entityIds,
int & $dumpCount )
private

Dump list of entities.

Parameters
EntityId[]$entityIds
int&$dumpCountThe number of entities already dumped (will be updated).

◆ generateDump()

Wikibase\Repo\Dumpers\DumpGenerator::generateDump ( EntityIdPager $idPager)

Generates a dump, writing to the file handle provided to the constructor.

◆ generateDumpForEntityId()

Wikibase\Repo\Dumpers\DumpGenerator::generateDumpForEntityId ( EntityId $entityId)
abstractprotected

Produce dump data for specific entity.

Parameters
EntityId$entityId
Exceptions
EntityLookupException
StorageException
Returns
string|null

Reimplemented in Wikibase\Repo\Dumpers\JsonDumpGenerator, and Wikibase\Repo\Dumpers\RdfDumpGenerator.

◆ idMatchesFilters()

Wikibase\Repo\Dumpers\DumpGenerator::idMatchesFilters ( EntityId $entityId)
private

◆ idMatchesShard()

Wikibase\Repo\Dumpers\DumpGenerator::idMatchesShard ( EntityId $entityId)
private

◆ idMatchesType()

Wikibase\Repo\Dumpers\DumpGenerator::idMatchesType ( EntityId $entityId)
private

◆ postDump()

Wikibase\Repo\Dumpers\DumpGenerator::postDump ( )
protected

Do something after dumping data.

Reimplemented in Wikibase\Repo\Dumpers\JsonDumpGenerator, and Wikibase\Repo\Dumpers\RdfDumpGenerator.

◆ postEntityDump()

Wikibase\Repo\Dumpers\DumpGenerator::postEntityDump ( int $dumpCount)
protected

Do something after dumping entity.

◆ preBatchDump()

Wikibase\Repo\Dumpers\DumpGenerator::preBatchDump ( array $entities)
protected

Do something before dumping a batch of entities.

Parameters
EntityId[]$entities

◆ preDump()

Wikibase\Repo\Dumpers\DumpGenerator::preDump ( )
protected

Do something before dumping data.

Reimplemented in Wikibase\Repo\Dumpers\JsonDumpGenerator, and Wikibase\Repo\Dumpers\RdfDumpGenerator.

◆ preEntityDump()

Wikibase\Repo\Dumpers\DumpGenerator::preEntityDump ( int $dumpCount)
protected

Do something before dumping entity.

Reimplemented in Wikibase\Repo\Dumpers\JsonDumpGenerator.

◆ setBatchCallback()

Wikibase\Repo\Dumpers\DumpGenerator::setBatchCallback ( callable $callback)

Set a callback that is called once per batch, at the beginning of each batch.

◆ setBatchSize()

Wikibase\Repo\Dumpers\DumpGenerator::setBatchSize ( int $batchSize)

Sets the batch size for processing.

The batch size is used as the limit when listing IDs via the EntityIdPager::getNextBatchOfIds() method, and also controls the interval of progress reports.

Exceptions
InvalidArgumentException

◆ setEntityTypesFilter()

Wikibase\Repo\Dumpers\DumpGenerator::setEntityTypesFilter ( ?array $types)

Set the entity types to be included in the output.

Parameters
string[] | null$typesThe desired types (use null for any type).

◆ setExceptionHandler()

Wikibase\Repo\Dumpers\DumpGenerator::setExceptionHandler ( ExceptionHandler $exceptionHandler)

◆ setLimit()

Wikibase\Repo\Dumpers\DumpGenerator::setLimit ( int $limit)

Set maximum number of entities produced.

◆ setProgressReporter()

Wikibase\Repo\Dumpers\DumpGenerator::setProgressReporter ( MessageReporter $progressReporter)

◆ setShardingFilter()

Wikibase\Repo\Dumpers\DumpGenerator::setShardingFilter ( $shardingFactor,
$shard )

Set the sharding factor and desired shard.

For instance, to generate four dumps in parallel, use setShardingFilter( 4, 0 ) for the first dump, setShardingFilter( 4, 1 ) for the second dump, etc.

Parameters
int$shardingFactor
int$shard
Exceptions
InvalidArgumentException

◆ writeToDump()

Wikibase\Repo\Dumpers\DumpGenerator::writeToDump ( string $data)
protected

Writers the given string to the output provided to the constructor.

Member Data Documentation

◆ $batchCallback

Wikibase\Repo\Dumpers\DumpGenerator::$batchCallback
private

◆ $batchSize

int Wikibase\Repo\Dumpers\DumpGenerator::$batchSize = 100
protected

◆ $entityPrefetcher

EntityPrefetcher Wikibase\Repo\Dumpers\DumpGenerator::$entityPrefetcher
protected

◆ $entityTypes

array Wikibase\Repo\Dumpers\DumpGenerator::$entityTypes = null
protected

◆ $exceptionHandler

ExceptionHandler Wikibase\Repo\Dumpers\DumpGenerator::$exceptionHandler
protected

◆ $limit

int Wikibase\Repo\Dumpers\DumpGenerator::$limit = 0
protected

Entity count limit - dump will generate this many.

◆ $out

Wikibase\Repo\Dumpers\DumpGenerator::$out
protected

◆ $progressReporter

MessageReporter Wikibase\Repo\Dumpers\DumpGenerator::$progressReporter
protected

◆ $shard

int Wikibase\Repo\Dumpers\DumpGenerator::$shard = 0
protected

◆ $shardingFactor

int Wikibase\Repo\Dumpers\DumpGenerator::$shardingFactor = 1
protected

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