Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Client\Usage\Sql\EntityUsageTable Class Reference

Helper class for updating the wbc_entity_usage table. More...

+ Collaboration diagram for Wikibase\Client\Usage\Sql\EntityUsageTable:

Public Member Functions

 __construct (EntityIdParser $idParser, ?IDatabase $writeConnection, int $batchSize=100, ?string $tableName=null, int $addUsagesBatchSize=500)
 
 addUsages (int $pageId, array $usages)
 
 queryUsages (int $pageId)
 
 pruneUsages (int $pageId)
 Removes all usage tracking for a given page.
 
 removeUsages (int $pageId, array $usages)
 
 getPagesUsing (array $entityIds, array $aspects=[])
 
 getUnusedEntities (array $entityIds)
 
 setAddUsagesBatchSize (int $addUsagesBatchSize)
 Set the batch size for adding entity usage records.
 

Public Attributes

const DEFAULT_TABLE_NAME = 'wbc_entity_usage'
 

Private Member Functions

 getWriteConnection ()
 
 getAffectedRowIds (int $pageId, array $usages)
 
 makeUsageRows (int $pageId, array $usages)
 
 getEntityIdStrings (array $entityIds)
 
 convertRowsToUsages (Traversable $rows)
 
 foldRowsIntoPageEntityUsages (Traversable $rows)
 
 getUsedEntityIdStrings (array $idStrings)
 Returns those entity ids which are used from a given set of entity ids.
 
 getUsedEntityIdStringsQueries (array $idStrings)
 
 getPrimaryKeys (array $where, string $method)
 Returns the primary keys for the given where clause.
 
 getUsedEntityIdStringsMySql (array $subQueries, IReadableDatabase $readConnection)
 

Private Attributes

EntityIdParser $idParser
 
IDatabase $writeConnection
 
ClientDomainDb $db
 
int $batchSize
 
string $tableName
 
int $addUsagesBatchSize
 
LoggerInterface $logger
 

Detailed Description

Helper class for updating the wbc_entity_usage table.

This is used internally by SqlUsageTracker.

Author
Daniel Kinzler
Marius Hoch

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Client\Usage\Sql\EntityUsageTable::__construct ( EntityIdParser $idParser,
?IDatabase $writeConnection,
int $batchSize = 100,
?string $tableName = null,
int $addUsagesBatchSize = 500 )
Parameters
EntityIdParser$idParser
IDatabase | null$writeConnectionIf null, this instance can only be used for “read” queries.
int$batchSizeBatch size for database queries on the entity usage table, including INSERTs, SELECTs, and DELETEs. Defaults to 100.
string | null$tableNamedefaults to wbc_entity_usage
int$addUsagesBatchSizeBatch size for adding entity usage records. Can also be set after construction.
Exceptions
InvalidArgumentException

Member Function Documentation

◆ addUsages()

Wikibase\Client\Usage\Sql\EntityUsageTable::addUsages ( int $pageId,
array $usages )
Parameters
int$pageId
EntityUsage[]$usages
Exceptions
InvalidArgumentException
Returns
int The number of entries added

◆ convertRowsToUsages()

Wikibase\Client\Usage\Sql\EntityUsageTable::convertRowsToUsages ( Traversable $rows)
private
Parameters
Traversable$rows
Returns
EntityUsage[]

◆ foldRowsIntoPageEntityUsages()

Wikibase\Client\Usage\Sql\EntityUsageTable::foldRowsIntoPageEntityUsages ( Traversable $rows)
private
Parameters
Traversable$rows
Returns
PageEntityUsages[]

◆ getAffectedRowIds()

Wikibase\Client\Usage\Sql\EntityUsageTable::getAffectedRowIds ( int $pageId,
array $usages )
private
Parameters
int$pageId
EntityUsage[]$usages
Returns
int[] affected row ids

◆ getEntityIdStrings()

Wikibase\Client\Usage\Sql\EntityUsageTable::getEntityIdStrings ( array $entityIds)
private
Parameters
EntityId[]$entityIds
Returns
string[]

◆ getPagesUsing()

