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...

Public Member Functions

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

Public Attributes

const DEFAULT_TABLE_NAME = 'wbc_entity_usage'
 

Private Member Functions

 getAffectedRowIds ( $pageId, array $usages)
 
 makeUsageRows ( $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, $method)
 Returns the primary keys for the given where clause.
 
 getUsedEntityIdStringsMySql (array $subQueries)
 

Private Attributes

 $idParser
 
 $writeConnection
 
 $readConnection
 
 $loadBalancerFactory
 
 $batchSize
 
 $tableName
 
 $addUsagesBatchSize
 

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,
  $batchSize = 100,
  $tableName = null,
  $addUsagesBatchSize = 500 
)
Parameters
EntityIdParser$idParser
IDatabase$writeConnection
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 (   $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 (   $pageId,
array  $usages 
)
private
Parameters
int$pageId
EntityUsage[]$usages
Returns
int[] affected row ids
Exceptions
DBUnexpectedError
MWException

◆ 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,
  $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)
private
Parameters
string[]$subQueries
Returns
string[]

◆ getUsedEntityIdStringsQueries()

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

◆ makeUsageRows()

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

◆ pruneUsages()

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

Removes all usage tracking for a given page.

Parameters
int$pageId
Exceptions
InvalidArgumentException
Returns
EntityUsage[]

◆ queryUsages()

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

◆ removeUsages()

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

◆ setAddUsagesBatchSize()

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

Set the batch size for adding entity usage records.

This can also be set in the constructor.

Parameters
int$addUsagesBatchSize

Member Data Documentation

◆ $addUsagesBatchSize

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

◆ $batchSize

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

◆ $idParser

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

◆ $loadBalancerFactory

Wikibase\Client\Usage\Sql\EntityUsageTable::$loadBalancerFactory
private

◆ $readConnection

Wikibase\Client\Usage\Sql\EntityUsageTable::$readConnection
private

◆ $tableName

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

◆ $writeConnection

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: