r52159 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52158‎ | r52159 | r52160 >
Date:10:50, 19 June 2009
Author:daniel
Status:deferred
Tags:
Comment:
use database hints
Modified paths:
  • /trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/schema/WikiWordStoreSchema.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/test/java/de/brightbyte/wikiword/builder/ValidateImport.java (modified) (history)
  • /trunk/WikiWord/WikiWordIntegrator/.classpath (modified) (history)
  • /trunk/WikiWord/WikiWordIntegrator/src/test/java/de/brightbyte/wikiword/integrator/IntegratorAppTestBase.java (modified) (history)

Diff [purge]

Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/schema/WikiWordStoreSchema.java
@@ -13,10 +13,13 @@
1414
1515 import de.brightbyte.db.DatabaseAgendaPersistor;
1616 import de.brightbyte.db.DatabaseField;
 17+import de.brightbyte.db.DatabaseHints;
1718 import de.brightbyte.db.DatabaseSchema;
1819 import de.brightbyte.db.DatabaseTable;
 20+import de.brightbyte.db.DefaultSqlDialect;
1921 import de.brightbyte.db.EntityTable;
2022 import de.brightbyte.db.KeyType;
 23+import de.brightbyte.db.MySqlDialect;
2124 import de.brightbyte.db.ReferenceField;
2225 import de.brightbyte.util.PersistenceException;
2326 import de.brightbyte.wikiword.ConceptType;
@@ -78,13 +81,40 @@
7982
8083 private DatasetIdentifier dataset;
8184
 85+ public static DatabaseHints makeHints(TweakSet tweaks, boolean useFlushQueue) {
 86+ DatabaseHints hints = new DatabaseHints();
 87+
 88+ if (useFlushQueue) hints.setHint(HINT_JOB_QUEUE_CAPACITY, tweaks.getTweak("dbstore.backgroundFlushQueue", 4)); //XXX: doc tweak!
 89+
 90+ hints.setHint(MySqlDialect.HINT_EXPLAIN_SQL_THREASHOLD, tweaks.getTweak("dbstore.explainSQLThreashold", 0));
 91+ hints.setHint(DefaultSqlDialect.HINT_SLOW_SQL_THREASHOLD, tweaks.getTweak("dbstore.slowSQLThreashold", 0));
 92+ hints.setHint(DefaultSqlDialect.HINT_TRACE_SQL, tweaks.getTweak("dbstore.traceSQL", false));
 93+
 94+ String sqlMode = tweaks.getTweak("dbstore.sqlMode", null);
 95+ if (sqlMode!=null) hints.setHint(MySqlDialect.HINT_SQL_MODE, sqlMode);
 96+
 97+ hints.setHint(HINT_MAX_STATEMENT_SIZE, tweaks.getTweak("dbstore.maxStatementSize", -1));
 98+ hints.setHint(HINT_BUFFER_SCALE, tweaks.getTweak("dbstore.insertionBufferFactor", 16));
 99+
 100+ int groupLen = tweaks.getTweak("dbstore.groupConcatMaxLen", -1);
 101+ if (groupLen>0) hints.setHint(MySqlDialect.HINT_GROUP_CONCAT_MAX_LEN, groupLen);
 102+
 103+ String dbengine = tweaks.getTweak("dbstore.engine", "MyISAM");
 104+ String defaultTableAttributes = "ENGINE="+dbengine+" CHARSET utf8 COLLATE utf8_bin";
 105+ defaultTableAttributes = tweaks.getTweak("dbstore.table.attributes", defaultTableAttributes);
 106+
 107+ hints.setHint(HINT_DEFAULT_TABLE_ATTRIBUTES, defaultTableAttributes);
 108+
 109+ return hints;
 110+ }
 111+