Wikibase\Client\Usage\Sql\EntityUsageTable::getPagesUsing ( array $entityIds,
array $aspects = [] )
See also
UsageLookup::getPagesUsing
Parameters
EntityId[]$entityIds
string[]$aspects
Returns
Traversable A traversable over PageEntityUsages grouped by page.

◆ getPrimaryKeys()

Wikibase\Client\Usage\Sql\EntityUsageTable::getPrimaryKeys ( array $where,
string $method )
private

Returns the primary keys for the given where clause.

Parameters
array$where
string$methodCalling method
Returns
int[]

◆ getUnusedEntities()

Wikibase\Client\Usage\Sql\EntityUsageTable::getUnusedEntities ( array $entityIds)
See also
UsageLookup::getUnusedEntities
Parameters
EntityId[]$entityIds
Returns
EntityId[]

◆ getUsedEntityIdStrings()

Wikibase\Client\Usage\Sql\EntityUsageTable::getUsedEntityIdStrings ( array $idStrings)
private

Returns those entity ids which are used from a given set of entity ids.

Parameters
string[]$idStrings
Returns
string[]

◆ getUsedEntityIdStringsMySql()

Wikibase\Client\Usage\Sql\EntityUsageTable::getUsedEntityIdStringsMySql ( array $subQueries,
IReadableDatabase $readConnection )
private
Parameters
SelectQueryBuilder[]$subQueries
IReadableDatabase$readConnectionmust have type MySQL
Returns
string[]

◆ getUsedEntityIdStringsQueries()

Wikibase\Client\Usage\Sql\EntityUsageTable::getUsedEntityIdStringsQueries ( array $idStrings)
private
Parameters
string[]$idStrings
Returns
SelectQueryBuilder[]

◆ getWriteConnection()

Wikibase\Client\Usage\Sql\EntityUsageTable::getWriteConnection ( )
private

◆ makeUsageRows()

Wikibase\Client\Usage\Sql\EntityUsageTable::makeUsageRows ( int $pageId,
array $usages )
private
Parameters
int$pageId
EntityUsage[]$usages
Exceptions
InvalidArgumentException
Returns
array[]

◆ pruneUsages()

Wikibase\Client\Usage\Sql\EntityUsageTable::pruneUsages ( int $pageId)

Removes all usage tracking for a given page.

Parameters
int$pageId
Exceptions
InvalidArgumentException
Returns
EntityUsage[]

◆ queryUsages()

Wikibase\Client\Usage\Sql\EntityUsageTable::queryUsages ( int $pageId)
Parameters
int$pageId
Exceptions
InvalidArgumentException
Returns
EntityUsage[] EntityUsage identity string => EntityUsage

◆ removeUsages()

Wikibase\Client\Usage\Sql\EntityUsageTable::removeUsages ( int $pageId,
array $usages )
Parameters
int$pageId
EntityUsage[]$usages
Exceptions
InvalidArgumentException

◆ setAddUsagesBatchSize()

Wikibase\Client\Usage\Sql\EntityUsageTable::setAddUsagesBatchSize ( int $addUsagesBatchSize)

Set the batch size for adding entity usage records.

This can also be set in the constructor.

Member Data Documentation

◆ $addUsagesBatchSize

int Wikibase\Client\Usage\Sql\EntityUsageTable::$addUsagesBatchSize
private

◆ $batchSize

int Wikibase\Client\Usage\Sql\EntityUsageTable::$batchSize
private

◆ $db

ClientDomainDb Wikibase\Client\Usage\Sql\EntityUsageTable::$db
private

◆ $idParser

EntityIdParser Wikibase\Client\Usage\Sql\EntityUsageTable::$idParser
private

◆ $logger

LoggerInterface Wikibase\Client\Usage\Sql\EntityUsageTable::$logger
private

◆ $tableName

string Wikibase\Client\Usage\Sql\EntityUsageTable::$tableName
private

◆ $writeConnection

IDatabase Wikibase\Client\Usage\Sql\EntityUsageTable::$writeConnection
private

◆ DEFAULT_TABLE_NAME

const Wikibase\Client\Usage\Sql\EntityUsageTable::DEFAULT_TABLE_NAME = 'wbc_entity_usage'

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