r52493 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52492‎ | r52493 | r52494 >
Date:15:09, 27 June 2009
Author:daniel
Status:deferred
Tags:
Comment:
getConceptIdCursor: use big query, use asString
Modified paths:
  • /trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/store/DatabaseWikiWordStore.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseLocalConceptStoreBuilder.java (modified) (history)

Diff [purge]

Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/store/DatabaseWikiWordStore.java
@@ -176,6 +176,14 @@
177177 throw new PersistenceException(e);
178178 }
179179 }
 180+
 181+ protected ResultSet executeBigQuery(String name, String sql) throws PersistenceException {
 182+ try {
 183+ return database.executeBigQuery(name, sql);
 184+ } catch (SQLException e) {
 185+ throw new PersistenceException(e);
 186+ }
 187+ }
180188
181189 /*
182190 protected ResultSet executeBigQuery(String name, String sql) throws PersistenceException {
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseLocalConceptStoreBuilder.java
@@ -22,8 +22,10 @@
2323 import de.brightbyte.db.DatabaseDataSet;
2424 import de.brightbyte.db.DatabaseField;
2525 import de.brightbyte.db.DatabaseTable;
 26+import de.brightbyte.db.DatabaseUtil;
2627 import de.brightbyte.db.EntityTable;
2728 import de.brightbyte.db.Inserter;
 29+import de.brightbyte.db.MySqlDialect;
2830 import de.brightbyte.db.ReferenceField;
2931 import de.brightbyte.db.RelationTable;
3032 import de.brightbyte.util.PersistenceException;
@@ -192,12 +194,17 @@
193195 }
194196
195197 protected DataCursor<Pair<String, Integer>> getConceptIdCursor() throws PersistenceException {
 198+ final boolean binaryText = database.getHints().getHint(MySqlDialect.HINT_USE_BINARY_TEXT, false);
 199+
196200 String sql = "SELECT name, id from " + conceptTable.getSQLName();
197 - ResultSet rs = executeQuery("getConceptIdCursor", sql);
 201+ ResultSet rs = executeBigQuery("getConceptIdCursor", sql);
198202
199203 DatabaseDataSet.Factory<Pair<String, Integer>> f = new DatabaseDataSet.Factory<Pair<String, Integer>>() {
200204 public Pair<String, Integer> newInstance(ResultSet row) throws Exception {
201 - return new Pair<String, Integer>(row.getString(1), row.getInt(2));
 205+ Object n = binaryText ? row.getBytes(1) : row.getString(1);
 206+ String name = DatabaseUtil.asString(n, "UTF-8");
 207+ int id = DatabaseUtil.asInt(row.getObject(2));
 208+ return new Pair<String, Integer>(name, id);
202209 }
203210 };
204211

Status & tagging log