r50071 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50070‎ | r50071 | r50072 >
Date:09:16, 30 April 2009
Author:daniel
Status:deferred
Tags:
Comment:
encapsulate patricia trie
Modified paths:
  • /trunk/WikiWord/WikiWordBuilder/src/main/assembly/bin-dep.xml (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/NameMaps.java (added) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/processor/TitleSetFilter.java (modified) (history)
  • /trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseLocalConceptStoreBuilder.java (modified) (history)

Diff [purge]

Index: trunk/WikiWord/WikiWordBuilder/src/main/assembly/bin-dep.xml
@@ -35,6 +35,10 @@
3636 <include>*.jar</include>
3737 </includes>
3838 </fileSet>-->
 39+ <fileSet>
 40+ <directory>lib</directory>
 41+ <outputDirectory>/lib</outputDirectory>
 42+ </fileSet>
3943 </fileSets>
4044 <dependencySets>
4145 <dependencySet>
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/processor/TitleSetFilter.java
@@ -4,29 +4,28 @@
55 import java.io.FileInputStream;
66 import java.io.IOException;
77 import java.io.InputStream;
 8+import java.util.Map;
89 import java.util.Set;
910
10 -import org.ardverk.collection.PatriciaTrie;
11 -import org.ardverk.collection.StringKeyAnalyzer;
12 -
1311 import de.brightbyte.data.cursor.DataCursor;
1412 import de.brightbyte.data.filter.StaticSetFilter;
1513 import de.brightbyte.io.LineCursor;
1614 import de.brightbyte.util.PersistenceException;
 15+import de.brightbyte.wikiword.builder.NameMaps;
1716
1817 public class TitleSetFilter extends PageTitleFilter {
1918
2019 protected static Set<String> slurpCursor(DataCursor<String> titleCursor) throws PersistenceException {
21 - PatriciaTrie<String, Integer> trie = new PatriciaTrie<String, Integer>(new StringKeyAnalyzer());
 20+ Map<String, Integer> map = NameMaps.newMap();
2221
2322 final Integer ONE = new Integer(1);
2423
2524 String s;
2625 while ((s = titleCursor.next()) != null) {
27 - trie.put(s, ONE);
 26+ map.put(s, ONE);
2827 }
2928
30 - return trie.keySet();
 29+ return map.keySet();
3130 }
3231
3332 protected static Set<String> slurpLines(File f, String enc) throws PersistenceException {
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/builder/NameMaps.java
@@ -0,0 +1,20 @@
 2+package de.brightbyte.wikiword.builder;
 3+
 4+import java.util.HashMap;
 5+import java.util.Map;
 6+
 7+import org.ardverk.collection.PatriciaTrie;
 8+import org.ardverk.collection.StringKeyAnalyzer;
 9+
 10+public class NameMaps {
 11+ public static <V> Map<String, V> newMap() {
 12+ try {
 13+ PatriciaTrie<String, V> trie = new PatriciaTrie<String, V>(new StringKeyAnalyzer());
 14+ return trie;
 15+ } catch (LinkageError ex) {
 16+ //noop
 17+ }
 18+
 19+ return new HashMap<String, V>();
 20+ }
 21+}
Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/store/builder/DatabaseLocalConceptStoreBuilder.java
@@ -7,6 +7,7 @@
88 import java.sql.ResultSet;
99 import java.sql.SQLException;
1010 import java.util.Date;
 11+import java.util.Map;
1112 import java.util.Random;
1213
1314 import javax.sql.DataSource;
@@ -33,6 +34,7 @@
3435 import de.brightbyte.wikiword.ExtractionRule;
3536 import de.brightbyte.wikiword.ResourceType;
3637 import de.brightbyte.wikiword.TweakSet;
 38+import de.brightbyte.wikiword.builder.NameMaps;
3739 import de.brightbyte.wikiword.model.LocalConcept;
3840 import de.brightbyte.wikiword.model.LocalConceptReference;
3941 import de.brightbyte.wikiword.schema.AliasScope;
@@ -153,8 +155,8 @@
154156
155157 int bsz = tweaks.getTweak("dbstore.idManager.bufferSize", 16*1024);
156158
157 - //FIXME: use factory to create map impl!
158 - idManager = new PersistentIdManager(new PatriciaTrie<String, Integer>(new StringKeyAnalyzer()), f, "UTF-8", bsz);
 159+ Map<String, Integer> map = NameMaps.newMap();
 160+ idManager = new PersistentIdManager(map, f, "UTF-8", bsz);
159161 }
160162
161163 /*

Status & tagging log