Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataTables.php |
— | — | @@ -170,6 +170,21 @@ |
171 | 171 | $this->addTransactionId = $this->createColumn("add_transaction_id"); |
172 | 172 | $this->removeTransactionId = $this->createColumn("remove_transaction_id"); |
173 | 173 | } |
| 174 | + |
| 175 | + protected function createVersionedIndexes($name, $versionedEnd, $versionedStart, $unversioned, array $columns) { |
| 176 | + $result = array(); |
| 177 | + |
| 178 | + if ($versionedEnd) |
| 179 | + $result[] = new TableIndex("versioned_end_" . $name, array_merge(array($this->removeTransactionId), $columns)); |
| 180 | + |
| 181 | + if ($versionedStart) |
| 182 | + $result[] = new TableIndex("versioned_start_" . $name, array_merge(array($this->addTransactionId), $columns)); |
| 183 | + |
| 184 | + if ($unversioned) |
| 185 | + $result[] = new TableIndex("unversioned_" . $name, $columns); |
| 186 | + |
| 187 | + return $result; |
| 188 | + } |
174 | 189 | } |
175 | 190 | |
176 | 191 | class BootstrappedDefinedMeaningsTable extends Table { |
— | — | @@ -252,44 +267,17 @@ |
253 | 268 | |
254 | 269 | $this->setKeyColumns(array($this->expressionId)); |
255 | 270 | |
256 | | - $this->setWebSiteIndexes(array( |
257 | | - new TableIndex("versioned_end_expression", array( |
258 | | - $this->removeTransactionId, |
259 | | - $this->expressionId, |
260 | | - $this->languageId |
261 | | - )), |
262 | | - new TableIndex("versioned_end_language", array( |
263 | | - $this->removeTransactionId, |
264 | | - $this->languageId, |
265 | | - $this->expressionId |
266 | | - )), |
267 | | - new TableIndex("versioned_end_spelling", array( |
268 | | - $this->removeTransactionId, |
269 | | - $this->spelling->subPart(255), |
270 | | - $this->expressionId, |
271 | | - $this->languageId |
272 | | - )), |
273 | | - new TableIndex("versioned_start_expression", array( |
274 | | - $this->addTransactionId, |
275 | | - $this->expressionId, |
276 | | - $this->languageId |
277 | | - )), |
278 | | - new TableIndex("versioned_start_language", array( |
279 | | - $this->addTransactionId, |
280 | | - $this->languageId, |
281 | | - $this->expressionId |
282 | | - )), |
283 | | - new TableIndex("versioned_start_spelling", array( |
284 | | - $this->addTransactionId, |
285 | | - $this->spelling->subPart(255), |
286 | | - $this->expressionId, |
287 | | - $this->languageId |
288 | | - )), |
289 | | - new TableIndex("expressions_unique_idx", array( |
290 | | - $this->expressionId, |
291 | | - $this->languageId |
292 | | - )) |
293 | | - )); |
| 271 | + $this->setWebSiteIndexes(array_merge( |
| 272 | + $this->createVersionedIndexes("expression", true, true, true, |
| 273 | + array($this->expressionId, $this->languageId) |
| 274 | + ), |
| 275 | + $this->createVersionedIndexes("language", true, true, false, |
| 276 | + array($this->languageId, $this->expressionId) |
| 277 | + ), |
| 278 | + $this->createVersionedIndexes("spelling", true, true, false, |
| 279 | + array($this->spelling->subPart(255),$this->languageId, $this->expressionId) |
| 280 | + ) |
| 281 | + )); |
294 | 282 | } |
295 | 283 | } |
296 | 284 | |