r47744 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47743‎ | r47744 | r47745 >
Date:15:01, 24 February 2009
Author:daniel
Status:deferred
Tags:
Comment:
force index for resolve alias queries
Modified paths:
  • /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/DatabaseWikiWordStoreBuilder.java (modified) (history)

Diff [purge]

Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseWikiWordStoreBuilder.java
@@ -451,8 +451,9 @@
452452 }
453453 }
454454
455 - protected int resolveRedirects(RelationTable aliasTable, DatabaseTable table, String relNameField, String relIdField, AliasScope scope, int chunkFactor) throws PersistenceException {
 455+ protected int resolveRedirects(RelationTable aliasTable, DatabaseTable table, String relNameField, String relIdField, AliasScope scope, int chunkFactor, String forceIndex) throws PersistenceException {
456456 if (relIdField==null && relNameField==null) throw new IllegalArgumentException("relNameFields and relIdField can't both be null");
 457+ if (forceIndex!=null && table.getKey(forceIndex)==null) throw new IllegalArgumentException("unknown key: "+forceIndex);
457458
458459 DatabaseField nmField = relNameField ==null ? null : table.getField(relNameField);
459460 DatabaseField idField = relIdField == null ? null : table.getField(relIdField);
@@ -465,7 +466,10 @@
466467
467468 if (idTable!=null && nmTable!=null && !nmTable.equals(idTable)) throw new IllegalArgumentException(relNameField+" and "+relIdField+" in table "+table.getName()+" do not reference the same table: "+nmTable+" != "+idTable);
468469
469 - String sql = "UPDATE "+table.getSQLName()+" as R JOIN "+aliasTable.getSQLName()+" as E "
 470+
 471+ String sql = "UPDATE "+table.getSQLName()+" as R "
 472+ + (forceIndex!=null ? " force index ("+forceIndex+") " : "")
 473+ + " JOIN "+aliasTable.getSQLName()+" as E "
470474 + ((idField!=null) ? " ON R."+relIdField+" = E.source " : " ON R."+relNameField+" = E.source_name ")
471475 + " SET ";
472476
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseLocalConceptStoreBuilder.java
@@ -669,7 +669,7 @@
670670 //NOTE: need to resolve category-aliases here, so no concepts are generated for aliased categories!
671671 //NOTE: bad category redirs have been droped in finishBadLinks
672672 if (beginTask("finishMissingConcpets", "resolveRedirects:broader")) {
673 - int n = resolveRedirects(aliasTable, broaderTable, "broad_name", idManager==null ? null : "broad", AliasScope.CATEGORY, 1);
 673+ int n = resolveRedirects(aliasTable, broaderTable, "broad_name", idManager==null ? null : "broad", AliasScope.CATEGORY, 1, idManager==null ? "broad_name" : "broad_narrow");
674674 endTask("finishMissingConcpets", "resolveRedirects:broader", n+" entries");
675675 }
676676
@@ -741,24 +741,24 @@
742742 if (beginTask("finishAliases", "resolveRedirects:link")) {
743743 //XXX: SLOW!
744744 //TODO: smaller chunks? chunk on target table, not alias table? force index?
745 - int n = resolveRedirects(aliasTable, linkTable, "target_name", "target", AliasScope.REDIRECT, 8);
 745+ int n = resolveRedirects(aliasTable, linkTable, "target_name", "target", AliasScope.REDIRECT, 8, null);
746746 endTask("finishAliases", "resolveRedirects:link", n+" entries");
747747 }
748748
749749 //NOTE: broader.broad_name already done in finishMissingConcepts for AliasScope.BROADER
750750
751751 if (beginTask("finishAliases", "resolveRedirects:about")) {
752 - int n = resolveRedirects(aliasTable, aboutTable, null, "concept", null, 1);
 752+ int n = resolveRedirects(aliasTable, aboutTable, null, "concept", null, 1, null);
753753 endTask("finishAliases", "resolveRedirects:about", n+" entries");
754754 }
755755
756756 if (beginTask("finishAliases", "resolveRedirects:narrow")) {
757 - int n = resolveRedirects(aliasTable, broaderTable, "narrow_name", "narrow", null, 1);
 757+ int n = resolveRedirects(aliasTable, broaderTable, "narrow_name", "narrow", null, 1, null);
758758 endTask("finishAliases", "resolveRedirects:narrow", n+" entries");
759759 }
760760
761761 if (beginTask("finishAliases", "resolveRedirects:broad")) {
762 - int n = resolveRedirects(aliasTable, broaderTable, "broad_name", "broad", null, 1);
 762+ int n = resolveRedirects(aliasTable, broaderTable, "broad_name", "broad", null, 1, null);
763763 endTask("finishAliases", "resolveRedirects:broad", n+" entries");
764764 }
765765
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabasePropertyStoreBuilder.java
@@ -114,7 +114,7 @@
115115 if (beginTask("finishAliases", "resolveRedirects:property")) {
116116 RelationTable aliasTable = (RelationTable)conceptStoreSchema.getTable("alias");
117117
118 - int n = resolveRedirects(aliasTable, propertyTable, "concept_name", "concept", AliasScope.REDIRECT, 3);
 118+ int n = resolveRedirects(aliasTable, propertyTable, "concept_name", "concept", AliasScope.REDIRECT, 3, null);
119119 endTask("finishAliases", "resolveRedirects:property", n+" entries");
120120 }
121121 }

Status & tagging log