jenkins-bot has submitted this change and it was merged.

Change subject: General code cleanup
......................................................................


General code cleanup

- Fix a NPE
- Remove some unused methods
- Remove some unused variables
- Slap some @SupressWarnings on junk in lucene-2.1 that use raw types
- Fix up some dead code paths

Change-Id: I41b4b6f2ff2cc006a230702d6e5ec59b0a583967
---
M src/org/apache/lucene/search/CustomBoostQuery.java
M src/org/apache/lucene/search/PositionalMultiQuery.java
M src/org/apache/lucene/search/PositionalScorer.java
M src/org/apache/lucene/search/RelevanceQuery.java
M src/org/wikimedia/lsearch/analyzers/FastWikiTokenizerEngine.java
M src/org/wikimedia/lsearch/analyzers/WikiQueryParser.java
M src/org/wikimedia/lsearch/frontend/SearchDaemon.java
M src/org/wikimedia/lsearch/index/WikiIndexModifier.java
M src/org/wikimedia/lsearch/interoperability/RMIMessengerClient.java
M src/org/wikimedia/lsearch/prefix/PrefixIndexBuilder.java
M src/org/wikimedia/lsearch/ranks/LinksBuilder.java
M src/org/wikimedia/lsearch/search/MatchAllTitlesQuery.java
M src/org/wikimedia/lsearch/search/RankField.java
M src/org/wikimedia/lsearch/search/SearcherCache.java
M src/org/wikimedia/lsearch/spell/SuggestBuilder.java
M src/org/wikimedia/lsearch/spell/api/SpellCheckIndexer.java
M src/org/wikimedia/lsearch/util/CharacterEntityReference.java
M src/org/wikimedia/lsearch/util/QueryStringMap.java
18 files changed, 18 insertions(+), 84 deletions(-)

Approvals:
  Demon: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/org/apache/lucene/search/CustomBoostQuery.java 
