r50285 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50284‎ | r50285 | r50286 >
Date:21:15, 6 May 2009
Author:daniel
Status:deferred
Tags:
Comment:
standalone property extraction
Modified paths:
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/AbstractImporter.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ConceptImporter.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ImportApp.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ImportConcepts.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ImportProperties.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/PropertyImporter.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseLocalConceptStoreBuilder.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabasePropertyStoreBuilder.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseWikiWordConceptStoreBuilder.java (modified) (history)

Diff [purge]

Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ImportProperties.java
@@ -16,7 +16,9 @@
1717 private PropertyStoreBuilder propertyStore;
1818
1919 public ImportProperties() {
20 - super("ExtractProperties");
 20+ super("ImportProperties");
 21+
 22+ baseTasks = new String[] {"ImportProperties", "ImportConcepts", "BuildStatistics", "BuildConceptInfo", };
2123 }
2224
2325 @Override
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ImportConcepts.java
@@ -20,7 +20,7 @@
2121 private TextStoreBuilder textStore;
2222
2323 public ImportConcepts() {
24 - super("ImportDump");
 24+ super("ImportConcepts");
2525 }
2626
2727 @Override
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ImportApp.java
@@ -25,7 +25,8 @@
2626 protected static enum Operation {
2727 FRESH,
2828 CONTINUE,
29 - APPEND
 29+ APPEND,
 30+ ATTACH
3031 }
3132
3233 private boolean useAgenda;
@@ -33,7 +34,8 @@
3435 protected Agenda agenda;
3536
3637 protected Operation operation = null;
37 - private Monitor agendaMonitor;
 38+ private Monitor agendaMonitor;
 39+ protected String[] baseTasks = new String[] {};
