- function insertJobs( ResultWrapper $res ) {
- $numRows = $res->numRows();
- $numBatches = ceil( $numRows / $this->mRowsPerJob );
- $realBatchSize = $numRows / $numBatches;
- $start = false;
+ /**
+ * Update some of the backlinks, defined by a page ID range
+ */
+ protected function doPartialUpdate() {
+ $titleArray = $this->mCache->getLinks( $this->mTable, $this->mStart, $this->mEnd );
+ if ( $titleArray->count() <= $this->mRowsPerJob * 2 ) {
+ # This partition is small enough, do the update
+ $this->invalidateTitles( $titleArray );
+ } else {
+ # Partitioning was excessively inaccurate. Divide the job further.
+ # This can occur when a large number of links are added in a short
+ # period of time, say by updating a heavily-used template.
+ $this->insertJobsFromTitles( $titleArray );
+ }
+ }
+
+ /**
+ * Partition the current range given by $this->mStart and $this->mEnd,
+ * using a pre-calculated title array which gives the links in that range.
+ * Queue the resulting jobs.
+ */
+ protected function insertJobsFromTitles( $titleArray ) {
+ # We make subpartitions in the sense that the start of the first job
+ # will be the start of the parent partition, and the end of the last
+ # job will be the end of the parent partition.