lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r829454 [6/8] - in /lucene/java/branches/flex_1458: ./ contrib/ contrib/analyzers/common/src/java/org/apache/lucene/analysis/ar/ contrib/analyzers/common/src/java/org/apache/lucene/analysis/br/ contrib/analyzers/common/src/java/org/apache/l...
Date Sat, 24 Oct 2009 21:23:37 GMT
Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/queryParser/QueryParser.jj
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/queryParser/QueryParser.jj?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/queryParser/QueryParser.jj (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/queryParser/QueryParser.jj Sat Oct 24 21:23:15 2009
@@ -36,7 +36,6 @@
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.Vector;
 
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.CachingTokenFilter;
@@ -58,7 +57,7 @@
 import org.apache.lucene.search.TermRangeQuery;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.search.WildcardQuery;
-import org.apache.lucene.util.Parameter;
+import org.apache.lucene.util.Version;
 
 /**
  * This class is generated by JavaCC.  The most important method is
@@ -125,6 +124,14 @@
  * <p><b>NOTE</b>: there is a new QueryParser in contrib, which matches
  * the same syntax as this class, but is more modular,
  * enabling substantial customization to how a query is created.
+ *
+ * <a name="version"/>
+ * <p><b>NOTE</b>: You must specify the required {@link Version}
+ * compatibility when creating QueryParser:
+ * <ul>
+ *    <li> As of 2.9, {@link #setEnablePositionIncrements} is true by
+ *         default.
+ * </ul>
  */
 public class QueryParser {
 
@@ -149,7 +156,7 @@
   boolean lowercaseExpandedTerms = true;
   MultiTermQuery.RewriteMethod multiTermRewriteMethod = MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT;
   boolean allowLeadingWildcard = false;
-  boolean enablePositionIncrements = false;
+  boolean enablePositionIncrements = true;
 
   Analyzer analyzer;
   String field;
@@ -161,7 +168,7 @@
   // the default date resolution
   DateTools.Resolution dateResolution = null;
   // maps field names to date resolutions
-  Map fieldToDateResolution = null;
+  Map<String,DateTools.Resolution> fieldToDateResolution = null;
 
   // The collator to use when determining range inclusion,
   // for use when constructing RangeQuerys.
@@ -170,23 +177,22 @@
   /** The default operator for parsing queries. 
    * Use {@link QueryParser#setDefaultOperator} to change it.
    */
-  static public final class Operator extends Parameter {
-    private Operator(String name) {
-      super(name);
-    }
-    static public final Operator OR = new Operator("OR");
-    static public final Operator AND = new Operator("AND");
-  }
-
+  static public enum Operator { OR, AND }
 
   /** Constructs a query parser.
+   *  @param matchVersion  Lucene version to match.  See {@link <a href="#version">above</a>)
    *  @param f  the default field for query terms.
    *  @param a   used to find terms in the query text.
    */
-  public QueryParser(String f, Analyzer a) {
+  public QueryParser(Version matchVersion, String f, Analyzer a) {
     this(new FastCharStream(new StringReader("")));
     analyzer = a;
     field = f;
+    if (matchVersion.onOrAfter(Version.LUCENE_29)) {
+      enablePositionIncrements = true;
+    } else {
+      enablePositionIncrements = false;
+    }
   }
 
   /** Parses a query string, returning a {@link org.apache.lucene.search.Query}.
@@ -360,29 +366,6 @@
   }
 
   /**
-   * @deprecated Please use {@link #setMultiTermRewriteMethod} instead.
-   */
-  public void setUseOldRangeQuery(boolean useOldRangeQuery) {
-    if (useOldRangeQuery) {
-      setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
-    } else {
-      setMultiTermRewriteMethod(MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
-    }
-  }
-
-
-  /**
-   * @deprecated Please use {@link #getMultiTermRewriteMethod} instead.
-   */
-  public boolean getUseOldRangeQuery() {
-    if (getMultiTermRewriteMethod() == MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE) {
-      return true;
-    } else {
-      return false;
-    }
-  }
-
-  /**
    * By default QueryParser uses {@link MultiTermQuery#CONSTANT_SCORE_AUTO_REWRITE_DEFAULT}
    * when creating a PrefixQuery, WildcardQuery or RangeQuery. This implementation is generally preferable because it 
    * a) Runs faster b) Does not have the scarcity of terms unduly influence score 
@@ -442,7 +425,7 @@
 
     if (fieldToDateResolution == null) {
       // lazily initialize HashMap
-      fieldToDateResolution = new HashMap();
+      fieldToDateResolution = new HashMap<String,DateTools.Resolution>();
     }
 
     fieldToDateResolution.put(fieldName, dateResolution);
@@ -464,7 +447,7 @@
       return this.dateResolution;
     }
 
-    DateTools.Resolution resolution = (DateTools.Resolution) fieldToDateResolution.get(fieldName);
+    DateTools.Resolution resolution = fieldToDateResolution.get(fieldName);
     if (resolution == null) {
       // no date resolutions set for the given field; return default date resolution instead
       resolution = this.dateResolution;
@@ -497,20 +480,13 @@
     return rangeCollator;
   }
 
-  /**
-   * @deprecated use {@link #addClause(List, int, int, Query)} instead.
-   */
-  protected void addClause(Vector clauses, int conj, int mods, Query q) {
-    addClause((List) clauses, conj, mods, q);
-  }
-
-  protected void addClause(List clauses, int conj, int mods, Query q) {
+  protected void addClause(List<BooleanClause> clauses, int conj, int mods, Query q) {
     boolean required, prohibited;
 
     // If this term is introduced by AND, make the preceding term required,
     // unless it's already prohibited
     if (clauses.size() > 0 && conj == CONJ_AND) {
-      BooleanClause c = (BooleanClause) clauses.get(clauses.size()-1);
+      BooleanClause c = clauses.get(clauses.size()-1);
       if (!c.isProhibited())
         c.setOccur(BooleanClause.Occur.MUST);
     }
@@ -520,7 +496,7 @@
       // unless it's prohibited (that means we leave -a OR b but +a OR b-->a OR b)
       // notice if the input is a OR b, first term is parsed as required; without
       // this modification a OR b would parsed as +a OR b
-      BooleanClause c = (BooleanClause) clauses.get(clauses.size()-1);
+      BooleanClause c = clauses.get(clauses.size()-1);
       if (!c.isProhibited())
         c.setOccur(BooleanClause.Occur.SHOULD);
     }
@@ -659,7 +635,7 @@
           // phrase query:
           MultiPhraseQuery mpq = newMultiPhraseQuery();
           mpq.setSlop(phraseSlop);
-          List multiTerms = new ArrayList();
+          List<Term> multiTerms = new ArrayList<Term>();
           int position = -1;
           for (int i = 0; i < numTokens; i++) {
             String term = null;
@@ -677,9 +653,9 @@
 
             if (positionIncrement > 0 && multiTerms.size() > 0) {
               if (enablePositionIncrements) {
-                mpq.add((Term[])multiTerms.toArray(new Term[0]),position);
+                mpq.add(multiTerms.toArray(new Term[0]),position);
               } else {
-                mpq.add((Term[])multiTerms.toArray(new Term[0]));
+                mpq.add(multiTerms.toArray(new Term[0]));
               }
               multiTerms.clear();
             }
@@ -687,9 +663,9 @@
             multiTerms.add(new Term(field, term));
           }
           if (enablePositionIncrements) {
-            mpq.add((Term[])multiTerms.toArray(new Term[0]),position);
+            mpq.add(multiTerms.toArray(new Term[0]),position);
           } else {
-            mpq.add((Term[])multiTerms.toArray(new Term[0]));
+            mpq.add(multiTerms.toArray(new Term[0]));
           }
           return mpq;
         }
@@ -909,26 +885,8 @@
    *
    * @return Resulting {@link Query} object.
    * @exception ParseException throw in overridden method to disallow
-   * @deprecated use {@link #getBooleanQuery(List)} instead
-   */
-  protected Query getBooleanQuery(Vector clauses) throws ParseException {
-    return getBooleanQuery((List) clauses, false);
-  }
-
-  /**
-   * Factory method for generating query, given a set of clauses.
-   * By default creates a boolean query composed of clauses passed in.
-   *
-   * Can be overridden by extending classes, to modify query being
-   * returned.
-   *
-   * @param clauses List that contains {@link BooleanClause} instances
-   *    to join.
-   *
-   * @return Resulting {@link Query} object.
-   * @exception ParseException throw in overridden method to disallow
    */
-  protected Query getBooleanQuery(List clauses) throws ParseException {
+  protected Query getBooleanQuery(List<BooleanClause> clauses) throws ParseException {
     return getBooleanQuery(clauses, false);
   }
 
@@ -945,37 +903,16 @@
    *
    * @return Resulting {@link Query} object.
    * @exception ParseException throw in overridden method to disallow
-   * @deprecated use {@link #getBooleanQuery(List, boolean)} instead
-   */
-  protected Query getBooleanQuery(Vector clauses, boolean disableCoord)
-    throws ParseException
-  {
-    return getBooleanQuery((List) clauses, disableCoord);
-  }
-
-  /**
-   * Factory method for generating query, given a set of clauses.
-   * By default creates a boolean query composed of clauses passed in.
-   *
-   * Can be overridden by extending classes, to modify query being
-   * returned.
-   *
-   * @param clauses List that contains {@link BooleanClause} instances
-   *    to join.
-   * @param disableCoord true if coord scoring should be disabled.
-   *
-   * @return Resulting {@link Query} object.
-   * @exception ParseException throw in overridden method to disallow
    */
-  protected Query getBooleanQuery(List clauses, boolean disableCoord)
+  protected Query getBooleanQuery(List<BooleanClause> clauses, boolean disableCoord)
     throws ParseException
   {
     if (clauses.size()==0) {
       return null; // all clause words were filtered away by the analyzer.
     }
     BooleanQuery query = newBooleanQuery(disableCoord);
-    for (int i = 0; i < clauses.size(); i++) {
-      query.add((BooleanClause)clauses.get(i));
+    for(final BooleanClause clause: clauses) {
+      query.add(clause);
     }
     return query;
   }
@@ -1179,7 +1116,7 @@
       System.out.println("Usage: java org.apache.lucene.queryParser.QueryParser <input>");
       System.exit(0);
     }
-    QueryParser qp = new QueryParser("field",
+    QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field",
                            new org.apache.lucene.analysis.SimpleAnalyzer());
     Query q = qp.parse(args[0]);
     System.out.println(q.toString("field"));
@@ -1286,7 +1223,7 @@
 
 Query Query(String field) :
 {
-  List clauses = new ArrayList();
+  List<BooleanClause> clauses = new ArrayList<BooleanClause>();
   Query q, firstQuery=null;
   int conj, mods;
 }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/queryParser/QueryParserTokenManager.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/queryParser/QueryParserTokenManager.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/queryParser/QueryParserTokenManager.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/queryParser/QueryParserTokenManager.java Sat Oct 24 21:23:15 2009
@@ -32,7 +32,7 @@
 import org.apache.lucene.search.TermRangeQuery;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.search.WildcardQuery;
-import org.apache.lucene.util.Parameter;
+import org.apache.lucene.util.Version;
 
 /** Token Manager. */
 public class QueryParserTokenManager implements QueryParserConstants

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanClause.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanClause.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanClause.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanClause.java Sat Oct 24 21:23:15 2009
@@ -1,7 +1,5 @@
 package org.apache.lucene.search;
 
-import org.apache.lucene.util.Parameter;
-
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -23,33 +21,24 @@
 public class BooleanClause implements java.io.Serializable {
   
   /** Specifies how clauses are to occur in matching documents. */
-  public static final class Occur extends Parameter implements java.io.Serializable {
-    
-    private Occur(String name) {
-      // typesafe enum pattern, no public constructor
-      super(name);
-    }
-
-    public String toString() {
-      if (this == MUST) return "+";
-      if (this == MUST_NOT) return "-";
-      return "";
-    }
+  public static enum Occur {
 
     /** Use this operator for clauses that <i>must</i> appear in the matching documents. */
-    public static final Occur MUST = new Occur("MUST");
+    MUST     { public String toString() { return "+"; } },
+
     /** Use this operator for clauses that <i>should</i> appear in the 
      * matching documents. For a BooleanQuery with no <code>MUST</code> 
      * clauses one or more <code>SHOULD</code> clauses must match a document 
      * for the BooleanQuery to match.
      * @see BooleanQuery#setMinimumNumberShouldMatch
      */
-    public static final Occur SHOULD = new Occur("SHOULD");
+    SHOULD   { public String toString() { return "";  } },
+
     /** Use this operator for clauses that <i>must not</i> appear in the matching documents.
      * Note that it is not possible to search for queries that only consist
      * of a <code>MUST_NOT</code> clause. */
-    public static final Occur MUST_NOT = new Occur("MUST_NOT");
-    
+    MUST_NOT { public String toString() { return "-"; } };
+
   }
 
   /** The query whose matching documents are combined by the boolean query.
@@ -85,11 +74,11 @@
   }
   
   public boolean isProhibited() {
-    return Occur.MUST_NOT.equals(occur);
+    return Occur.MUST_NOT == occur;
   }
 
   public boolean isRequired() {
-    return Occur.MUST.equals(occur);
+    return Occur.MUST == occur;
   }
 
 
@@ -100,12 +89,12 @@
       return false;
     BooleanClause other = (BooleanClause)o;
     return this.query.equals(other.query)
-      && this.occur.equals(other.occur);
+      && this.occur == other.occur;
   }
 
   /** Returns a hash code value for this object.*/
   public int hashCode() {
-    return query.hashCode() ^ (Occur.MUST.equals(occur)?1:0) ^ (Occur.MUST_NOT.equals(occur)?2:0);
+    return query.hashCode() ^ (Occur.MUST == occur?1:0) ^ (Occur.MUST_NOT == occur?2:0);
   }
 
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanQuery.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanQuery.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanQuery.java Sat Oct 24 21:23:15 2009
@@ -187,8 +187,7 @@
       this.similarity = getSimilarity(searcher);
       weights = new ArrayList<Weight>(clauses.size());
       for (int i = 0 ; i < clauses.size(); i++) {
-        BooleanClause c = (BooleanClause)clauses.get(i);
-        weights.add(c.getQuery().createWeight(searcher));
+        weights.add(clauses.get(i).getQuery().createWeight(searcher));
       }
     }
 
@@ -202,11 +201,9 @@
     public float sumOfSquaredWeights() throws IOException {
       float sum = 0.0f;
       for (int i = 0 ; i < weights.size(); i++) {
-        BooleanClause c = (BooleanClause)clauses.get(i);
-        Weight w = (Weight)weights.get(i);
         // call sumOfSquaredWeights for all clauses in case of side effects
-        float s = w.sumOfSquaredWeights();         // sum sub weights
-        if (!c.isProhibited())
+        float s = weights.get(i).sumOfSquaredWeights();         // sum sub weights
+        if (!clauses.get(i).isProhibited())
           // only add to sum for non-prohibited clauses
           sum += s;
       }
@@ -370,7 +367,7 @@
   @Override
   public Query rewrite(IndexReader reader) throws IOException {
     if (minNrShouldMatch == 0 && clauses.size() == 1) {                    // optimize 1-clause queries
-      BooleanClause c = (BooleanClause)clauses.get(0);
+      BooleanClause c = clauses.get(0);
       if (!c.isProhibited()) {			  // just return clause
 
         Query query = c.getQuery().rewrite(reader);    // rewrite first
@@ -409,10 +406,10 @@
         }
   }
 
-  @Override
+  @Override @SuppressWarnings("unchecked")
   public Object clone() {
     BooleanQuery clone = (BooleanQuery)super.clone();
-    clone.clauses = (ArrayList<BooleanClause>)this.clauses.clone();
+    clone.clauses = (ArrayList<BooleanClause>) this.clauses.clone();
     return clone;
   }
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanScorer2.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanScorer2.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanScorer2.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/BooleanScorer2.java Sat Oct 24 21:23:15 2009
@@ -212,7 +212,7 @@
     if (optionalScorers.size() > nrOptRequired)
       requiredCountingSumScorer = countingDisjunctionSumScorer(optionalScorers, nrOptRequired);
     else if (optionalScorers.size() == 1)
-      requiredCountingSumScorer = new SingleMatchScorer((Scorer) optionalScorers.get(0));
+      requiredCountingSumScorer = new SingleMatchScorer(optionalScorers.get(0));
     else
       requiredCountingSumScorer = countingConjunctionSumScorer(optionalScorers);
     return addProhibitedScorers(requiredCountingSumScorer);
@@ -226,7 +226,7 @@
     } else { // optionalScorers.size() > minNrShouldMatch, and at least one required scorer
       Scorer requiredCountingSumScorer =
             requiredScorers.size() == 1
-            ? new SingleMatchScorer((Scorer) requiredScorers.get(0))
+            ? new SingleMatchScorer(requiredScorers.get(0))
             : countingConjunctionSumScorer(requiredScorers);
       if (minNrShouldMatch > 0) { // use a required disjunction scorer over the optional scorers
         return addProhibitedScorers( 
@@ -239,7 +239,7 @@
         return new ReqOptSumScorer(
                       addProhibitedScorers(requiredCountingSumScorer),
                       optionalScorers.size() == 1
-                        ? new SingleMatchScorer((Scorer) optionalScorers.get(0))
+                        ? new SingleMatchScorer(optionalScorers.get(0))
                         // require 1 in combined, optional scorer.
                         : countingDisjunctionSumScorer(optionalScorers, 1));
       }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/CachingWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/CachingWrapperFilter.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/CachingWrapperFilter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/CachingWrapperFilter.java Sat Oct 24 21:23:15 2009
@@ -72,7 +72,7 @@
     }
 
     if (cached != null) {
-      return (DocIdSet) cached;
+      return cached;
     }
 
     final DocIdSet docIdSet = docIdSetToCache(filter.getDocIdSet(reader), reader);

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/DefaultSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/DefaultSimilarity.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/DefaultSimilarity.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/DefaultSimilarity.java Sat Oct 24 21:23:15 2009
@@ -37,7 +37,7 @@
       numTerms = state.getLength() - state.getNumOverlap();
     else
       numTerms = state.getLength();
-    return (float) (state.getBoost() * lengthNorm(field, numTerms));
+    return (state.getBoost() * lengthNorm(field, numTerms));
   }
   
   /** Implemented as <code>1/sqrt(numTerms)</code>. */

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java Sat Oct 24 21:23:15 2009
@@ -39,10 +39,10 @@
  * include this term in only the best of those multiple fields, without confusing this with the better case of two different terms
  * in the multiple fields.
  */
-public class DisjunctionMaxQuery extends Query {
+public class DisjunctionMaxQuery extends Query implements Iterable<Query> {
 
   /* The subqueries */
-  private ArrayList disjuncts = new ArrayList();
+  private ArrayList<Query> disjuncts = new ArrayList<Query>();
 
   /* Multiple of the non-max disjunct scores added into our final score.  Non-zero values support tie-breaking. */
   private float tieBreakerMultiplier = 0.0f;
@@ -62,7 +62,7 @@
    * @param disjuncts a Collection<Query> of all the disjuncts to add
    * @param tieBreakerMultiplier   the weight to give to each matching non-maximum disjunct
    */
-  public DisjunctionMaxQuery(Collection disjuncts, float tieBreakerMultiplier) {
+  public DisjunctionMaxQuery(Collection<Query> disjuncts, float tieBreakerMultiplier) {
     this.tieBreakerMultiplier = tieBreakerMultiplier;
     add(disjuncts);
   }
@@ -77,12 +77,12 @@
   /** Add a collection of disjuncts to this disjunction
    * via Iterable<Query>
    */
-  public void add(Collection disjuncts) {
+  public void add(Collection<Query> disjuncts) {
     this.disjuncts.addAll(disjuncts);
   }
 
   /** An Iterator<Query> over the disjuncts */
-  public Iterator iterator() {
+  public Iterator<Query> iterator() {
     return disjuncts.iterator();
   }
 
@@ -98,27 +98,30 @@
     protected Similarity similarity;
 
     /** The Weights for our subqueries, in 1-1 correspondence with disjuncts */
-    protected ArrayList weights = new ArrayList();  // The Weight's for our subqueries, in 1-1 correspondence with disjuncts
+    protected ArrayList<Weight> weights = new ArrayList<Weight>();  // The Weight's for our subqueries, in 1-1 correspondence with disjuncts
 
     /* Construct the Weight for this Query searched by searcher.  Recursively construct subquery weights. */
     public DisjunctionMaxWeight(Searcher searcher) throws IOException {
       this.similarity = searcher.getSimilarity();
-      for (Iterator iter = disjuncts.iterator(); iter.hasNext();) {
-        weights.add(((Query) iter.next()).createWeight(searcher));
+      for (Query disjunctQuery : disjuncts) {
+        weights.add(disjunctQuery.createWeight(searcher));
       }
     }
 
     /* Return our associated DisjunctionMaxQuery */
+    @Override
     public Query getQuery() { return DisjunctionMaxQuery.this; }
 
     /* Return our boost */
+    @Override
     public float getValue() { return getBoost(); }
 
     /* Compute the sub of squared weights of us applied to our subqueries.  Used for normalization. */
+    @Override
     public float sumOfSquaredWeights() throws IOException {
       float max = 0.0f, sum = 0.0f;
-      for (Iterator iter = weights.iterator(); iter.hasNext();) {
-        float sub = ((Weight) iter.next()).sumOfSquaredWeights();
+      for (Weight currentWeight : weights) {
+        float sub = currentWeight.sumOfSquaredWeights();
         sum += sub;
         max = Math.max(max, sub);
         
@@ -128,10 +131,11 @@
     }
 
     /* Apply the computed normalization factor to our subqueries */
+    @Override
     public void normalize(float norm) {
       norm *= getBoost();  // Incorporate our boost
-      for (Iterator iter = weights.iterator(); iter.hasNext();) {
-        ((Weight) iter.next()).normalize(norm);
+      for (Weight wt : weights) {
+        wt.normalize(norm);
       }
     }
 
@@ -140,8 +144,7 @@
         boolean topScorer) throws IOException {
       Scorer[] scorers = new Scorer[weights.size()];
       int idx = 0;
-      for (Iterator iter = weights.iterator(); iter.hasNext();) {
-        Weight w = (Weight) iter.next();
+      for (Weight w : weights) {
         Scorer subScorer = w.scorer(reader, true, false);
         if (subScorer != null && subScorer.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
           scorers[idx++] = subScorer;
@@ -153,13 +156,14 @@
     }
 
     /* Explain the score we computed for doc */
+    @Override
     public Explanation explain(IndexReader reader, int doc) throws IOException {
-      if (disjuncts.size() == 1) return ((Weight) weights.get(0)).explain(reader,doc);
+      if (disjuncts.size() == 1) return weights.get(0).explain(reader,doc);
       ComplexExplanation result = new ComplexExplanation();
       float max = 0.0f, sum = 0.0f;
       result.setDescription(tieBreakerMultiplier == 0.0f ? "max of:" : "max plus " + tieBreakerMultiplier + " times others of:");
-      for (Iterator iter = weights.iterator(); iter.hasNext();) {
-        Explanation e = ((Weight) iter.next()).explain(reader, doc);
+      for (Weight wt : weights) {
+        Explanation e = wt.explain(reader, doc);
         if (e.isMatch()) {
           result.setMatch(Boolean.TRUE);
           result.addDetail(e);
@@ -174,6 +178,7 @@
   }  // end of DisjunctionMaxWeight inner class
 
   /* Create the Weight used to score us */
+  @Override
   public Weight createWeight(Searcher searcher) throws IOException {
     return new DisjunctionMaxWeight(searcher);
   }
@@ -184,7 +189,7 @@
   public Query rewrite(IndexReader reader) throws IOException {
     int numDisjunctions = disjuncts.size();
     if (numDisjunctions == 1) {
-      Query singleton = (Query) disjuncts.get(0);
+      Query singleton = disjuncts.get(0);
       Query result = singleton.rewrite(reader);
       if (getBoost() != 1.0f) {
         if (result == singleton) result = (Query)result.clone();
@@ -194,7 +199,7 @@
     }
     DisjunctionMaxQuery clone = null;
     for (int i = 0 ; i < numDisjunctions; i++) {
-      Query clause = (Query) disjuncts.get(i);
+      Query clause = disjuncts.get(i);
       Query rewrite = clause.rewrite(reader);
       if (rewrite != clause) {
         if (clone == null) clone = (DisjunctionMaxQuery)this.clone();
@@ -207,16 +212,18 @@
 
   /** Create a shallow copy of us -- used in rewriting if necessary
    * @return a copy of us (but reuse, don't copy, our subqueries) */
+  @Override @SuppressWarnings("unchecked")
   public Object clone() {
     DisjunctionMaxQuery clone = (DisjunctionMaxQuery)super.clone();
-    clone.disjuncts = (ArrayList<Query>)this.disjuncts.clone();
+    clone.disjuncts = (ArrayList<Query>) this.disjuncts.clone();
     return clone;
   }
 
   // inherit javadoc
+  @Override
   public void extractTerms(Set<Term> terms) {
-    for (Iterator iter = disjuncts.iterator(); iter.hasNext();) {
-      ((Query) iter.next()).extractTerms(terms);
+    for (Query query : disjuncts) {
+      query.extractTerms(terms);
     }
   }
 
@@ -229,7 +236,7 @@
     buffer.append("(");
     int numDisjunctions = disjuncts.size();
     for (int i = 0 ; i < numDisjunctions; i++) {
-      Query subquery = (Query) disjuncts.get(i);
+      Query subquery = disjuncts.get(i);
       if (subquery instanceof BooleanQuery) {   // wrap sub-bools in parens
         buffer.append("(");
         buffer.append(subquery.toString(field));
@@ -254,6 +261,7 @@
    * @param o another object
    * @return true iff o is a DisjunctionMaxQuery with the same boost and the same subqueries, in the same order, as us
    */
+  @Override
   public boolean equals(Object o) {
     if (! (o instanceof DisjunctionMaxQuery) ) return false;
     DisjunctionMaxQuery other = (DisjunctionMaxQuery)o;
@@ -265,6 +273,7 @@
   /** Compute a hash code for hashing us
    * @return the hash code
    */
+  @Override
   public int hashCode() {
     return Float.floatToIntBits(getBoost())
             + Float.floatToIntBits(tieBreakerMultiplier)

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCacheImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCacheImpl.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCacheImpl.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldCacheImpl.java Sat Oct 24 21:23:15 2009
@@ -492,9 +492,8 @@
       super(wrapper);
     }
 
-    protected Object createValue(IndexReader reader, Entry entryKey)
+    protected Object createValue(IndexReader reader, Entry entry)
         throws IOException {
-      Entry entry = (Entry) entryKey;
       String field = entry.field;
       FieldCache.LongParser parser = (FieldCache.LongParser) entry.custom;
       if (parser == null) {
@@ -619,7 +618,7 @@
 
     protected Object createValue(IndexReader reader, Entry entryKey)
         throws IOException {
-      String field = StringHelper.intern((String) entryKey.field);
+      String field = StringHelper.intern(entryKey.field);
       final String[] retArray = new String[reader.maxDoc()];
 
       Terms terms = reader.fields().terms(field);
@@ -659,7 +658,7 @@
 
     protected Object createValue(IndexReader reader, Entry entryKey)
         throws IOException {
-      String field = StringHelper.intern((String) entryKey.field);
+      String field = StringHelper.intern(entryKey.field);
       final int[] retArray = new int[reader.maxDoc()];
       String[] mterms = new String[reader.maxDoc()+1];
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldComparator.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldComparator.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldComparator.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldComparator.java Sat Oct 24 21:23:15 2009
@@ -84,6 +84,85 @@
  */
 public abstract class FieldComparator {
 
+  /**
+   * Compare hit at slot1 with hit at slot2.
+   * 
+   * @param slot1 first slot to compare
+   * @param slot2 second slot to compare
+   * @return any N < 0 if slot2's value is sorted after
+   * slot1, any N > 0 if the slot2's value is sorted before
+   * slot1 and 0 if they are equal
+   */
+  public abstract int compare(int slot1, int slot2);
+
+  /**
+   * Set the bottom slot, ie the "weakest" (sorted last)
+   * entry in the queue.  When {@link #compareBottom} is
+   * called, you should compare against this slot.  This
+   * will always be called before {@link #compareBottom}.
+   * 
+   * @param slot the currently weakest (sorted last) slot in the queue
+   */
+  public abstract void setBottom(final int slot);
+
+  /**
+   * Compare the bottom of the queue with doc.  This will
+   * only invoked after setBottom has been called.  This
+   * should return the same result as {@link
+   * #compare(int,int)}} as if bottom were slot1 and the new
+   * document were slot 2.
+   *    
+   * <p>For a search that hits many results, this method
+   * will be the hotspot (invoked by far the most
+   * frequently).</p>
+   * 
+   * @param doc that was hit
+   * @return any N < 0 if the doc's value is sorted after
+   * the bottom entry (not competitive), any N > 0 if the
+   * doc's value is sorted before the bottom entry and 0 if
+   * they are equal.
+   */
+  public abstract int compareBottom(int doc) throws IOException;
+
+  /**
+   * This method is called when a new hit is competitive.
+   * You should copy any state associated with this document
+   * that will be required for future comparisons, into the
+   * specified slot.
+   * 
+   * @param slot which slot to copy the hit to
+   * @param doc docID relative to current reader
+   */
+  public abstract void copy(int slot, int doc) throws IOException;
+
+  /**
+   * Set a new Reader. All doc correspond to the current Reader.
+   * 
+   * @param reader current reader
+   * @param docBase docBase of this reader 
+   * @throws IOException
+   * @throws IOException
+   */
+  public abstract void setNextReader(IndexReader reader, int docBase) throws IOException;
+
+  /** Sets the Scorer to use in case a document's score is
+   *  needed.
+   * 
+   * @param scorer Scorer instance that you should use to
+   * obtain the current hit's score, if necessary. */
+  public void setScorer(Scorer scorer) {
+    // Empty implementation since most comparators don't need the score. This
+    // can be overridden by those that need it.
+  }
+  
+  /**
+   * Return the actual value in the slot.
+   *
+   * @param slot the value
+   * @return value in this slot upgraded to Comparable
+   */
+  public abstract Comparable value(int slot);
+
   /** Parses field's values as byte (using {@link
    *  FieldCache#getBytes} and sorts by ascending value */
   public static final class ByteComparator extends FieldComparator {
@@ -789,83 +868,4 @@
     }
     return -(low + 1);
   }
-
-  /**
-   * Compare hit at slot1 with hit at slot2.
-   * 
-   * @param slot1 first slot to compare
-   * @param slot2 second slot to compare
-   * @return any N < 0 if slot2's value is sorted after
-   * slot1, any N > 0 if the slot2's value is sorted before
-   * slot1 and 0 if they are equal
-   */
-  public abstract int compare(int slot1, int slot2);
-
-  /**
-   * Set the bottom slot, ie the "weakest" (sorted last)
-   * entry in the queue.  When {@link #compareBottom} is
-   * called, you should compare against this slot.  This
-   * will always be called before {@link #compareBottom}.
-   * 
-   * @param slot the currently weakest (sorted last) slot in the queue
-   */
-  public abstract void setBottom(final int slot);
-
-  /**
-   * Compare the bottom of the queue with doc.  This will
-   * only invoked after setBottom has been called.  This
-   * should return the same result as {@link
-   * #compare(int,int)}} as if bottom were slot1 and the new
-   * document were slot 2.
-   *    
-   * <p>For a search that hits many results, this method
-   * will be the hotspot (invoked by far the most
-   * frequently).</p>
-   * 
-   * @param doc that was hit
-   * @return any N < 0 if the doc's value is sorted after
-   * the bottom entry (not competitive), any N > 0 if the
-   * doc's value is sorted before the bottom entry and 0 if
-   * they are equal.
-   */
-  public abstract int compareBottom(int doc) throws IOException;
-
-  /**
-   * This method is called when a new hit is competitive.
-   * You should copy any state associated with this document
-   * that will be required for future comparisons, into the
-   * specified slot.
-   * 
-   * @param slot which slot to copy the hit to
-   * @param doc docID relative to current reader
-   */
-  public abstract void copy(int slot, int doc) throws IOException;
-
-  /**
-   * Set a new Reader. All doc correspond to the current Reader.
-   * 
-   * @param reader current reader
-   * @param docBase docBase of this reader 
-   * @throws IOException
-   * @throws IOException
-   */
-  public abstract void setNextReader(IndexReader reader, int docBase) throws IOException;
-
-  /** Sets the Scorer to use in case a document's score is
-   *  needed.
-   * 
-   * @param scorer Scorer instance that you should use to
-   * obtain the current hit's score, if necessary. */
-  public void setScorer(Scorer scorer) {
-    // Empty implementation since most comparators don't need the score. This
-    // can be overridden by those that need it.
-  }
-  
-  /**
-   * Return the actual value in the slot.
-   *
-   * @param slot the value
-   * @return value in this slot upgraded to Comparable
-   */
-  public abstract Comparable value(int slot);
 }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java Sat Oct 24 21:23:15 2009
@@ -30,159 +30,107 @@
  *
  * @since   lucene 1.4
  */
-class FieldDocSortedHitQueue
-extends PriorityQueue<FieldDoc> {
+class FieldDocSortedHitQueue extends PriorityQueue<FieldDoc> {
 
-	volatile SortField[] fields;
+  volatile SortField[] fields;
 
-	// used in the case where the fields are sorted by locale
-	// based strings
-	volatile Collator[] collators;
-
-
-	/**
-	 * Creates a hit queue sorted by the given list of fields.
-	 * @param fields Fieldable names, in priority order (highest priority first).
-	 * @param size  The number of hits to retain.  Must be greater than zero.
-	 */
-	FieldDocSortedHitQueue (SortField[] fields, int size) {
-		this.fields = fields;
-		this.collators = hasCollators (fields);
-		initialize (size);
-	}
-
-
-	/**
-	 * Allows redefinition of sort fields if they are <code>null</code>.
-	 * This is to handle the case using ParallelMultiSearcher where the
-	 * original list contains AUTO and we don't know the actual sort
-	 * type until the values come back.  The fields can only be set once.
-	 * This method is thread safe.
-	 * @param fields
-	 */
-	synchronized void setFields (SortField[] fields) {
-		this.fields = fields;
-		this.collators = hasCollators (fields);
-	}
-
-
-	/** Returns the fields being used to sort. */
-	SortField[] getFields() {
-		return fields;
-	}
-
-
-	/** Returns an array of collators, possibly <code>null</code>.  The collators
-	 * correspond to any SortFields which were given a specific locale.
-	 * @param fields Array of sort fields.
-	 * @return Array, possibly <code>null</code>.
-	 */
-	private Collator[] hasCollators (final SortField[] fields) {
-		if (fields == null) return null;
-		Collator[] ret = new Collator[fields.length];
-		for (int i=0; i<fields.length; ++i) {
-			Locale locale = fields[i].getLocale();
-			if (locale != null)
-				ret[i] = Collator.getInstance (locale);
-		}
-		return ret;
-	}
-
-
-	/**
-	 * Returns whether <code>a</code> is less relevant than <code>b</code>.
-	 * @param a ScoreDoc
-	 * @param b ScoreDoc
-	 * @return <code>true</code> if document <code>a</code> should be sorted after document <code>b</code>.
-	 */
-	protected final boolean lessThan (final FieldDoc docA, final FieldDoc docB) {
-		final int n = fields.length;
-		int c = 0;
-		for (int i=0; i<n && c==0; ++i) {
-			final int type = fields[i].getType();
-			switch (type) {
-				case SortField.SCORE:{
-					float r1 = ((Float)docA.fields[i]).floatValue();
-					float r2 = ((Float)docB.fields[i]).floatValue();
-					if (r1 > r2) c = -1;
-					if (r1 < r2) c = 1;
-					break;
-        }
-        case SortField.DOC:
-				case SortField.INT:{
-					int i1 = ((Integer)docA.fields[i]).intValue();
-					int i2 = ((Integer)docB.fields[i]).intValue();
-					if (i1 < i2) c = -1;
-					if (i1 > i2) c = 1;
-					break;
-        }
-        case SortField.LONG:{
-					long l1 = ((Long)docA.fields[i]).longValue();
-					long l2 = ((Long)docB.fields[i]).longValue();
-					if (l1 < l2) c = -1;
-					if (l1 > l2) c = 1;
-					break;
-        }
-        case SortField.STRING:{
-					String s1 = (String) docA.fields[i];
-					String s2 = (String) docB.fields[i];
-					// null values need to be sorted first, because of how FieldCache.getStringIndex()
-					// works - in that routine, any documents without a value in the given field are
-					// put first.  If both are null, the next SortField is used
-					if (s1 == null) c = (s2==null) ? 0 : -1;
-					else if (s2 == null) c = 1;  // 
-					else if (fields[i].getLocale() == null) {
-						c = s1.compareTo(s2);
-					} else {
-						c = collators[i].compare (s1, s2);
-					}
-					break;
-        }
-        case SortField.FLOAT:{
-					float f1 = ((Float)docA.fields[i]).floatValue();
-					float f2 = ((Float)docB.fields[i]).floatValue();
-					if (f1 < f2) c = -1;
-					if (f1 > f2) c = 1;
-					break;
-        }
-        case SortField.DOUBLE:{
-					double d1 = ((Double)docA.fields[i]).doubleValue();
-					double d2 = ((Double)docB.fields[i]).doubleValue();
-					if (d1 < d2) c = -1;
-					if (d1 > d2) c = 1;
-					break;
-        }
-        case SortField.BYTE:{
-					int i1 = ((Byte)docA.fields[i]).byteValue();
-					int i2 = ((Byte)docB.fields[i]).byteValue();
-					if (i1 < i2) c = -1;
-					if (i1 > i2) c = 1;
-					break;
-        }
-        case SortField.SHORT:{
-					int i1 = ((Short)docA.fields[i]).shortValue();
-					int i2 = ((Short)docB.fields[i]).shortValue();
-					if (i1 < i2) c = -1;
-					if (i1 > i2) c = 1;
-					break;
-        }
-        case SortField.CUSTOM:{
-					c = docA.fields[i].compareTo (docB.fields[i]);
-					break;
-        }
-        default:{
-					throw new RuntimeException ("invalid SortField type: "+type);
+  // used in the case where the fields are sorted by locale
+  // based strings
+  volatile Collator[] collators;
+
+
+  /**
+   * Creates a hit queue sorted by the given list of fields.
+   * @param fields Fieldable names, in priority order (highest priority first).
+   * @param size  The number of hits to retain.  Must be greater than zero.
+   */
+  FieldDocSortedHitQueue (SortField[] fields, int size) {
+    this.fields = fields;
+    this.collators = hasCollators (fields);
+    initialize (size);
+  }
+
+
+  /**
+   * Allows redefinition of sort fields if they are <code>null</code>.
+   * This is to handle the case using ParallelMultiSearcher where the
+   * original list contains AUTO and we don't know the actual sort
+   * type until the values come back.  The fields can only be set once.
+   * This method is thread safe.
+   * @param fields
+   */
+  synchronized void setFields (SortField[] fields) {
+    this.fields = fields;
+    this.collators = hasCollators (fields);
+  }
+
+
+  /** Returns the fields being used to sort. */
+  SortField[] getFields() {
+    return fields;
+  }
+
+
+  /** Returns an array of collators, possibly <code>null</code>.  The collators
+   * correspond to any SortFields which were given a specific locale.
+   * @param fields Array of sort fields.
+   * @return Array, possibly <code>null</code>.
+   */
+  private Collator[] hasCollators (final SortField[] fields) {
+    if (fields == null) return null;
+    Collator[] ret = new Collator[fields.length];
+    for (int i=0; i<fields.length; ++i) {
+      Locale locale = fields[i].getLocale();
+      if (locale != null)
+        ret[i] = Collator.getInstance (locale);
+    }
+    return ret;
+  }
+
+
+  /**
+   * Returns whether <code>a</code> is less relevant than <code>b</code>.
+   * @param a ScoreDoc
+   * @param b ScoreDoc
+   * @return <code>true</code> if document <code>a</code> should be sorted after document <code>b</code>.
+   */
+  @SuppressWarnings("unchecked") @Override
+  protected final boolean lessThan(final FieldDoc docA, final FieldDoc docB) {
+    final int n = fields.length;
+    int c = 0;
+    for (int i=0; i<n && c==0; ++i) {
+      final int type = fields[i].getType();
+      if (type == SortField.STRING) {
+        final String s1 = (String) docA.fields[i];
+        final String s2 = (String) docB.fields[i];
+        // null values need to be sorted first, because of how FieldCache.getStringIndex()
+        // works - in that routine, any documents without a value in the given field are
+        // put first.  If both are null, the next SortField is used
+        if (s1 == null) {
+          c = (s2 == null) ? 0 : -1;
+        } else if (s2 == null) {
+          c = 1;
+        } else if (fields[i].getLocale() == null) {
+          c = s1.compareTo(s2);
+        } else {
+          c = collators[i].compare(s1, s2);
+        }
+      } else {
+        c = docA.fields[i].compareTo(docB.fields[i]);
+        if (type == SortField.SCORE) {
+          c = -c;
         }
       }
-			if (fields[i].getReverse()) {
-				c = -c;
-			}
-		}
+      // reverse sort
+      if (fields[i].getReverse()) {
+        c = -c;
+      }
+    }
 
     // avoid random sort order that could lead to duplicates (bug #31241):
     if (c == 0)
       return docA.doc > docB.doc;
 
     return c > 0;
-	}
+  }
 }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FuzzyQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FuzzyQuery.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FuzzyQuery.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FuzzyQuery.java Sat Oct 24 21:23:15 2009
@@ -131,10 +131,11 @@
   
   @Override
   public Query rewrite(IndexReader reader) throws IOException {
-    if(!termLongEnough) {  // can't match
-      return new BooleanQuery();
+    if(!termLongEnough) {  // can only match if it's exact
+      return new TermQuery(term);
     }
 
+    //nocommit: use termsEnum
     FilteredTermEnum enumerator = getEnum(reader);
     int maxClauseCount = BooleanQuery.getMaxClauseCount();
     ScoreTermQueue stQueue = new ScoreTermQueue(maxClauseCount);
@@ -158,7 +159,7 @@
             continue;
           }
 
-          reusableST = (ScoreTerm) stQueue.insertWithOverflow(reusableST);
+          reusableST = stQueue.insertWithOverflow(reusableST);
         }
       } while (enumerator.next());
     } finally {
@@ -168,7 +169,7 @@
     BooleanQuery query = new BooleanQuery(true);
     int size = stQueue.size();
     for(int i = 0; i < size; i++){
-      ScoreTerm st = (ScoreTerm) stQueue.pop();
+      ScoreTerm st = stQueue.pop();
       TermQuery tq = new TermQuery(st.term);      // found a match
       tq.setBoost(getBoost() * st.score); // set the boost
       query.add(tq, BooleanClause.Occur.SHOULD);          // add to query

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FuzzyTermEnum.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FuzzyTermEnum.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FuzzyTermEnum.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/FuzzyTermEnum.java Sat Oct 24 21:23:15 2009
@@ -17,11 +17,11 @@
  * limitations under the License.
  */
 
+import java.io.IOException;
+
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
 
-import java.io.IOException;
-
 /** Subclass of FilteredTermEnum for enumerating all terms that are similar
  * to the specified filter term.
  *
@@ -32,16 +32,11 @@
  */
 public final class FuzzyTermEnum extends FilteredTermEnum {
 
-  /* This should be somewhere around the average long word.
-   * If it is longer, we waste time and space. If it is shorter, we waste a
-   * little bit of time growing the array as we encounter longer words.
-   */
-  private static final int TYPICAL_LONGEST_WORD_IN_INDEX = 19;
-
   /* Allows us save time required to create a new array
    * every time similarity is called.
    */
-  private int[][] d;
+  private int[] p;
+  private int[] d;
 
   private float similarity;
   private boolean endEnum = false;
@@ -53,7 +48,6 @@
 
   private final float minimumSimilarity;
   private final float scale_factor;
-  private final int[] maxDistances = new int[TYPICAL_LONGEST_WORD_IN_INDEX];
 
   /**
    * Creates a FuzzyTermEnum with an empty prefix and a minSimilarity of 0.5f.
@@ -123,8 +117,8 @@
     this.text = searchTerm.text().substring(realPrefixLength);
     this.prefix = searchTerm.text().substring(0, realPrefixLength);
 
-    initializeMaxDistances();
-    this.d = initDistanceArray();
+    this.p = new int[this.text.length()+1];
+    this.d = new int[this.text.length()+1];
 
     setEnum(reader.terms(new Term(searchTerm.field(), prefix)));
   }
@@ -143,10 +137,12 @@
     return false;
   }
   
+  /** {@inheritDoc} */
   public final float difference() {
-    return (float)((similarity - minimumSimilarity) * scale_factor);
+    return (similarity - minimumSimilarity) * scale_factor;
   }
   
+  /** {@inheritDoc} */
   public final boolean endEnum() {
     return endEnum;
   }
@@ -156,18 +152,6 @@
    ******************************/
   
   /**
-   * Finds and returns the smallest of three integers 
-   */
-  private static final int min(int a, int b, int c) {
-    final int t = (a < b) ? a : b;
-    return (t < c) ? t : c;
-  }
-
-  private final int[][] initDistanceArray(){
-    return new int[this.text.length() + 1][TYPICAL_LONGEST_WORD_IN_INDEX];
-  }
-
-  /**
    * <p>Similarity returns a number that is 1.0f or less (including negative numbers)
    * based on how similar the Term is compared to a target term.  It returns
    * exactly 0.0f when
@@ -216,7 +200,7 @@
       return prefix.length() == 0 ? 0.0f : 1.0f - ((float) n / prefix.length());
     }
 
-    final int maxDistance = getMaxDistance(m);
+    final int maxDistance = calculateMaxDistance(m);
 
     if (maxDistance < Math.abs(m-n)) {
       //just adding the characters of m to n or vice-versa results in
@@ -229,56 +213,52 @@
       return 0.0f;
     }
 
-    //let's make sure we have enough room in our array to do the distance calculations.
-    if (d[0].length <= m) {
-      growDistanceArray(m);
+    // init matrix d
+    for (int i = 0; i<=n; ++i) {
+      p[i] = i;
     }
 
-    // init matrix d
-    for (int i = 0; i <= n; i++) d[i][0] = i;
-    for (int j = 0; j <= m; j++) d[0][j] = j;
-    
     // start computing edit distance
-    for (int i = 1; i <= n; i++) {
+    for (int j = 1; j<=m; ++j) { // iterates through target
       int bestPossibleEditDistance = m;
-      final char s_i = text.charAt(i - 1);
-      for (int j = 1; j <= m; j++) {
-        if (s_i != target.charAt(j-1)) {
-            d[i][j] = min(d[i-1][j], d[i][j-1], d[i-1][j-1])+1;
-        }
-        else {
-          d[i][j] = min(d[i-1][j]+1, d[i][j-1]+1, d[i-1][j-1]);
-        }
-        bestPossibleEditDistance = Math.min(bestPossibleEditDistance, d[i][j]);
+      final char t_j = target.charAt(j-1); // jth character of t
+      d[0] = j;
+
+      for (int i=1; i<=n; ++i) { // iterates through text
+        // minimum of cell to the left+1, to the top+1, diagonally left and up +(0|1)
+        if (t_j != text.charAt(i-1)) {
+          d[i] = Math.min(Math.min(d[i-1], p[i]),  p[i-1]) + 1;
+		} else {
+          d[i] = Math.min(Math.min(d[i-1]+1, p[i]+1),  p[i-1]);
+		}
+        bestPossibleEditDistance = Math.min(bestPossibleEditDistance, d[i]);
       }
 
       //After calculating row i, the best possible edit distance
       //can be found by found by finding the smallest value in a given column.
       //If the bestPossibleEditDistance is greater than the max distance, abort.
 
-      if (i > maxDistance && bestPossibleEditDistance > maxDistance) {  //equal is okay, but not greater
+      if (j > maxDistance && bestPossibleEditDistance > maxDistance) {  //equal is okay, but not greater
         //the closest the target can be to the text is just too far away.
         //this target is leaving the party early.
         return 0.0f;
       }
+
+      // copy current distance counts to 'previous row' distance counts: swap p and d
+      int _d[] = p;
+      p = d;
+      d = _d;
     }
 
+    // our last action in the above loop was to switch d and p, so p now
+    // actually has the most recent cost counts
+
     // this will return less than 0.0 when the edit distance is
     // greater than the number of characters in the shorter word.
     // but this was the formula that was previously used in FuzzyTermEnum,
     // so it has not been changed (even though minimumSimilarity must be
     // greater than 0.0)
-    return 1.0f - ((float)d[n][m] / (float) (prefix.length() + Math.min(n, m)));
-  }
-
-  /**
-   * Grow the second dimension of the array, so that we can calculate the
-   * Levenshtein difference.
-   */
-  private void growDistanceArray(int m) {
-    for (int i = 0; i < d.length; i++) {
-      d[i] = new int[m+1];
-    }
+    return 1.0f - ((float)p[n] / (float) (prefix.length() + Math.min(n, m)));
   }
 
   /**
@@ -288,21 +268,14 @@
    * @param m the length of the "other value"
    * @return the maximum levenshtein distance that we care about
    */
-  private final int getMaxDistance(int m) {
-    return (m < maxDistances.length) ? maxDistances[m] : calculateMaxDistance(m);
-  }
-
-  private void initializeMaxDistances() {
-    for (int i = 0; i < maxDistances.length; i++) {
-      maxDistances[i] = calculateMaxDistance(i);
-    }
-  }
-  
   private int calculateMaxDistance(int m) {
     return (int) ((1-minimumSimilarity) * (Math.min(text.length(), m) + prefix.length()));
   }
 
+  /** {@inheritDoc} */
   public void close() throws IOException {
+    p = d = null;
+    searchTerm = null;
     super.close();  //call super.close() and let the garbage collector do its work.
   }
   

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiPhraseQuery.java Sat Oct 24 21:23:15 2009
@@ -69,7 +69,7 @@
   public void add(Term[] terms) {
     int position = 0;
     if (positions.size() > 0)
-      position = ((Integer) positions.get(positions.size()-1)).intValue() + 1;
+      position = positions.get(positions.size()-1).intValue() + 1;
 
     add(terms, position);
   }
@@ -111,7 +111,7 @@
   public int[] getPositions() {
     int[] result = new int[positions.size()];
     for (int i = 0; i < positions.size(); i++)
-      result[i] = ((Integer) positions.get(i)).intValue();
+      result[i] = positions.get(i).intValue();
     return result;
   }
 
@@ -137,9 +137,10 @@
       this.similarity = getSimilarity(searcher);
 
       // compute idf
+      final int maxDoc = searcher.maxDoc();
       for(final Term[] terms: termArrays) {
         for (Term term: terms) {
-          idf += getSimilarity(searcher).idf(term, searcher);
+          idf += this.similarity.idf(searcher.docFreq(term), maxDoc);
         }
       }
     }
@@ -164,7 +165,7 @@
 
       DocsEnum[] docs = new DocsEnum[termArrays.size()];
       for (int i=0; i<docs.length; i++) {
-        Term[] terms = (Term[])termArrays.get(i);
+        Term[] terms = termArrays.get(i);
 
         final DocsEnum docsEnum;
         if (terms.length > 1) {
@@ -257,7 +258,7 @@
 
   public Query rewrite(IndexReader reader) {
     if (termArrays.size() == 1) {                 // optimize one-term case
-      Term[] terms = (Term[])termArrays.get(0);
+      Term[] terms = termArrays.get(0);
       BooleanQuery boq = new BooleanQuery(true);
       for (int i=0; i<terms.length; i++) {
         boq.add(new TermQuery(terms[i]), BooleanClause.Occur.SHOULD);

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiSearcher.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiSearcher.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiSearcher.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/MultiSearcher.java Sat Oct 24 21:23:15 2009
@@ -117,7 +117,7 @@
   private int maxDoc = 0;
 
   /** Creates a searcher which searches <i>searchers</i>. */
-  public MultiSearcher(Searchable[] searchables) throws IOException {
+  public MultiSearcher(Searchable... searchables) throws IOException {
     this.searchables = searchables;
 
     starts = new int[searchables.length + 1];	  // build starts array
@@ -198,7 +198,7 @@
 
     ScoreDoc[] scoreDocs = new ScoreDoc[hq.size()];
     for (int i = hq.size()-1; i >= 0; i--)	  // put docs in array
-      scoreDocs[i] = (ScoreDoc)hq.pop();
+      scoreDocs[i] = hq.pop();
     
     float maxScore = (totalHits==0) ? Float.NEGATIVE_INFINITY : scoreDocs[0].score;
     
@@ -241,7 +241,7 @@
 
     ScoreDoc[] scoreDocs = new ScoreDoc[hq.size()];
     for (int i = hq.size() - 1; i >= 0; i--)	  // put docs in array
-      scoreDocs[i] = (ScoreDoc) hq.pop();
+      scoreDocs[i] =  hq.pop();
 
     return new TopFieldDocs (totalHits, scoreDocs, hq.getFields(), maxScore);
   }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/ParallelMultiSearcher.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/ParallelMultiSearcher.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/ParallelMultiSearcher.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/ParallelMultiSearcher.java Sat Oct 24 21:23:15 2009
@@ -34,7 +34,7 @@
   private int[] starts;
 	
   /** Creates a searchable which searches <i>searchables</i>. */
-  public ParallelMultiSearcher(Searchable[] searchables) throws IOException {
+  public ParallelMultiSearcher(Searchable... searchables) throws IOException {
     super(searchables);
     this.searchables = searchables;
     this.starts = getStarts();
@@ -85,7 +85,7 @@
 
     ScoreDoc[] scoreDocs = new ScoreDoc[hq.size()];
     for (int i = hq.size() - 1; i >= 0; i--) // put docs in array
-      scoreDocs[i] = (ScoreDoc) hq.pop();
+      scoreDocs[i] = hq.pop();
 
     float maxScore = (totalHits==0) ? Float.NEGATIVE_INFINITY : scoreDocs[0].score;
     
@@ -133,7 +133,7 @@
 
     ScoreDoc[] scoreDocs = new ScoreDoc[hq.size()];
     for (int i = hq.size() - 1; i >= 0; i--) // put docs in array
-      scoreDocs[i] = (ScoreDoc) hq.pop();
+      scoreDocs[i] = hq.pop();
 
     return new TopFieldDocs(totalHits, scoreDocs, hq.getFields(), maxScore);
   }
@@ -199,7 +199,7 @@
   private int nDocs;
   private TopDocs docs;
   private int i;
-  private PriorityQueue hq;
+  private PriorityQueue<? extends ScoreDoc> hq;
   private int[] starts;
   private IOException ioe;
   private Sort sort;
@@ -230,6 +230,7 @@
     this.sort = sort;
   }
 
+  @SuppressWarnings ("unchecked")
   public void run() {
     try {
       docs = (sort == null) ? searchable.search (weight, filter, nDocs)
@@ -266,7 +267,9 @@
         scoreDoc.doc += starts[i]; // convert doc 
         //it would be so nice if we had a thread-safe insert 
         synchronized (hq) {
-          if (scoreDoc == hq.insertWithOverflow(scoreDoc))
+          // this cast is bad, because we assume that the list has correct type.
+          // Because of that we have the @SuppressWarnings :-(
+          if (scoreDoc == ((PriorityQueue<ScoreDoc>) hq).insertWithOverflow(scoreDoc))
             break;
         } // no more scores > minScore
       }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PhraseScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PhraseScorer.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PhraseScorer.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/PhraseScorer.java Sat Oct 24 21:23:15 2009
@@ -153,7 +153,7 @@
   protected final void pqToList() {
     last = first = null;
     while (pq.top() != null) {
-      PhrasePositions pp = (PhrasePositions) pq.pop();
+      PhrasePositions pp = pq.pop();
       if (last != null) {			  // add next to end of list
         last.next = pp;
       } else

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/Query.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/Query.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/Query.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/Query.java Sat Oct 24 21:23:15 2009
@@ -150,7 +150,7 @@
     }
     // optimization: if we have just one query, just return it
     if(uniques.size() == 1){
-        return (Query)uniques.iterator().next();
+        return uniques.iterator().next();
     }
     BooleanQuery result = new BooleanQuery(true);
     for (final Query query : uniques)

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/QueryTermVector.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/QueryTermVector.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/QueryTermVector.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/QueryTermVector.java Sat Oct 24 21:23:15 2009
@@ -68,7 +68,7 @@
             terms.add(termAtt.term());
             hasMoreTokens = stream.incrementToken();
           }
-          processTerms((String[])terms.toArray(new String[terms.size()]));
+          processTerms(terms.toArray(new String[terms.size()]));
         } catch (IOException e) {
         }
       }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/QueryWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/QueryWrapperFilter.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/QueryWrapperFilter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/QueryWrapperFilter.java Sat Oct 24 21:23:15 2009
@@ -18,7 +18,7 @@
  */
 
 import java.io.IOException;
-import java.util.BitSet;
+
 
 import org.apache.lucene.index.IndexReader;
 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/Similarity.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/Similarity.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/Similarity.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/Similarity.java Sat Oct 24 21:23:15 2009
@@ -704,27 +704,6 @@
    */
   public abstract float tf(float freq);
 
-  /** Computes a score factor for a simple term.
-   *
-   * <p>The default implementation is:<pre>
-   *   return idf(searcher.docFreq(term), searcher.maxDoc());
-   * </pre>
-   *
-   * Note that {@link Searcher#maxDoc()} is used instead of
-   * {@link org.apache.lucene.index.IndexReader#numDocs() IndexReader#numDocs()} because also 
-   * {@link Searcher#docFreq(Term)} is used, and when the latter 
-   * is inaccurate, so is {@link Searcher#maxDoc()}, and in the same direction.
-   * In addition, {@link Searcher#maxDoc()} is more efficient to compute
-   *
-   * @param term the term in question
-   * @param searcher the document collection being searched
-   * @return a score factor for the term
-   * @deprecated see {@link #idfExplain(Term, Searcher)}
-   */
-  public float idf(Term term, Searcher searcher) throws IOException {
-    return idf(searcher.docFreq(term), searcher.maxDoc());
-  }
-  
   /**
    * Computes a score factor for a simple term and returns an explanation
    * for that score factor.
@@ -749,53 +728,21 @@
    * @throws IOException
    */
   public IDFExplanation idfExplain(final Term term, final Searcher searcher) throws IOException {
-    if(supportedMethods.overridesTermIDF) {
-      final float idf = idf(term, searcher);
-      return new IDFExplanation() {
-        //@Override
-        public float getIdf() {
-          return idf;
-        }
-        //@Override
-        public String explain() {
-          return "Inexplicable";
-        }
-      };
-    }
     final int df = searcher.docFreq(term);
     final int max = searcher.maxDoc();
     final float idf = idf(df, max);
     return new IDFExplanation() {
-        //@Override
+        @Override
         public String explain() {
           return "idf(docFreq=" + df +
           ", maxDocs=" + max + ")";
         }
-        //@Override
+        @Override
         public float getIdf() {
           return idf;
         }};
    }
 
-  /** Computes a score factor for a phrase.
-   *
-   * <p>The default implementation sums the {@link #idf(Term,Searcher)} factor
-   * for each term in the phrase.
-   *
-   * @param terms the terms in the phrase
-   * @param searcher the document collection being searched
-   * @return idf score factor
-   * @deprecated see {@link #idfExplain(Collection, Searcher)}
-   */
-  public float idf(Collection<Term> terms, Searcher searcher) throws IOException {
-    float idf = 0.0f;
-
-    for(final Term term: terms) {
-      idf += idf(term, searcher);
-    }
-    return idf;
-  }
-  
   /**
    * Computes a score factor for a phrase.
    * 
@@ -811,19 +758,6 @@
    * @throws IOException
    */
   public IDFExplanation idfExplain(Collection<Term> terms, Searcher searcher) throws IOException {
-    if(supportedMethods.overridesCollectionIDF) {
-      final float idf = idf(terms, searcher);
-      return new IDFExplanation() {
-        //@Override
-        public float getIdf() {
-          return idf;
-        }
-        //@Override
-        public String explain() {
-          return "Inexplicable";
-        }
-      };
-    }
     final int max = searcher.maxDoc();
     float idf = 0.0f;
     final StringBuilder exp = new StringBuilder();
@@ -837,11 +771,11 @@
     }
     final float fIdf = idf;
     return new IDFExplanation() {
-      //@Override
+      @Override
       public float getIdf() {
         return fIdf;
       }
-      //@Override
+      @Override
       public String explain() {
         return exp.toString();
       }
@@ -877,31 +811,6 @@
    */
   public abstract float coord(int overlap, int maxOverlap);
 
-
-
-
-  /**
-   * Calculate a scoring factor based on the data in the payload.  Overriding implementations
-   * are responsible for interpreting what is in the payload.  Lucene makes no assumptions about
-   * what is in the byte array.
-   * <p>
-   * The default implementation returns 1.
-   *
-   * @param fieldName The fieldName of the term this payload belongs to
-   * @param payload The payload byte array to be scored
-   * @param offset The offset into the payload array
-   * @param length The length in the array
-   * @return An implementation dependent float to be used as a scoring factor
-   *
-   * @deprecated See {@link #scorePayload(int, String, int, int, byte[], int, int)}
-   */
-  //TODO: When removing this, set the default value below to return 1.
-  public float scorePayload(String fieldName, byte [] payload, int offset, int length)
-  {
-    //Do nothing
-    return 1;
-  }
-
   /**
    * Calculate a scoring factor based on the data in the payload.  Overriding implementations
    * are responsible for interpreting what is in the payload.  Lucene makes no assumptions about
@@ -921,50 +830,7 @@
    */
   public float scorePayload(int docId, String fieldName, int start, int end, byte [] payload, int offset, int length)
   {
-    //TODO: When removing the deprecated scorePayload above, set this to return 1
-    return scorePayload(fieldName, payload, offset, length);
-  }
-  
-  /** @deprecated Remove this when old API is removed! */
-  private final MethodSupport supportedMethods = getSupportedMethods(this.getClass());
-  
-    /** @deprecated Remove this when old API is removed! */
-  private static final class MethodSupport implements Serializable {
-    final boolean overridesCollectionIDF, overridesTermIDF;
-
-    MethodSupport(Class clazz) {
-      overridesCollectionIDF = isMethodOverridden(clazz, "idf", C_IDF_METHOD_PARAMS);
-      overridesTermIDF = isMethodOverridden(clazz, "idf", T_IDF_METHOD_PARAMS);
-    }
-    
-    private static boolean isMethodOverridden(Class clazz, String name, Class[] params) {
-      try {
-        return clazz.getMethod(name, params).getDeclaringClass() != Similarity.class;
-      } catch (NoSuchMethodException e) {
-        // should not happen
-        throw new RuntimeException(e);
-      }
-    }
-    /** @deprecated Remove this when old API is removed! */
-    private static final Class[] T_IDF_METHOD_PARAMS = new Class[]{Term.class, Searcher.class};
-    
-    /** @deprecated Remove this when old API is removed! */
-    private static final Class[] C_IDF_METHOD_PARAMS = new Class[]{Collection.class, Searcher.class};
-  }
-  
-  /** @deprecated Remove this when old API is removed! */
-  private static final IdentityHashMap<Class<? extends Similarity>,MethodSupport> knownMethodSupport = new IdentityHashMap();
-  
-  /** @deprecated Remove this when old API is removed! */
-  private static MethodSupport getSupportedMethods(Class clazz) {
-    MethodSupport supportedMethods;
-    synchronized(knownMethodSupport) {
-      supportedMethods = (MethodSupport) knownMethodSupport.get(clazz);
-      if (supportedMethods == null) {
-        knownMethodSupport.put(clazz, supportedMethods = new MethodSupport(clazz));
-      }
-    }
-    return supportedMethods;
+    return 1;
   }
   
   /** The Similarity implementation used by default. 

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SimilarityDelegator.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SimilarityDelegator.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SimilarityDelegator.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SimilarityDelegator.java Sat Oct 24 21:23:15 2009
@@ -62,7 +62,7 @@
     return delegee.coord(overlap, maxOverlap);
   }
 
-  public float scorePayload(String fieldName, byte[] payload, int offset, int length) {
-    return delegee.scorePayload(fieldName, payload, offset, length);
+  public float scorePayload(int docId, String fieldName, int start, int end, byte [] payload, int offset, int length) {
+    return delegee.scorePayload(docId, fieldName, start, end, payload, offset, length);
   }
 }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SloppyPhraseScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SloppyPhraseScorer.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SloppyPhraseScorer.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/SloppyPhraseScorer.java Sat Oct 24 21:23:15 2009
@@ -58,9 +58,9 @@
         float freq = 0.0f;
         boolean done = (end<0);
         while (!done) {
-            PhrasePositions pp = (PhrasePositions) pq.pop();
+            PhrasePositions pp = pq.pop();
             int start = pp.position;
-            int next = ((PhrasePositions) pq.top()).position;
+            int next = pq.top().position;
 
             boolean tpsDiffer = true;
             for (int pos = start; pos <= next || !tpsDiffer; pos = pp.position) {
@@ -96,7 +96,7 @@
       int n=0;
       PhrasePositions pp3;
       //pop until finding pp2
-      while ((pp3=(PhrasePositions)pq.pop()) != pp2) {
+      while ((pp3=pq.pop()) != pp2) {
         tmpPos[n++] = pp3;
       }
       //insert back all but pp2

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/TopFieldCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/TopFieldCollector.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/TopFieldCollector.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/TopFieldCollector.java Sat Oct 24 21:23:15 2009
@@ -939,7 +939,7 @@
       // avoid casting if unnecessary.
       FieldValueHitQueue queue = (FieldValueHitQueue) pq;
       for (int i = howMany - 1; i >= 0; i--) {
-        results[i] = queue.fillFields((Entry) queue.pop());
+        results[i] = queue.fillFields(queue.pop());
       }
     } else {
       for (int i = howMany - 1; i >= 0; i--) {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/payloads/PayloadSpanUtil.java Sat Oct 24 21:23:15 2009
@@ -131,7 +131,7 @@
           }
         }
 
-        final List<Query>[] disjunctLists = new List[maxPosition + 1];
+        @SuppressWarnings("unchecked") final List<Query>[] disjunctLists = new List[maxPosition + 1];
         int distinctPositions = 0;
 
         for (int i = 0; i < termArrays.size(); ++i) {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/NearSpansUnordered.java Sat Oct 24 21:23:15 2009
@@ -211,7 +211,7 @@
     return more && (atMatch() ||  next());
   }
 
-  private SpansCell min() { return (SpansCell)queue.top(); }
+  private SpansCell min() { return queue.top(); }
 
   public int doc() { return min().doc(); }
   public int start() { return min().start(); }
@@ -281,7 +281,7 @@
   private void queueToList() throws IOException {
     last = first = null;
     while (queue.top() != null) {
-      addToList((SpansCell)queue.pop());
+      addToList(queue.pop());
     }
   }
   

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/SpanOrQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/SpanOrQuery.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/SpanOrQuery.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/search/spans/SpanOrQuery.java Sat Oct 24 21:23:15 2009
@@ -54,7 +54,7 @@
 
   /** Return the clauses whose spans are matched. */
   public SpanQuery[] getClauses() {
-    return (SpanQuery[])clauses.toArray(new SpanQuery[clauses.size()]);
+    return clauses.toArray(new SpanQuery[clauses.size()]);
   }
 
   public String getField() { return field; }
@@ -151,7 +151,7 @@
 
   public Spans getSpans(final IndexReader reader) throws IOException {
     if (clauses.size() == 1)                      // optimize 1-clause case
-      return ((SpanQuery)clauses.get(0)).getSpans(reader);
+      return (clauses.get(0)).getSpans(reader);
 
     return new Spans() {
         private SpanQueue queue = null;
@@ -187,7 +187,7 @@
           return queue.size() != 0;
         }
 
-        private Spans top() { return (Spans)queue.top(); }
+        private Spans top() { return queue.top(); }
 
         public boolean skipTo(int target) throws IOException {
           if (queue == null) {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/RAMFile.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/RAMFile.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/RAMFile.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/RAMFile.java Sat Oct 24 21:23:15 2009
@@ -71,7 +71,7 @@
   }
 
   final synchronized byte[] getBuffer(int index) {
-    return (byte[]) buffers.get(index);
+    return buffers.get(index);
   }
 
   final synchronized int numBuffers() {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/RAMInputStream.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/RAMInputStream.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/RAMInputStream.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/RAMInputStream.java Sat Oct 24 21:23:15 2009
@@ -92,7 +92,7 @@
         bufferPosition = BUFFER_SIZE;
       }
     } else {
-      currentBuffer = (byte[]) file.getBuffer(currentBufferIndex);
+      currentBuffer = file.getBuffer(currentBufferIndex);
       bufferPosition = 0;
       bufferStart = (long) BUFFER_SIZE * (long) currentBufferIndex;
       long buflen = length - bufferStart;

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/RAMOutputStream.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/RAMOutputStream.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/RAMOutputStream.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/store/RAMOutputStream.java Sat Oct 24 21:23:15 2009
@@ -61,7 +61,7 @@
       if (nextPos > end) {                        // at the last buffer
         length = (int)(end - pos);
       }
-      out.writeBytes((byte[])file.getBuffer(buffer++), length);
+      out.writeBytes(file.getBuffer(buffer++), length);
       pos = nextPos;
     }
   }
@@ -126,7 +126,7 @@
     if (currentBufferIndex == file.numBuffers()) {
       currentBuffer = file.addBuffer(BUFFER_SIZE);
     } else {
-      currentBuffer = (byte[]) file.getBuffer(currentBufferIndex);
+      currentBuffer = file.getBuffer(currentBufferIndex);
     }
     bufferPosition = 0;
     bufferStart = (long) BUFFER_SIZE * (long) currentBufferIndex;

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/Constants.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/Constants.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/Constants.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/Constants.java Sat Oct 24 21:23:15 2009
@@ -64,7 +64,13 @@
     }
   }
 
-  public static final String LUCENE_MAIN_VERSION = "3.0";
+  // this method prevents inlining the final version constant in compiled classes,
+  // see: http://www.javaworld.com/community/node/3400
+  private static String ident(final String s) {
+    return s.toString();
+  }
+  
+  public static final String LUCENE_MAIN_VERSION = ident("3.0");
 
   public static final String LUCENE_VERSION;
   static {
@@ -72,9 +78,9 @@
     String v = (pkg == null) ? null : pkg.getImplementationVersion();
     if (v == null) {
       v = LUCENE_MAIN_VERSION + "-dev";
-    } else if (v.indexOf(LUCENE_MAIN_VERSION) == -1) {
-      v = v + " [" + LUCENE_MAIN_VERSION + "]";
+    } else if (!v.startsWith(LUCENE_MAIN_VERSION)) {
+      v = LUCENE_MAIN_VERSION + "-dev " + v;
     }
-    LUCENE_VERSION = v;
+    LUCENE_VERSION = ident(v);
   }
 }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/FieldCacheSanityChecker.java Sat Oct 24 21:23:15 2009
@@ -271,7 +271,7 @@
    * returned by obj.getFieldCacheKey()
    */
   private List getAllDecendentReaderKeys(Object seed) {
-    List all = new ArrayList(17); // will grow as we iter
+    List<Object> all = new ArrayList<Object>(17); // will grow as we iter
     all.add(seed);
     for (int i = 0; i < all.size(); i++) {
       Object obj = all.get(i);

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/Parameter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/Parameter.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/Parameter.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/Parameter.java Sat Oct 24 21:23:15 2009
@@ -25,7 +25,9 @@
 
 /**
  * A serializable Enum class.
+ * @deprecated Use Java 5 enum, will be removed in a later Lucene 3.x release.
  */
+@SuppressWarnings("serial")
 public abstract class Parameter implements Serializable
 {
   static Map<String,Parameter> allParameters = new HashMap<String,Parameter>();

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/ReaderUtil.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/ReaderUtil.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/ReaderUtil.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/ReaderUtil.java Sat Oct 24 21:23:15 2009
@@ -56,7 +56,7 @@
   public static IndexReader subReader(int doc, IndexReader reader) {
     List<IndexReader> subReadersList = new ArrayList<IndexReader>();
     ReaderUtil.gatherSubReaders(subReadersList, reader);
-    IndexReader[] subReaders = (IndexReader[]) subReadersList
+    IndexReader[] subReaders = subReadersList
         .toArray(new IndexReader[subReadersList.size()]);
     int[] docStarts = new int[subReaders.length];
     int maxDoc = 0;
@@ -77,7 +77,7 @@
   public static IndexReader subReader(IndexReader reader, int subIndex) {
     List<IndexReader> subReadersList = new ArrayList<IndexReader>();
     ReaderUtil.gatherSubReaders(subReadersList, reader);
-    IndexReader[] subReaders = (IndexReader[]) subReadersList
+    IndexReader[] subReaders = subReadersList
         .toArray(new IndexReader[subReadersList.size()]);
     return subReaders[subIndex];
   }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/Version.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/Version.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/Version.java (original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/util/Version.java Sat Oct 24 21:23:15 2009
@@ -18,15 +18,36 @@
  */
 
 
-import java.io.Serializable;
-
 /**
  * Use by certain classes to match version compatibility
  * across releases of Lucene.
  */
-public final class Version extends Parameter implements Serializable {
+public enum Version {
+
+  /** Match settings and bugs in Lucene's 2.0 release. */
+  LUCENE_20,
+
+  /** Match settings and bugs in Lucene's 2.1 release. */
+  LUCENE_21,
+
+  /** Match settings and bugs in Lucene's 2.2 release. */
+  LUCENE_22,
+
+  /** Match settings and bugs in Lucene's 2.3 release. */
+  LUCENE_23,
+
+  /** Match settings and bugs in Lucene's 2.4 release. */
+  LUCENE_24,
+
+  /** Match settings and bugs in Lucene's 2.9 release. */
+  LUCENE_29,
 
-  /** Use this to get the latest & greatest settings, bug
+  /** Match settings and bugs in Lucene's 3.0 release. */
+  LUCENE_30,
+  
+  /* Add new constants for later versions **here** to respect order! */
+
+  /** Use this to get the latest &amp; greatest settings, bug
    *  fixes, etc, for Lucene.
    *
    * <p><b>WARNING</b>: if you use this setting, and then
@@ -35,22 +56,9 @@
    * then you should instead explicitly specify an actual
    * version.
    */
-  public static final Version LUCENE_CURRENT = new Version("LUCENE_CURRENT", 0);
-  
-  /** Match settings and bugs in Lucene's 2.4 release. */
-  public static final Version LUCENE_24 = new Version("LUCENE_24", 2400);
-
-  /** Match settings and bugs in Lucene's 2.9 release. */
-  public static final Version LUCENE_29 = new Version("LUCENE_29", 2900);
-
-  private final int v;
-
-  public Version(String name, int v) {
-    super(name);
-    this.v = v;
-  }
+  LUCENE_CURRENT;
 
   public boolean onOrAfter(Version other) {
-    return v == 0 || v >= other.v;
+    return compareTo(other) >= 0;
   }
 }
\ No newline at end of file

Modified: lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestDemo.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestDemo.java?rev=829454&r1=829453&r2=829454&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestDemo.java (original)
+++ lucene/java/branches/flex_1458/src/test/org/apache/lucene/TestDemo.java Sat Oct 24 21:23:15 2009
@@ -63,7 +63,7 @@
     // Now search the index:
     IndexSearcher isearcher = new IndexSearcher(directory, true); // read-only=true
     // Parse a simple query that searches for "text":
-    QueryParser parser = new QueryParser("fieldname", analyzer);
+    QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, "fieldname", analyzer);
     Query query = parser.parse("text");
     ScoreDoc[] hits = isearcher.search(query, null, 1000).scoreDocs;
     assertEquals(1, hits.length);



Mime
View raw message