3840
3941 public ImportApp(String agendaTask, boolean allowGlobal, boolean allowLocal) { //TODO: agenda-params!
4042 super(allowGlobal, allowLocal);
@@ -73,7 +75,7 @@
7476 this.agendaMonitor = monitor;
7577 }
7678
77 - protected void initAgenda(Agenda agenda) throws PersistenceException {
 79+ protected void initAgenda(Agenda agenda, String... canAttachTo) throws PersistenceException {
7880 agenda.setLogger(
7981 logLevel<=LOG_INFO ? out : null,
8082 logLevel<=LOG_FINE ? out : null
@@ -86,12 +88,16 @@
8789 if (args.isSet("fresh")) operation = Operation.FRESH;
8890 else if (args.isSet("continue")) operation = Operation.CONTINUE;
8991 else if (args.isSet("append")) operation = Operation.APPEND;
 92+ else if (args.isSet("attach")) operation = Operation.ATTACH;
9093
9194 //String phase = fresh ? null : args.getStringOption("phase", null);
9295 //if (phase != null) ctinue = true;
9396 Prompt p = new Prompt();
9497
95 - if (agenda.wasFinished(agendaTask)) {
 98+ if (operation==Operation.ATTACH && agenda.canRelyUpon(canAttachTo)) {
 99+ p.println("### building upon previous task ("+agenda.getLastRootTask()+")");
 100+ }
 101+ else if (agenda.wasFinished(agendaTask)) {
96102 p.println("### the last run FINISHED.");
97103
98104 if (operation==Operation.FRESH) {
@@ -100,12 +106,15 @@
101107 else if (operation==Operation.APPEND) {
102108 p.println("### performing APPENDING import!");
103109 }
 110+ else if (operation==Operation.ATTACH) {
 111+ p.println("### performing ATTACHING import!");
 112+ }
104113 else if (operation==Operation.CONTINUE) {
105114 p.println("### noting to CONTINUE.");
106115 System.exit(0);
107116 }
108117 else {
109 - String s = p.prompt("### type \"fresh\" to start a fresh run, or \"append\" to append.", "");
 118+ String s = p.prompt("### type \"fresh\" to start a fresh run", "");
110119
111120 if (s==null) {
112121 p.println("### UNEXPECTED EOF.");
@@ -118,9 +127,9 @@
119128 if (s.equals("fresh")) {
120129 operation = Operation.FRESH;
121130 }
122 - else if (s.equals("append")) {
 131+ /*else if (s.equals("append")) {
123132 operation = Operation.APPEND;
124 - }
 133+ }*/
125134 else {
126135 p.println("### aborted.");
127136 System.exit(0);
@@ -139,6 +148,8 @@
140149 else {
141150 if (operation==Operation.APPEND) {
142151 p.println("### can not append to incomplete database!");
 152+ } else if (operation==Operation.ATTACH) {
 153+ p.println("### can not attach to incomplete database!");
143154 }
144155
145156 String s = p.prompt("### type \"fresh\" to start a fresh run, or \"continue\" to continue the previous run\".", "");
@@ -175,6 +186,9 @@
176187 if (operation==Operation.APPEND) {
177188 p.println("### can not append to incomplete database!");
178189 operation = null;
 190+ } else if (operation==Operation.ATTACH) {
 191+ p.println("### can not attach to incomplete database!");
 192+ operation = null;
179193 }
180194
181195 if (operation == null) {
@@ -268,7 +282,7 @@
269283 if (!noimport) {
270284 if (useAgenda) {
271285 agenda = conceptStore.getAgenda();
272 - initAgenda(agenda);
 286+ initAgenda(agenda, baseTasks = new String[] {});
273287 }
274288
275289 if (operation == Operation.FRESH) {
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/ConceptImporter.java
@@ -20,6 +20,7 @@
2121 import de.brightbyte.wikiword.analyzer.WikiPage;
2222 import de.brightbyte.wikiword.model.LocalConceptReference;
2323 import de.brightbyte.wikiword.schema.AliasScope;
 24+import de.brightbyte.wikiword.store.builder.IncrementalStoreBuilder;
2425 import de.brightbyte.wikiword.store.builder.LocalConceptStoreBuilder;
2526 import de.brightbyte.wikiword.store.builder.PropertyStoreBuilder;
2627 import de.brightbyte.wikiword.store.builder.TextStoreBuilder;
@@ -120,6 +121,11 @@
121122 store.flush();
122123 }
123124
 125+ protected void deleteDataAfter(int delAfter) throws PersistenceException {
 126+ ((IncrementalStoreBuilder)store).deleteDataAfter(delAfter, false); //FIXME: make sure we are not off by one!
 127+ if (propertyStore!=null && storeProperties) ((IncrementalStoreBuilder)propertyStore).deleteDataAfter(delAfter, false); //FIXME: make sure we are not off by one!
 128+ }
 129+
124130 protected void buildTermsForMissingConcepts() throws PersistenceException {
125131 if (!analyzer.isInitialized()) { //XXX: ugly hack!
126132 analyzer.initialize(Namespace.canonicalNamespaces, true);
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/AbstractImporter.java
@@ -125,7 +125,8 @@
126126
127127 int delAfter = (Integer)rec.parameters.get("lastRcId_");
128128 out.info("=== DIRTY BLOCK FOR SAFEPOINT#"+safepointNumber+", Deleting entries starting after id: #"+delAfter+" ===");
129 - ((IncrementalStoreBuilder)store).deleteDataAfter(delAfter, false); //FIXME: make sure we are not off by one!
 129+
 130+ deleteDataAfter(delAfter);
130131 }
131132
132133 out.info("=== BEGINNING BLOCK FOR SAFEPOINT#"+safepointNumber+": "+getAgenda().getCurrentRecord().parameters+" ===");
@@ -135,6 +136,10 @@
136137 return doit;
137138 }
138139
 140+ protected void deleteDataAfter(int delAfter) throws PersistenceException {
 141+ ((IncrementalStoreBuilder)store).deleteDataAfter(delAfter, false); //FIXME: make sure we are not off by one!
 142+ }
 143+
139144 protected void concludeStep() throws PersistenceException{
140145 safepointTicks++;
141146 if (safepointTicks>=safepointInterval) {
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/PropertyImporter.java
@@ -13,6 +13,7 @@
1414 import de.brightbyte.wikiword.analyzer.WikiTextAnalyzer;
1515 import de.brightbyte.wikiword.analyzer.WikiPage;
1616 import de.brightbyte.wikiword.store.builder.ConceptBasedStoreBuilder;
 17+import de.brightbyte.wikiword.store.builder.IncrementalStoreBuilder;
1718 import de.brightbyte.wikiword.store.builder.LocalConceptStoreBuilder;
1819
1920 public class PropertyImporter extends ConceptImporter {
@@ -83,6 +84,11 @@
8485 return cid;
8586 }
8687
 88+ protected void deleteDataAfter(int delAfter) throws PersistenceException {
 89+ if (buildConcepts) ((IncrementalStoreBuilder)store).deleteDataAfter(delAfter, false);
 90+ ((IncrementalStoreBuilder)propertyStore).deleteDataAfter(delAfter, false);
 91+ }
 92+
8793 @Override
8894 protected boolean isRelevant(WikiPage analyzerPage) {
8995 ResourceType t = analyzerPage.getResourceType();
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabasePropertyStoreBuilder.java
@@ -5,6 +5,7 @@
66
77 import de.brightbyte.application.Agenda;
88 import de.brightbyte.data.PersistentIdManager;
 9+import de.brightbyte.db.DatabaseTable;
910 import de.brightbyte.db.Inserter;
1011 import de.brightbyte.db.RelationTable;
1112 import de.brightbyte.util.PersistenceException;
@@ -27,6 +28,13 @@
2829 null, tweaks, null);
2930 }
3031
 32+ protected DatabaseTable getTable(String name) {
 33+ if (database.hasTable(name))
 34+ return database.getTable(name);
 35+ else
 36+ return conceptStoreSchema.getTable(name);
 37+ }
 38+
3139 public DatabasePropertyStoreBuilder(DatabaseLocalConceptStoreBuilder conceptStore, TweakSet tweaks) throws SQLException, PersistenceException {
3240 this(new LocalConceptStoreSchema(conceptStore.getCorpus(),
3341 conceptStore.getDatabaseAccess().getConnection(),
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseLocalConceptStoreBuilder.java
@@ -216,9 +216,14 @@
217217 public void flush() throws PersistenceException{
218218 if (idManager!=null) idManager.flush();
219219 super.flush();
 220+
 221+ if (propertyStore!=null)
 222+ propertyStore.flush();
 223+
 224+ if (textStore!=null)
 225+ textStore.flush();
220226 }
221227
222 -
223228 protected void deleteDataFrom(int rcId, String op) throws PersistenceException {
224229 deleteDataFrom(rcId, op, definitionTable, "resource");
225230
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseWikiWordConceptStoreBuilder.java
@@ -408,6 +408,18 @@
409409 return executeChunkedUpdate("finishGlobalConcepts", "similarities:bilink", sql, suffix, linkTable, "A.anchor", 1);
410410 }
411411
 412+
 413+ @Override
 414+ public void flush() throws PersistenceException{
 415+ super.flush();
 416+
 417+ if (statsStore!=null)
 418+ statsStore.flush();
 419+
 420+ if (infoStore!=null)
 421+ infoStore.flush();
 422+ }
 423+
412424 //----------------------------------------------------------------------------------
413425
414426 protected abstract DatabaseStatisticsStoreBuilder newStatisticsStoreBuilder() throws SQLException, PersistenceException;

Status & tagging log