r25989 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25988‎ | r25989 | r25990 >
Date:14:09, 21 September 2007
Author:proes
Status:old
Tags:
Comment:
Replaced Create bootstrapped_defined_meanings indices.sql by PHP code.
Modified paths:
  • /trunk/extensions/Wikidata/Database+scripts/Convenience/Create+bootstrapped_defined_meanings+indices.sql (deleted) (history)
  • /trunk/extensions/Wikidata/Database+scripts/Convenience/Recreate+indexes+for+all+tables+for+website.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/WikiDataTables.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/Database scripts/Convenience/Create bootstrapped_defined_meanings indices.sql
@@ -1,3 +0,0 @@
2 -ALTER TABLE `bootstrapped_defined_meanings`
3 - ADD INDEX `unversioned_meaning` (`defined_meaning_id`),
4 - ADD INDEX `unversioned_name` (`name` (255), `defined_meaning_id`);
Index: trunk/extensions/Wikidata/Database scripts/Convenience/Recreate indexes for all tables for website.php
@@ -48,11 +48,11 @@
4949 echo "Dropping indices from table " . $dc . "_" . $tableName . ".\n";
5050 dropAllIndicesFromTable($dc . "_" . $tableName);
5151 echo "Creating new indices for table " . $dc . "_" . $tableName . ".\n";
52 - createIndexesForTable($dc,$tableName);
 52+ createIndexesForTable($dc, $tableName);
5353 }
5454
55 -function addIndexesForTable($table) {
56 - $tableIndexes = $table->getIndexes("WebSite");
 55+function addIndexesForTable($table, $purpose) {
 56+ $tableIndexes = $table->getIndexes($purpose);
5757 $indexes = array();
5858
5959 foreach ($tableIndexes as $tableIndex) {
@@ -74,12 +74,12 @@
7575 addIndexes($table->getIdentifier(), $indexes);
7676 }
7777
78 -function recreateIndexesForTableNew(Table $table) {
 78+function recreateIndexesForTableNew(Table $table, $purpose) {
7979 echo "Dropping indices from table " . $table->getIdentifier() . ".\n";
8080 dropAllIndicesFromTable($table->getIdentifier());
8181
8282 echo "Creating new indices for table " . $table->getIdentifier() . ".\n";
83 - addIndexesForTable($table);
 83+ addIndexesForTable($table, $purpose);
8484 }
8585
8686 function recreateIndexesForTables($dc, $tableNames) {
@@ -95,7 +95,6 @@
9696 $dc = "uw";
9797
9898 $tables = array(
99 - "bootstrapped_defined_meanings",
10099 "transactions",
101100 "translated_content",
102101 "alt_meaningtexts",
@@ -113,11 +112,13 @@
114113 "url_attribute_values"
115114 );
116115
 116+$purpose = "WebSite";
117117 $prefixes = retrieve_datasets();
118118
119119 foreach($prefixes as $prefix) {
120120 $dataSet = new WikiDataSet($prefix);
121 - recreateIndexesForTableNew($dataSet->expression);
 121+ recreateIndexesForTableNew($dataSet->bootstrappedDefinedMeanings, $purpose);
 122+ recreateIndexesForTableNew($dataSet->expression, $purpose);
122123
123124 recreateIndexesForTables($prefix, $tables);
124125 }
Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataTables.php
@@ -105,8 +105,8 @@
106106 return $this->identifier;
107107 }
108108
109 - protected function createColumn($identifier) {
110 - $result = new TableColumn($this, $identifier);
 109+ protected function createColumn($identifier, $length = null) {
 110+ $result = new TableColumn($this, $identifier, $length);
111111 $this->columns[] = $result;
112112
113113 return $result;
@@ -194,10 +194,14 @@
195195 public function __construct($identifier) {
196196 parent::__construct($identifier, false);
197197
198 - $this->name = $this->createColumn("name");
 198+ $this->name = $this->createColumn("name", 255);
199199 $this->definedMeaningId = $this->createColumn("defined_meaning_id");
200200
201 - $this->setKeyColumns(array($this->name));
 201+ $this->setKeyColumns(array($this->name));
 202+ $this->setWebSiteIndexes(array(
 203+ new TableIndex("unversioned_meaning", array($this->definedMeaningId)),
 204+ new TableIndex("unversioned_name", array($this->name, $this->definedMeaningId))
 205+ ));
202206 }
203207 }
204208
@@ -262,7 +266,7 @@
263267 parent::__construct($name);
264268
265269 $this->expressionId = $this->createColumn("expression_id");
266 - $this->spelling = $this->createColumn("spelling");
 270+ $this->spelling = $this->createColumn("spelling", 255);
267271 $this->languageId = $this->createColumn("language_id");
268272
269273 $this->setKeyColumns(array($this->expressionId));
@@ -275,7 +279,7 @@
276280 array($this->languageId, $this->expressionId)
277281 ),
278282 $this->createVersionedIndexes("spelling", true, true, false,
279 - array($this->spelling->subPart(255),$this->languageId, $this->expressionId)
 283+ array($this->spelling, $this->languageId, $this->expressionId)
280284 )
281285 ));
282286 }

Status & tagging log