82112 public WikiWordStoreSchema(DatasetIdentifier dataset, Connection connection, TweakSet tweaks, boolean useFlushQueue) throws SQLException {
83 - super(dataset.getDbPrefix(), connection, useFlushQueue ? tweaks.getTweak("dbstore.backgroundFlushQueue", 4) : 0 ); //XXX: doc tweak!
 113+ super(dataset.getDbPrefix(), connection, makeHints(tweaks, useFlushQueue) );
84114 init(dataset, tweaks);
85115 }
86116
87117 public WikiWordStoreSchema(DatasetIdentifier dataset, DataSource connectionInfo, TweakSet tweaks, boolean useFlushQueue) throws SQLException {
88 - super(dataset.getDbPrefix(), connectionInfo, useFlushQueue ? tweaks.getTweak("dbstore.backgroundFlushQueue", 4) : 0); //XXX: doc tweak!
 118+ super(dataset.getDbPrefix(), connectionInfo, makeHints(tweaks, useFlushQueue) );
89119 init(dataset, tweaks);
90120 }
91121
@@ -92,22 +122,6 @@
93123 this.setLogLevel(tweaks.getTweak("dbstore.logLevel", LOG_INFO));
94124
95125 this.dataset = dataset;
96 - this.setExplainSQLThreashold(tweaks.getTweak("dbstore.explainSQLThreashold", 0));
97 - this.setSlowSQLThreashold(tweaks.getTweak("dbstore.slowSQLThreashold", 0));
98 - this.setTraceSQL(tweaks.getTweak("dbstore.traceSQL", false));
99 -
100 - this.setMaxStatementSize(tweaks.getTweak("dbstore.maxStatementSize", -1));
101 -
102 - this.setBufferScale(tweaks.getTweak("dbstore.insertionBufferFactor", 16));
103 -
104 - String sqlMode = tweaks.getTweak("dbstore.sqlMode", null);
105 - if (sqlMode!=null) this.setSqlMode(sqlMode);
106 -
107 - String dbengine = tweaks.getTweak("dbstore.engine", "MyISAM");
108 - String defaultTableAttributes = "ENGINE="+dbengine+" CHARSET utf8 COLLATE utf8_bin";
109 - defaultTableAttributes = tweaks.getTweak("dbstore.table.attributes", defaultTableAttributes);
110 -
111 - this.setDefaultTableAttributes(defaultTableAttributes);
112126 this.useBinaryText = tweaks.getTweak("dbstore.useBinaryText", true);
113127
114128 logTable = DatabaseAgendaPersistor.makeTableSpec(this, "log");
Index: trunk/WikiWord/WikiWordBuilder/src/test/java/de/brightbyte/wikiword/builder/ValidateImport.java
@@ -252,7 +252,7 @@
253253
254254 String prefix = tweaks.getTweak("prefix", "TEST");
255255 if (prefix!=null && prefix.length()>0) prefix += "_";
256 - database = new DatabaseSchema(prefix, dataSource, 0);
 256+ database = new DatabaseSchema(prefix, dataSource, null);
257257
258258 //--------------------
259259 String dir = args.getStringOption("dir", null);
Index: trunk/WikiWord/WikiWordIntegrator/.classpath
@@ -15,9 +15,9 @@
1616 <attribute name="javadoc_location" value="http://www.beanshell.org/javadoc/"/>
1717 </attributes>
1818 </classpathentry>
19 - <classpathentry kind="var" path="M2_REPO/org/dbunit/dbunit/2.4.4/dbunit-2.4.4.jar">
 19+ <classpathentry kind="var" path="M2_REPO/org/dbunit/dbunit/2.4.4/dbunit-2.4.4.jar" sourcepath="/M2_REPO/org/dbunit/dbunit/2.4.4/dbunit-2.4.4-sources.jar">
2020 <attributes>
21 - <attribute name="javadoc_location" value="http://www.dbunit.org/apidocs/"/>
 21+ <attribute name="javadoc_location" value="jar:file:/home/daniel/.m2/repository/org/dbunit/dbunit/2.4.4/dbunit-2.4.5-javadoc.jar!/"/>
2222 </attributes>
2323 </classpathentry>
2424 <classpathentry kind="output" path="bin"/>
Index: trunk/WikiWord/WikiWordIntegrator/src/test/java/de/brightbyte/wikiword/integrator/IntegratorAppTestBase.java
@@ -3,6 +3,8 @@
44 import java.io.IOException;
55 import java.net.URL;
66
 7+import org.dbunit.operation.DatabaseOperation;
 8+
79 import de.brightbyte.db.testing.DatabaseTestBase;
810 import de.brightbyte.wikiword.DatasetIdentifier;
911 import de.brightbyte.wikiword.TweakSet;
@@ -12,6 +14,11 @@
1315 public IntegratorAppTestBase(String name) {
1416 super(name);
1517 }
 18+
 19+ protected DatabaseOperation getSetUpOperation() throws Exception
 20+ {
 21+ return DatabaseOperation.NONE;
 22+ }
1623
1724 public TweakSet loadTweakSet() throws IOException {
1825 URL url = requireAuxilliaryFileURL("test-tweaks.properties");

Status & tagging log