b/src/org/apache/lucene/search/CustomBoostQuery.java
index b6ef6f7..08e63dc 100644
--- a/src/org/apache/lucene/search/CustomBoostQuery.java
+++ b/src/org/apache/lucene/search/CustomBoostQuery.java
@@ -88,6 +88,7 @@
   }
 
   /*(non-Javadoc) @see 
org.apache.lucene.search.Query#extractTerms(java.util.Set) */
+  @SuppressWarnings("rawtypes")
   public void extractTerms(Set terms) {
     subQuery.extractTerms(terms);
     if (boostQuery!=null) {
diff --git a/src/org/apache/lucene/search/PositionalMultiQuery.java 
b/src/org/apache/lucene/search/PositionalMultiQuery.java
index 01b563d..65ad280 100644
--- a/src/org/apache/lucene/search/PositionalMultiQuery.java
+++ b/src/org/apache/lucene/search/PositionalMultiQuery.java
@@ -60,6 +60,7 @@
                        this.similarity = getSimilarity(searcher);
                        this.idf = 0;
              // compute idf - take average when multiple terms
+             @SuppressWarnings("rawtypes")
              Iterator i = termArrays.iterator();
              int count = 0;
              while (i.hasNext()) {
diff --git a/src/org/apache/lucene/search/PositionalScorer.java 
b/src/org/apache/lucene/search/PositionalScorer.java
index 5bfe110..db99fbf 100644
--- a/src/org/apache/lucene/search/PositionalScorer.java
+++ b/src/org/apache/lucene/search/PositionalScorer.java
@@ -162,13 +162,15 @@
                tfExplanation.setDescription("tf(freq=" + freq + ")");
 
                // add extra info about every term in the sum
-               if(DEBUG && explanations != null && explanations.get(doc) != 
null){
-                       Explanation eFreq = new Explanation();
-                       eFreq.setValue(freq);
-                       eFreq.setDescription("sum of:");                        
        
-                       for(Explanation e : explanations.get(doc))
-                               eFreq.addDetail(e);
-                       tfExplanation.addDetail(eFreq);
+               if(DEBUG) {
+                       if(explanations != null && explanations.get(doc) != 
null){
+                               Explanation eFreq = new Explanation();
+                               eFreq.setValue(freq);
+                               eFreq.setDescription("sum of:");
+                               for(Explanation e : explanations.get(doc))
+                                       eFreq.addDetail(e);
+                               tfExplanation.addDetail(eFreq);
+                       }
                }
 
                return tfExplanation;
diff --git a/src/org/apache/lucene/search/RelevanceQuery.java 
b/src/org/apache/lucene/search/RelevanceQuery.java
index a3c0aa1..21c2e41 100644
--- a/src/org/apache/lucene/search/RelevanceQuery.java
+++ b/src/org/apache/lucene/search/RelevanceQuery.java
@@ -52,6 +52,7 @@
        }
 
        /*(non-Javadoc) @see 
org.apache.lucene.search.Query#extractTerms(java.util.Set) */
+       @SuppressWarnings("rawtypes")
        public void extractTerms(Set terms) {
                main.extractTerms(terms);
                for(Query r : relevance)
diff --git a/src/org/wikimedia/lsearch/analyzers/FastWikiTokenizerEngine.java 
b/src/org/wikimedia/lsearch/analyzers/FastWikiTokenizerEngine.java
index d9d9289..95fe4f2 100644
--- a/src/org/wikimedia/lsearch/analyzers/FastWikiTokenizerEngine.java
+++ b/src/org/wikimedia/lsearch/analyzers/FastWikiTokenizerEngine.java
@@ -748,21 +748,6 @@
                return false;
        }
        
-       /** Check if the external link is valid, i.e. if it's a valid URL */
-       private final boolean validateExternalLink(){
-               if(cur + 1 >= textLength)
-                       return false;
-               cur++; // position after the '[' char
-               for(String p : PROTOCOLS){
-                       if(matchesString(p)){
-                               cur--;
-                               return true;
-                       }
-               }
-               cur--;
-               return false;
-       }
-       
        /** Returns true if the parsed article is a redirect page */
        public final boolean isRedirect(){
                if(textLength == 0 || text[0] != '#') // quick test
diff --git a/src/org/wikimedia/lsearch/analyzers/WikiQueryParser.java 
b/src/org/wikimedia/lsearch/analyzers/WikiQueryParser.java
index 3f2f919..b8e2f8c 100644
--- a/src/org/wikimedia/lsearch/analyzers/WikiQueryParser.java
+++ b/src/org/wikimedia/lsearch/analyzers/WikiQueryParser.java
@@ -1560,22 +1560,6 @@
                }
                return ret;
        }
-
-       /** Recursively transverse queries and put stop words to SHOULD */
-       private void filterStopWords(BooleanQuery bq) {
-               if(stopWords==null && stopWords.size()==0)
-                       return;
-               for(BooleanClause cl : bq.getClauses()){
-                       Query q = cl.getQuery();
-                       Occur o = cl.getOccur();
-                       if(q instanceof BooleanQuery){
-                               filterStopWords((BooleanQuery)q);
-                       } else if(q instanceof TermQuery && 
o.equals(Occur.MUST) 
-                                       && 
stopWords.contains(((TermQuery)q).getTerm().text())){
-                               cl.setOccur(Occur.SHOULD);
-                       }
-               }
-       }
        
        /** @return new ParsedWords with stop words deleted */
        private ParsedWords filterStopWords(ParsedWords words){
diff --git a/src/org/wikimedia/lsearch/frontend/SearchDaemon.java 
b/src/org/wikimedia/lsearch/frontend/SearchDaemon.java
index 3bd1240..3476ace 100644
--- a/src/org/wikimedia/lsearch/frontend/SearchDaemon.java
+++ b/src/org/wikimedia/lsearch/frontend/SearchDaemon.java
@@ -447,14 +447,6 @@
                        log.error("Error sending result line ("+score + " " + 
namespace + " " + title +"): "+e.getMessage(),e);
                }
        }
-       /** Unused? */
-       private void sendResultLine(String namespace, String title) {
-               try{
-                       sendOutputLine(namespace + " " +        
encodeTitle(title));
-               } catch(Exception e){
-                       log.error("Error sending prefix result line (" + 
namespace + " " + title +"): "+e.getMessage(),e);
-               }
-       }
 
        /**
         * Determine whether searchterm either contains a credit card number, 
diff --git a/src/org/wikimedia/lsearch/index/WikiIndexModifier.java 
b/src/org/wikimedia/lsearch/index/WikiIndexModifier.java
index 106ca23..52fba6d 100644
--- a/src/org/wikimedia/lsearch/index/WikiIndexModifier.java
+++ b/src/org/wikimedia/lsearch/index/WikiIndexModifier.java
@@ -787,18 +787,6 @@
                }
                return doc;
        }
-
-       /** Serialize redirects that will be added to end of the article */
-       private static String serializeRedirects(ArrayList<String> 
redirectKeywords) {
-               if(redirectKeywords.size()==0)
-                       return "";
-               StringBuilder sb = new StringBuilder();
-               for(String s : redirectKeywords){
-                       sb.append(s);
-                       sb.append(". ");
-               }
-               return sb.toString();
-       }
        
        /** Serialize alttitle (anchors, titles, redirects) to be added to end 
of contents */
        public static String serializeAlttitle(Article article, boolean 
exactCase){
diff --git a/src/org/wikimedia/lsearch/interoperability/RMIMessengerClient.java 
b/src/org/wikimedia/lsearch/interoperability/RMIMessengerClient.java
index 9b2ed8a..384fddf 100644
--- a/src/org/wikimedia/lsearch/interoperability/RMIMessengerClient.java
+++ b/src/org/wikimedia/lsearch/interoperability/RMIMessengerClient.java
@@ -8,7 +8,6 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Map;
@@ -23,7 +22,6 @@
 import org.wikimedia.lsearch.config.GlobalConfiguration;
 import org.wikimedia.lsearch.config.IndexId;
 import org.wikimedia.lsearch.highlight.Highlight;
-import org.wikimedia.lsearch.highlight.HighlightResult;
 import org.wikimedia.lsearch.index.IndexUpdateRecord;
 import org.wikimedia.lsearch.search.HighlightPack;
 import org.wikimedia.lsearch.search.NamespaceFilter;
diff --git a/src/org/wikimedia/lsearch/prefix/PrefixIndexBuilder.java 
b/src/org/wikimedia/lsearch/prefix/PrefixIndexBuilder.java
index 2c3d661..7a07c3d 100644
--- a/src/org/wikimedia/lsearch/prefix/PrefixIndexBuilder.java
+++ b/src/org/wikimedia/lsearch/prefix/PrefixIndexBuilder.java
@@ -411,6 +411,7 @@
        
        /** Set omitNorms on all fields of the document */
        protected void setOmitNorms(Document doc){
+               @SuppressWarnings("rawtypes")
                Iterator it = doc.getFields().iterator();
                while(it.hasNext()){
                        ((Field)it.next()).setOmitNorms(true);
diff --git a/src/org/wikimedia/lsearch/ranks/LinksBuilder.java 
b/src/org/wikimedia/lsearch/ranks/LinksBuilder.java
index 91ae418..58bc8e0 100644
--- a/src/org/wikimedia/lsearch/ranks/LinksBuilder.java
+++ b/src/org/wikimedia/lsearch/ranks/LinksBuilder.java
@@ -11,15 +11,11 @@
 import org.mediawiki.dumper.ProgressFilter;
 import org.mediawiki.dumper.Tools;
 import org.mediawiki.importer.XmlDumpReader;
-import org.wikimedia.lsearch.beans.Title;
 import org.wikimedia.lsearch.config.Configuration;
 import org.wikimedia.lsearch.config.GlobalConfiguration;
 import org.wikimedia.lsearch.config.IndexId;
 import org.wikimedia.lsearch.index.IndexThread;
-import org.wikimedia.lsearch.related.CompactArticleLinks;
-import org.wikimedia.lsearch.related.CompactLinks;
 import org.wikimedia.lsearch.related.Related;
-import org.wikimedia.lsearch.related.RelatedTitle;
 import org.wikimedia.lsearch.util.Localization;
 import org.wikimedia.lsearch.util.UnicodeDecomposer;
 
@@ -155,18 +151,6 @@
                                score += 1.0/norm(refCache.get((int) (l1)));
                }
                return score;
-       }
-
-       /**
-        * Get related titles (RelatedTitle is used in Article)
-        */
-       public static ArrayList<RelatedTitle> 
getRelatedTitles(CompactArticleLinks cs, CompactLinks links){
-               ArrayList<Related> rel = null; // getRelated(cs,links);
-               ArrayList<RelatedTitle> ret = new ArrayList<RelatedTitle>();
-               for(Related r : rel){
-                       ret.add(new RelatedTitle(new 
Title(r.getRelates().toString()),r.getScore()));
-               }
-               return ret;
        }
        
        public static double norm(double d){
diff --git a/src/org/wikimedia/lsearch/search/MatchAllTitlesQuery.java 
b/src/org/wikimedia/lsearch/search/MatchAllTitlesQuery.java
index 3168013..8e1891b 100644
--- a/src/org/wikimedia/lsearch/search/MatchAllTitlesQuery.java
+++ b/src/org/wikimedia/lsearch/search/MatchAllTitlesQuery.java
@@ -142,6 +142,7 @@
                return new MatchAllDocsWeight(searcher);
        }
 
+       @SuppressWarnings("rawtypes")
        public void extractTerms(Set terms) {
        }
 
diff --git a/src/org/wikimedia/lsearch/search/RankField.java 
b/src/org/wikimedia/lsearch/search/RankField.java
index 3331dc6..8e72034 100644
--- a/src/org/wikimedia/lsearch/search/RankField.java
+++ b/src/org/wikimedia/lsearch/search/RankField.java
@@ -39,6 +39,7 @@
                protected int[] ranks = null;
                
                protected RankFieldSource(IndexReader reader) throws 
IOException{
+                       @SuppressWarnings("rawtypes")
                        Collection fields = 
reader.getFieldNames(FieldOption.ALL);
                        if(!fields.contains("rank"))
                                return; // index doesn't have ranking info
diff --git a/src/org/wikimedia/lsearch/search/SearcherCache.java 
b/src/org/wikimedia/lsearch/search/SearcherCache.java
index 0a0f84e..2909208 100644
--- a/src/org/wikimedia/lsearch/search/SearcherCache.java
+++ b/src/org/wikimedia/lsearch/search/SearcherCache.java
@@ -101,6 +101,7 @@
                                if(iid.isArticleIndex() || 
iid.isTitlesBySuffix()){
                                        IndexReader reader = 
searcher.getIndexReader();
                                        ArrayList<CacheBuilder> builders = new 
ArrayList<CacheBuilder>();
+                                       @SuppressWarnings("rawtypes")
                                        Collection fields = 
reader.getFieldNames(FieldOption.ALL);
                                        for(Object fieldObj : fields){
                                                String field = (String)fieldObj;
diff --git a/src/org/wikimedia/lsearch/spell/SuggestBuilder.java 
b/src/org/wikimedia/lsearch/spell/SuggestBuilder.java
index 704966a..78970f7 100644
--- a/src/org/wikimedia/lsearch/spell/SuggestBuilder.java
+++ b/src/org/wikimedia/lsearch/spell/SuggestBuilder.java
@@ -75,11 +75,6 @@
                                        continue;
                                IndexId spell = iid.getSpell();
                                IndexId pre = spell.getPrecursor();
-                               if(spell == null){
-                                       log.fatal("Index "+iid+" doesn't have a 
spell-check index assigned. Enable them in global configuration.");
-                                       continue;
-                               }
-
                                if(inputfile != null){
                                        log.info("Rebuilding precursor 
index...");
                                        // open                 
diff --git a/src/org/wikimedia/lsearch/spell/api/SpellCheckIndexer.java 
b/src/org/wikimedia/lsearch/spell/api/SpellCheckIndexer.java
index 54b8c0a..dc4dd41 100644
--- a/src/org/wikimedia/lsearch/spell/api/SpellCheckIndexer.java
+++ b/src/org/wikimedia/lsearch/spell/api/SpellCheckIndexer.java
@@ -339,6 +339,7 @@
        
        /** Set omitNorms on all fields of the document */
        protected void setOmitNorms(Document doc){
+               @SuppressWarnings("rawtypes")
                Iterator it = doc.getFields().iterator();
                while(it.hasNext()){
                        ((Field)it.next()).setOmitNorms(true);
diff --git a/src/org/wikimedia/lsearch/util/CharacterEntityReference.java 
b/src/org/wikimedia/lsearch/util/CharacterEntityReference.java
index 7e3cf73..137bdd9 100644
--- a/src/org/wikimedia/lsearch/util/CharacterEntityReference.java
+++ b/src/org/wikimedia/lsearch/util/CharacterEntityReference.java
@@ -55,8 +55,6 @@
  * @see NumericCharacterReference
  */
 public class CharacterEntityReference {
-       private String name;
-
        /** <samp>&nbsp;</samp> <code>&amp;nbsp; = &amp;#160;</code> -- 
no-break space = non-breaking space, U+00A0 ISOnum. */
        public static final char _nbsp='\u00A0';
        /** <samp>&iexcl;</samp> <code>&amp;iexcl; = &amp;#161;</code> -- 
inverted exclamation mark, U+00A1 ISOnum. */
diff --git a/src/org/wikimedia/lsearch/util/QueryStringMap.java 
b/src/org/wikimedia/lsearch/util/QueryStringMap.java
index c0e860d..9e5e3b4 100644
--- a/src/org/wikimedia/lsearch/util/QueryStringMap.java
+++ b/src/org/wikimedia/lsearch/util/QueryStringMap.java
@@ -35,7 +35,7 @@
 import java.util.StringTokenizer;
 
 /** Extract parameters from an URL */
-public class QueryStringMap extends LinkedHashMap implements Map {
+public class QueryStringMap extends LinkedHashMap<String,Object> implements 
Map<String,Object> {
        
        public QueryStringMap(URI uri) {
                super();

-- 
To view, visit https://gerrit.wikimedia.org/r/60444
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I41b4b6f2ff2cc006a230702d6e5ec59b0a583967
Gerrit-PatchSet: 2
Gerrit-Project: operations/debs/lucene-search-2
Gerrit-Branch: master
Gerrit-Owner: Demon <ch...@wikimedia.org>
Gerrit-Reviewer: Demon <ch...@wikimedia.org>
Gerrit-Reviewer: Ram <r...@wikimedia.org>
Gerrit-Reviewer: Tim Starling <tstarl...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to