r68164 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68163‎ | r68164 | r68165 >
Date:10:54, 17 June 2010
Author:daniel
Status:deferred
Tags:
Comment:
import about-table into global thesaurus
Modified paths:
  • /trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/schema/GlobalConceptStoreSchema.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/BuildThesaurus.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseGlobalConceptStoreBuilder.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/GlobalConceptStoreBuilder.java (modified) (history)

Diff [purge]

Index: trunk/WikiWord/WikiWord/src/main/java/de/brightbyte/wikiword/schema/GlobalConceptStoreSchema.java
@@ -25,6 +25,7 @@
2626 protected RelationTable mergeTable;
2727 protected RelationTable langprepTable;
2828 protected RelationTable meaningTable;
 29+ protected RelationTable aboutTable;
2930
3031 private ConceptTypeSet conceptTypes;
3132 protected TweakSet tweaks;
@@ -109,9 +110,18 @@
110111 meaningTable.addKey( new DatabaseKey(this, KeyType.INDEX, "concept_lang", new String[] {"concept", "lang"}) );
111112 addTable(meaningTable);
112113
 114+ aboutTable = new RelationTable(this, "about", getDefaultTableAttributes());
 115+ //aliasTable.addField( new DatabaseField(this, "id", "INT", "AUTO_INCREMENT", false, KeyType.PRIMARY) );
 116+ aboutTable.addField( new DatabaseField(this, "lang", getTextType(10), null, true, null ) );
 117+ aboutTable.addField( new ReferenceField(this, "local_resource", "INT", null, true, null, "resource", "id", null ) );
 118+ aboutTable.addField( new ReferenceField(this, "local_resource_name", getTextType(255), null, true, null, "resource", "name", null ) );
 119+ aboutTable.addField( new ReferenceField(this, "type", "INT", null, true, KeyType.INDEX, "concept", "id", null ) );
 120+ aboutTable.addField( new ReferenceField(this, "concept", "INT", null, true, null, "concept", "id", null ) );
 121+ aboutTable.addKey( new DatabaseKey(this, KeyType.INDEX, "by_concept", new String[] {"concept", "lang"}) );
 122+ aboutTable.addKey( new DatabaseKey(this, KeyType.INDEX, "by_resource_name", new String[] {"lang", "local_resource_name"}) );
 123+ aboutTable.addKey( new DatabaseKey(this, KeyType.INDEX, "by_resource_id", new String[] {"lang", "local_resource"}) );
 124+ addTable(aboutTable);
113125
114 - //TODO: reference table (aka link)
115 -
116126 //getLanguages(); //initialize knownlanguages, corpuses and content types#
117127 }
118128
@@ -125,7 +135,8 @@
126136 checkIdSanity(originTable, "local_concept");
127137 checkReferentialIntegrity(originTable, "global_concept", false);
128138 checkReferentialIntegrity(meaningTable, "concept", false);
129 -
 139+ checkReferentialIntegrity(aboutTable, "about", false);
 140+
130141 checkReferentialIntegrity(relationTable, "concept1", false);
131142 checkReferentialIntegrity(relationTable, "concept2", false);
132143
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/BuildThesaurus.java
@@ -93,9 +93,9 @@
9494 }
9595
9696 section("-- buildMeaningIndex --------------------------------------------------");
97 - if (agenda.beginTask("BuildThesaurus.run", "buildMeaningIndex")) {
98 - this.conceptStore.buildMeaningIndex();
99 - agenda.endTask("BuildThesaurus.run", "buildMeaningIndex");
 97+ if (agenda.beginTask("BuildThesaurus.run", "buildGlobalIndexes")) {
 98+ this.conceptStore.buildGlobalIndexes();
 99+ agenda.endTask("BuildThesaurus.run", "buildGlobalIndexes");
100100 }
101101
102102 /*
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/GlobalConceptStoreBuilder.java
@@ -23,6 +23,6 @@
2424
2525 public void setLanguages(String[] languages) throws PersistenceException;
2626
27 - public void buildMeaningIndex() throws PersistenceException;
 27+ public void buildGlobalIndexes() throws PersistenceException;
2828
2929 }
\ No newline at end of file
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseGlobalConceptStoreBuilder.java
@@ -54,6 +54,7 @@
5555
5656 protected RelationTable originTable;
5757 protected RelationTable meaningTable;
 58+ protected RelationTable aboutTable;
5859
5960 protected RelationTable mergeTable;
6061 //protected RelationTable langprepTable;
@@ -111,6 +112,9 @@
112113 Inserter meaningInserter = configureTable("meaning", 16, 4*1024);
113114 meaningTable = (RelationTable)meaningInserter.getTable();
114115
 116+ Inserter aboutInserter = configureTable("about", 16, 4*1024);
 117+ aboutTable = (RelationTable)aboutInserter.getTable();
 118+
115119 mergeInserter = configureTable("merge", 16, 4*1024);
116120 mergeTable = (RelationTable)mergeInserter.getTable();
117121
@@ -678,7 +682,19 @@
679683 }
680684 }
681685
682 - public void buildMeaningIndex() throws PersistenceException {
 686+ public void buildGlobalIndexes() throws PersistenceException {
 687+ if (beginTask("buildGlobalIndexes", "importAbout")) {
 688+ importAbout();
 689+ endTask("buildGlobalIndexes", "importAbout");
 690+ }
 691+
 692+ if (beginTask("buildGlobalIndexes", "buildMeaningIndex")) {
 693+ buildMeaningIndex();
 694+ endTask("buildGlobalIndexes", "buildMeaningIndex");
 695+ }
 696+ }
 697+
 698+ protected void buildMeaningIndex() throws PersistenceException {
683699 Corpus[] cc = getLanguages();
684700
685701 for (Corpus c: cc) {
@@ -703,7 +719,35 @@
704720 int n = executeChunkedUpdate("importMeanings", "import("+c.getLanguage()+")", sql, null, localMeanings, "M.concept");
705721 return n;
706722 }
 723+
 724+ public void importAbout() throws PersistenceException {
 725+ Corpus[] cc = getLanguages();
 726+
 727+ for (Corpus c: cc) {
 728+ if (beginTask("importAbout", "importAbout#"+c.getLanguage())) {
 729+ importAbout(c);
 730+ endTask("importAbout", "importAbout#"+c.getLanguage());
 731+ }
 732+ }
 733+ }
707734
 735+ private int importAbout(Corpus c) throws PersistenceException {
 736+ LocalConceptStoreSchema localdb = getLocalConceptDatabase(c);
 737+ DatabaseTable localAbout = localdb.getTable("about");
 738+ DatabaseTable localResource = localdb.getTable("resource");
 739+ DatabaseTable origin = database.getTable("origin");
 740+
 741+ String sql = "INSERT INTO "+aboutTable.getSQLName()+" (concept, lang, local_resource, local_resource_name, type) "
 742+ + " SELECT O.global_concept, "+database.quoteString(c.getLanguage())+", R.id, R.name, R.type "
 743+ + " FROM "+origin.getSQLName()+" as O "
 744+ + " JOIN "+localAbout.getSQLName()+" as A ON A.concept = O.local_concept "
 745+ + " AND O.lang = "+database.quoteString(c.getLanguage()) + " "
 746+ + " JOIN "+localResource.getSQLName()+" as R ON R.id = A.resource ";
 747+
 748+ int n = executeChunkedUpdate("importAbout", "import("+c.getLanguage()+")", sql, null, localAbout, "A.concept");
 749+ return n;
 750+ }
 751+
708752 public void clusterGlobalConcepts() throws PersistenceException {
709753 int i = 0;
710754 while (true) {

Status & tagging log