r71341 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71340‎ | r71341 | r71342 >
Date:10:02, 20 August 2010
Author:daniel
Status:deferred
Tags:
Comment:
temp tables are now returned as DatabaseTable instances
Modified paths:
  • /trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/store/DatabaseFeatureStore.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseProximityStoreBuilder.java (modified) (history)

Diff [purge]

Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/store/DatabaseFeatureStore.java
@@ -12,6 +12,7 @@
1313 import de.brightbyte.data.MapLabeledVector;
1414 import de.brightbyte.data.cursor.DataSet;
1515 import de.brightbyte.db.DatabaseDataSet;
 16+import de.brightbyte.db.DatabaseTable;
1617 import de.brightbyte.db.DatabaseUtil;
1718 import de.brightbyte.db.EntityTable;
1819 import de.brightbyte.db.QueryDataSet;
@@ -236,8 +237,8 @@
237238 @Override
238239 public Cursor<ConceptFeatures<T, Integer>> cursor() throws PersistenceException {
239240 try {
240 - String n = database.createTemporaryTable("id integer not null, name varchar(255) default null, primary key (id)");
241 - String sql = "INSERT IGNORE INTO "+n+" (id) ";
 241+ DatabaseTable tmp = database.createTemporaryTable("id integer not null, name varchar(255) default null, primary key (id)");
 242+ String sql = "INSERT IGNORE INTO "+tmp.getSQLName()+" (id) ";
242243 sql += " SELECT N.feature as id ";
243244 sql += " FROM "+featureTable.getSQLName()+" AS F ";
244245 sql += " JOIN "+featureTable.getSQLName()+" AS N ON F.feature = N.concept ";
@@ -245,18 +246,18 @@
246247
247248 database.executeUpdate("getNeighbourhoodFeatures#neighbours", sql);
248249
249 - sql = "UPDATE "+n+" as N ";
 250+ sql = "UPDATE "+tmp.getSQLName()+" as N ";
250251 sql+= " JOIN "+conceptTable.getSQLName()+" AS C ON C.id = N.id ";
251252 sql+= " SET N.name = C.name ";
252253
253254 database.executeUpdate("getNeighbourhoodFeatures#names", sql);
254255
255256 sql = "SELECT N.id as concept, N.name as name, X.feature as feature, X.normal_weight as value ";
256 - sql+= " FROM "+n+" AS N ";
 257+ sql+= " FROM "+tmp.getSQLName()+" AS N ";
257258 sql+= " JOIN "+featureTable.getSQLName()+" as X ON X.concept = N.id ";
258259
259260 ResultSet rs = database.executeQuery("getNeighbourhoodFeatures#features", sql);
260 - return new TemporaryTableDataSet.Cursor<ConceptFeatures<T, Integer>>(rs, factory, database, new String[] { n }, database.getLogOutput() );
 261+ return new TemporaryTableDataSet.Cursor<ConceptFeatures<T, Integer>>(rs, factory, database, new String[] { tmp.getSQLName() }, database.getLogOutput() );
261262 } catch (SQLException e) {
262263 throw new PersistenceException(e);
263264 }
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseProximityStoreBuilder.java
@@ -266,14 +266,14 @@
267267 }
268268
269269 if (beginTask("buildProximityAround", "buildFeatures(join)")) {
270 - String t = database.createTemporaryTable("id INT, PRIMARY KEY (id)");
 270+ DatabaseTable tmp = database.createTemporaryTable("id INT, PRIMARY KEY (id)");
271271
272 - String sql = "INSERT INTO "+t+" SELECT id FROM "+featureTable.getSQLName()+" WHERE concept = "+concept;
 272+ String sql = "INSERT INTO "+tmp.getSQLName()+" SELECT id FROM "+featureTable.getSQLName()+" WHERE concept = "+concept;
273273 database.executeUpdate("buildProximityAround::getFirstLevelConceptIds", sql);
274274
275 - buildFeatures(new ConceptSetRestriction("JOIN "+t+" ON {concept} = "+t+".id "+concept, false, false));
 275+ buildFeatures(new ConceptSetRestriction("JOIN "+tmp.getSQLName()+" ON {concept} = "+tmp.getSQLName()+".id "+concept, false, false));
276276
277 - database.executeUpdate("buildProximityAround::dropFirstLevelConceptIds", "DROP TEMPORARY TABLE "+t);
 277+ database.executeUpdate("buildProximityAround::dropFirstLevelConceptIds", "DROP TEMPORARY TABLE "+tmp.getSQLName());
278278 endTask("buildProximityAround", "buildFeatures(join)", "ok");
279279 }
280280

Status & tagging log